Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
 4.2.99
mctp_i2c_gpio_controller.h File Reference
#include <stdint.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/mpsc_lockfree.h>
#include <zephyr/rtio/rtio.h>
#include <zephyr/pmci/mctp/mctp_i2c_gpio_common.h>
#include <libmctp.h>
#include <stdatomic.h>

Go to the source code of this file.

Data Structures

struct  mctp_binding_i2c_gpio_controller
 INTERNAL_HIDDEN. More...

Macros

#define MCTP_I2C_GPIO_CONTROLLER_DT_DEFINE(_name, _node_id)
 INTERNAL_HIDDEN.

Macro Definition Documentation

◆ MCTP_I2C_GPIO_CONTROLLER_DT_DEFINE

#define MCTP_I2C_GPIO_CONTROLLER_DT_DEFINE ( _name,
_node_id )
Value:
RTIO_DEFINE(_name##_rtio_tx, 5, 5); \
RTIO_DEFINE(_name##_rtio_rx, 5, 5); \
MCTP_I2C_GPIO_CONTROLLER_DEFINE_IODEVS(_node_id, _name); \
MCTP_I2C_GPIO_CONTROLLER_DEFINE_GPIOS(_node_id, _name); \
MCTP_I2C_GPIO_CONTROLLER_DEFINE_IDS(_node_id, _name); \
MCTP_I2C_GPIO_CONTROLLER_DEFINE_GPIO_CBS(_node_id, _name); \
K_SEM_DEFINE(_name##_tx_lock, 1, 1); \
.binding = { \
.name = STRINGIFY(_name), .version = 1, \
.start = mctp_i2c_gpio_controller_start, \
.tx = mctp_i2c_gpio_controller_tx, \
.pkt_size = MCTP_I2C_GPIO_MAX_PKT_SIZE, \
}, \
.i2c = DEVICE_DT_GET(DT_PHANDLE(_node_id, i2c)), \
.num_endpoints = DT_PROP_LEN(_node_id, endpoint_ids), \
.endpoint_ids = _name##_endpoint_ids, \
.endpoint_gpios = _name##_endpoint_gpios, \
.endpoint_gpio_cbs = _name##_endpoint_gpio_cbs, \
.endpoint_iodevs = _name##_endpoint_iodevs, \
.r_tx = &_name##_rtio_tx, \
.r_rx = &_name##_rtio_rx, \
.tx_lock = &_name##_tx_lock, \
};
#define DEVICE_DT_GET(node_id)
Get a device reference from a devicetree node identifier.
Definition device.h:314
#define DT_PHANDLE(node_id, prop)
Get a node identifier for a phandle property's value.
Definition devicetree.h:1799
#define DT_PROP_LEN(node_id, prop)
Get a property's logical length.
Definition devicetree.h:796
#define RTIO_DEFINE(name, sq_sz, cq_sz)
Statically define and initialize an RTIO context.
Definition rtio.h:960
#define STRINGIFY(s)
Definition common.h:165
INTERNAL_HIDDEN.
Definition mctp_i2c_gpio_controller.h:40

INTERNAL_HIDDEN.

Define a MCTP bus binding for I2C controller with GPIO

Rather than mode switching as the MCTP standard wishes, this is a custom binding. On the controller side each neighbor has an associated i2c address and gpio it will listen for a trigger on. When triggered the controller will read the target device. The target device will be expected to have what amounts to two registers, one containing a message length and another containing a FIFO like register producing the message bytes.

Thus the sequence for a I2C target to send a message would be...

  1. Setup a length and message value (pseudo registers).
  2. Signal the controller with a GPIO level set
  3. The controller then is expected to read the length (write of addr 0 + read 1 byte)
  4. The controller then is expected to read the message (write of addr 1 + read N bytes)
  5. The target clears the pin set
  6. The controller reports a message receive to MCTP
Parameters
_nameSymbolic name of the bus binding variable
_node_idDeviceTree Node containing the configuration of this MCTP binding