Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mctp_i2c_gpio_target.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 */
7
13
14#ifndef ZEPHYR_INCLUDE_PMCI_MCTP_MCTP_I2C_GPIO_TARGET_H_
15#define ZEPHYR_INCLUDE_PMCI_MCTP_MCTP_I2C_GPIO_TARGET_H_
16
17#include <stdint.h>
18#include <zephyr/kernel.h>
19#include <zephyr/device.h>
20#include <zephyr/drivers/i2c.h>
21#include <zephyr/drivers/gpio.h>
23#include <libmctp.h>
24
30 struct mctp_binding binding;
31 const struct device *i2c;
32 struct i2c_target_config i2c_target_cfg;
33 uint8_t endpoint_id;
34 const struct gpio_dt_spec endpoint_gpio;
35 uint8_t reg_addr;
36 bool rxtx;
37 uint8_t rx_idx;
38 uint8_t rx_exp_len;
39 struct mctp_pktbuf *rx_pkt;
40 struct k_sem *tx_lock;
41 struct k_sem *tx_complete;
42 uint8_t tx_idx;
43 struct mctp_pktbuf *tx_pkt;
44 uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_I2C_GPIO_MAX_PKT_SIZE)] PKTBUF_STORAGE_ALIGN;
46};
47
49extern const struct i2c_target_callbacks mctp_i2c_gpio_target_callbacks;
50int mctp_i2c_gpio_target_start(struct mctp_binding *binding);
51int mctp_i2c_gpio_target_tx(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
52int mctp_i2c_gpio_target_unregister(struct mctp_binding_i2c_gpio_target *b);
54
79#define MCTP_I2C_GPIO_TARGET_DT_DEFINE(_name, _node_id) \
80 K_SEM_DEFINE(_name ##_tx_lock, 1, 1); \
81 K_SEM_DEFINE(_name ##_tx_complete, 0, 1); \
82 struct mctp_binding_i2c_gpio_target _name = { \
83 .binding = { \
84 .name = STRINGIFY(_name), .version = 1, \
85 .start = mctp_i2c_gpio_target_start, \
86 .tx = mctp_i2c_gpio_target_tx, \
87 .pkt_size = MCTP_I2C_GPIO_MAX_PKT_SIZE, \
88 .tx_storage = _name.tx_storage, \
89 }, \
90 .i2c = DEVICE_DT_GET(DT_PHANDLE(_node_id, i2c)), \
91 .i2c_target_cfg = { \
92 .address = DT_PROP(_node_id, i2c_addr), \
93 .callbacks = &mctp_i2c_gpio_target_callbacks, \
94 }, \
95 .endpoint_id = DT_PROP(_node_id, endpoint_id), \
96 .endpoint_gpio = GPIO_DT_SPEC_GET(_node_id, endpoint_gpios), \
97 .tx_lock = &_name##_tx_lock, \
98 .tx_complete = &_name##_tx_complete, \
99 };
100
101#endif /* ZEPHYR_INCLUDE_PMCI_MCTP_MCTP_I2C_GPIO_TARGET_H_ */
Main header file for GPIO driver API.
Main header file for I2C (Inter-Integrated Circuit) driver API.
Public kernel APIs.
Internal definitions shared by the MCTP I2C GPIO controller and target bindings.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
Container for GPIO pin information specified in devicetree.
Definition gpio.h:296
Structure providing callbacks to be implemented for devices that supports the I2C target API.
Definition i2c.h:556
Structure describing a device that supports the I2C target API.
Definition i2c.h:594
Semaphore structure.
Definition kernel.h:3798
An MCTP binding for Zephyr's I2C target interface using GPIO.
Definition mctp_i2c_gpio_target.h:28