Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mctp_i3c_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_I3C_TARGET_H_
15#define ZEPHYR_INCLUDE_PMCI_MCTP_MCTP_I3C_TARGET_H_
16
17#include <stdint.h>
18#include <zephyr/kernel.h>
19#include <zephyr/device.h>
20#include <zephyr/drivers/i3c.h>
23#include <libmctp.h>
24
30 struct mctp_binding binding;
31 const struct device *i3c;
32 struct i3c_target_config i3c_target_cfg;
33 uint8_t endpoint_id;
34 uint8_t dynamic_addr;
35 struct mctp_pktbuf *tx_pkt;
36 struct k_sem *tx_lock;
37 struct k_sem *tx_complete;
38 struct mctp_pktbuf *rx_pkt;
39 /*
40 * Deferred receive: stop_cb runs in ISR context, but PEC verification (HW
41 * CRC) and mctp_bus_rx() may block. Received packets are queued and handled
42 * from thread context. The queue holds a full message's fragments.
43 */
44 struct k_work rx_work;
45 struct k_msgq rx_msgq;
46 struct mctp_pktbuf *rx_msgq_slots[CONFIG_MCTP_I3C_RX_QUEUE_DEPTH];
47 uint8_t tx_storage[MCTP_PKTBUF_SIZE(MCTP_I3C_MAX_PKT_SIZE +
48 I3C_PROTOCOL_PEC_SZ)] PKTBUF_STORAGE_ALIGN;
49 /* Counts up to MCTP_PACKET_SIZE(MCTP_I3C_MAX_PKT_SIZE) + PEC (> 255) */
50 uint16_t tx_ptr;
52};
53
55extern const struct i3c_target_callbacks mctp_i3c_target_callbacks;
56int mctp_i3c_target_start(struct mctp_binding *binding);
57int mctp_i3c_target_tx(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
59
66#define MCTP_I3C_TARGET_DT_DEFINE(_name, _node_id) \
67 K_SEM_DEFINE(_name##_tx_lock, 1, 1); \
68 K_SEM_DEFINE(_name##_tx_complete, 0, 1); \
69 struct mctp_binding_i3c_target _name = { \
70 .binding = { \
71 .name = STRINGIFY(_name), .version = 1, \
72 .start = mctp_i3c_target_start, \
73 .tx = mctp_i3c_target_tx, \
74 .pkt_size = MCTP_I3C_MAX_PKT_SIZE, \
75 .pkt_trailer = I3C_PROTOCOL_PEC_SZ, \
76 .tx_storage = _name.tx_storage, \
77 }, \
78 .i3c = DEVICE_DT_GET(DT_PHANDLE(_node_id, i3c)), \
79 .i3c_target_cfg = { \
80 .callbacks = &mctp_i3c_target_callbacks, \
81 }, \
82 .endpoint_id = DT_PROP(_node_id, endpoint_id), \
83 .tx_lock = &_name##_tx_lock, \
84 .tx_complete = &_name##_tx_complete, \
85 };
86
87#endif /* ZEPHYR_INCLUDE_PMCI_MCTP_MCTP_I3C_TARGET_H_ */
APIs and macros for the Zephyr device model.
Main header file for I3C (Inter-Integrated Circuit) driver API.
Public kernel APIs.
Internal definitions shared by the MCTP I3C controller and target bindings.
MCTP-over-I3C Packet Error Code (PEC) helpers.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:543
Definition target_device.h:106
Structure describing a device that supports the I3C target API.
Definition target_device.h:101
Message Queue Structure.
Definition kernel.h:5521
Semaphore structure.
Definition kernel.h:4002
A structure used to submit work.
Definition kernel.h:4913
An MCTP binding for Zephyr's I3C target interface using GPIO.
Definition mctp_i3c_target.h:28