Zephyr API
4.4.99
A Scalable Open Source RTOS
Toggle main menu visibility
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
8
#ifndef ZEPHYR_MCTP_I2C_GPIO_TARGET_H_
9
#define ZEPHYR_MCTP_I2C_GPIO_TARGET_H_
10
11
#include <
stdint.h
>
12
#include <
zephyr/kernel.h
>
13
#include <
zephyr/device.h
>
14
#include <
zephyr/drivers/i2c.h
>
15
#include <
zephyr/drivers/gpio.h
>
16
#include <
zephyr/pmci/mctp/mctp_i2c_gpio_common.h
>
17
#include <libmctp.h>
18
22
struct
mctp_binding_i2c_gpio_target
{
24
struct
mctp_binding binding;
25
const
struct
device
*i2c;
26
struct
i2c_target_config
i2c_target_cfg;
27
uint8_t
endpoint_id;
28
const
struct
gpio_dt_spec
endpoint_gpio;
29
uint8_t
reg_addr;
30
bool
rxtx;
31
uint8_t
rx_idx;
32
uint8_t
rx_exp_len;
33
struct
mctp_pktbuf *rx_pkt;
34
struct
k_sem
*tx_lock;
35
struct
k_sem
*tx_complete;
36
uint8_t
tx_idx;
37
struct
mctp_pktbuf *tx_pkt;
38
uint8_t
tx_storage[MCTP_PKTBUF_SIZE(MCTP_I2C_GPIO_MAX_PKT_SIZE)] PKTBUF_STORAGE_ALIGN;
40
};
41
43
extern
const
struct
i2c_target_callbacks
mctp_i2c_gpio_target_callbacks;
44
int
mctp_i2c_gpio_target_start(
struct
mctp_binding *binding);
45
int
mctp_i2c_gpio_target_tx(
struct
mctp_binding *binding,
struct
mctp_pktbuf *pkt);
46
int
mctp_i2c_gpio_target_unregister(
struct
mctp_binding_i2c_gpio_target
*b);
48
73
#define MCTP_I2C_GPIO_TARGET_DT_DEFINE(_name, _node_id) \
74
K_SEM_DEFINE(_name ##_tx_lock, 1, 1); \
75
K_SEM_DEFINE(_name ##_tx_complete, 0, 1); \
76
struct mctp_binding_i2c_gpio_target _name = { \
77
.binding = { \
78
.name = STRINGIFY(_name), .version = 1, \
79
.start = mctp_i2c_gpio_target_start, \
80
.tx = mctp_i2c_gpio_target_tx, \
81
.pkt_size = MCTP_I2C_GPIO_MAX_PKT_SIZE, \
82
.tx_storage = _name.tx_storage, \
83
}, \
84
.i2c = DEVICE_DT_GET(DT_PHANDLE(_node_id, i2c)), \
85
.i2c_target_cfg = { \
86
.address = DT_PROP(_node_id, i2c_addr), \
87
.callbacks = &mctp_i2c_gpio_target_callbacks, \
88
}, \
89
.endpoint_id = DT_PROP(_node_id, endpoint_id), \
90
.endpoint_gpio = GPIO_DT_SPEC_GET(_node_id, endpoint_gpios), \
91
.tx_lock = &_name##_tx_lock, \
92
.tx_complete = &_name##_tx_complete, \
93
};
94
95
#endif
/* ZEPHYR_MCTP_I2C_GPIO_TARGET_H_ */
device.h
gpio.h
Main header file for GPIO driver API.
i2c.h
Main header file for I2C (Inter-Integrated Circuit) driver API.
kernel.h
Public kernel APIs.
mctp_i2c_gpio_common.h
stdint.h
uint8_t
__UINT8_TYPE__ uint8_t
Definition
stdint.h:88
device
Runtime device structure (in ROM) per driver instance.
Definition
device.h:513
gpio_dt_spec
Container for GPIO pin information specified in devicetree.
Definition
gpio.h:296
i2c_target_callbacks
Structure providing callbacks to be implemented for devices that supports the I2C target API.
Definition
i2c.h:464
i2c_target_config
Structure describing a device that supports the I2C target API.
Definition
i2c.h:502
k_sem
Semaphore structure.
Definition
kernel.h:3723
mctp_binding_i2c_gpio_target
An MCTP binding for Zephyr's I2C target interface using GPIO.
Definition
mctp_i2c_gpio_target.h:22
zephyr
pmci
mctp
mctp_i2c_gpio_target.h
Generated on
for Zephyr API by
1.17.0