Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
 4.2.99
mctp_i2c_gpio_target.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/pmci/mctp/mctp_i2c_gpio_common.h>
#include <libmctp.h>

Go to the source code of this file.

Data Structures

struct  mctp_binding_i2c_gpio_target
 An MCTP binding for Zephyr's I2C target interface using GPIO. More...

Macros

#define MCTP_I2C_GPIO_TARGET_DT_DEFINE(_name, _node_id)
 INTERNAL_HIDDEN.

Macro Definition Documentation

◆ MCTP_I2C_GPIO_TARGET_DT_DEFINE

#define MCTP_I2C_GPIO_TARGET_DT_DEFINE ( _name,
_node_id )
Value:
K_SEM_DEFINE(_name ##_tx_lock, 1, 1); \
K_SEM_DEFINE(_name ##_tx_complete, 0, 1); \
struct mctp_binding_i2c_gpio_target _name = { \
.binding = { \
.name = STRINGIFY(_name), .version = 1, \
.start = mctp_i2c_gpio_target_start, \
.tx = mctp_i2c_gpio_target_tx, \
.pkt_size = MCTP_I2C_GPIO_MAX_PKT_SIZE, \
}, \
.i2c = DEVICE_DT_GET(DT_PHANDLE(_node_id, i2c)), \
.i2c_target_cfg = { \
.address = DT_PROP(_node_id, i2c_addr), \
.callbacks = &mctp_i2c_gpio_target_callbacks, \
}, \
.endpoint_id = DT_PROP(_node_id, endpoint_id), \
.endpoint_gpio = GPIO_DT_SPEC_GET(_node_id, endpoint_gpios), \
.tx_lock = &_name##_tx_lock, \
.tx_complete = &_name##_tx_complete, \
};
#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(node_id, prop)
Get a devicetree property value.
Definition devicetree.h:762
#define GPIO_DT_SPEC_GET(node_id, prop)
Equivalent to GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, 0).
Definition gpio.h:369
#define K_SEM_DEFINE(name, initial_count, count_limit)
Statically define and initialize a semaphore.
Definition kernel.h:3410
#define STRINGIFY(s)
Definition common.h:165
An MCTP binding for Zephyr's I2C target interface using GPIO.
Definition mctp_i2c_gpio_target.h:22

INTERNAL_HIDDEN.

Define a MCTP bus binding for I2C target with GPIO

Rather than mode switching as the MCTP standard wishes, this is a custom binding. On the target side a gpio pin is set active (could be active low or active high) when writes are pending. It's expected the controller then reads from the I2C target device at some point in the future. Reads are accepted at any time and are expected to contain full mctp packets.

In effect each device has a pair of pseudo registers for reading or writing as a packet FIFO.

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