Zephyr API Documentation 4.5.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
i3c.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Intel Corporation
3 * Copyright 2023 Meta Platforms, Inc. and its affiliates
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
13
14#ifndef ZEPHYR_INCLUDE_DRIVERS_I3C_H_
15#define ZEPHYR_INCLUDE_DRIVERS_I3C_H_
16
25
26#include <errno.h>
27#include <stdint.h>
28#include <stddef.h>
29
30#include <zephyr/device.h>
36#include <zephyr/drivers/i2c.h>
37#include <zephyr/sys/slist.h>
38#include <zephyr/sys/util.h>
39#include <zephyr/rtio/rtio.h>
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
49#define I3C_OD_TLOW_MIN_NS 200
50#define I3C_OD_MIXED_BUS_THIGH_MAX_NS 41
51#define I3C_OD_FIRST_BC_THIGH_MIN_NS 200
52
93
100#define I3C_BCR_MAX_DATA_SPEED_LIMIT BIT(0)
101
103#define I3C_BCR_IBI_REQUEST_CAPABLE BIT(1)
104
112#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE BIT(2)
113
120#define I3C_BCR_OFFLINE_CAPABLE BIT(3)
121
128#define I3C_BCR_VIRTUAL_TARGET BIT(4)
129
137#define I3C_BCR_ADV_CAPABILITIES BIT(5)
138
140#define I3C_BCR_DEVICE_ROLE_I3C_TARGET 0U
141
143#define I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE 1U
144
146#define I3C_BCR_DEVICE_ROLE_MASK GENMASK(7U, 6U)
147
155#define I3C_BCR_DEVICE_ROLE(bcr) \
156 FIELD_GET(I3C_BCR_DEVICE_ROLE_MASK, (bcr))
157
159
179
181#define I3C_LVR_I2C_FM_PLUS_MODE 0
182
184#define I3C_LVR_I2C_FM_MODE 1
185
187#define I3C_LVR_I2C_MODE_MASK BIT(4)
188
196#define I3C_LVR_I2C_MODE(lvr) \
197 FIELD_GET(I3C_LVR_I2C_MODE_MASK, (lvr))
198
205#define I3C_LVR_I2C_DEV_IDX_0 0
206
213#define I3C_LVR_I2C_DEV_IDX_1 1
214
221#define I3C_LVR_I2C_DEV_IDX_2 2
222
224#define I3C_LVR_I2C_DEV_IDX_MASK GENMASK(7U, 5U)
225
233#define I3C_LVR_I2C_DEV_IDX(lvr) \
234 FIELD_GET(I3C_LVR_I2C_DEV_IDX_MASK, (lvr))
235
237
268
284
309
315
316/*
317 * I3C_MSG_* are I3C Message flags.
318 */
319
321#define I3C_MSG_WRITE (0U << 0U)
322
324#define I3C_MSG_READ BIT(0)
325
327#define I3C_MSG_RW_MASK BIT(0)
329
331#define I3C_MSG_STOP BIT(1)
332
342#define I3C_MSG_RESTART BIT(2)
343
345#define I3C_MSG_HDR BIT(3)
346
348#define I3C_MSG_NBCH BIT(4)
349
351#define I3C_MSG_NOACK_EXPECTED BIT(5)
352
354#define I3C_MSG_HDR_MODE0 BIT(0)
355
357#define I3C_MSG_HDR_MODE1 BIT(1)
358
360#define I3C_MSG_HDR_MODE2 BIT(2)
361
363#define I3C_MSG_HDR_MODE3 BIT(3)
364
366#define I3C_MSG_HDR_MODE4 BIT(4)
367
369#define I3C_MSG_HDR_MODE5 BIT(5)
370
372#define I3C_MSG_HDR_MODE6 BIT(6)
373
375#define I3C_MSG_HDR_MODE7 BIT(7)
376
378#define I3C_MSG_HDR_DDR I3C_MSG_HDR_MODE0
379
381#define I3C_MSG_HDR_TSP I3C_MSG_HDR_MODE1
382
384#define I3C_MSG_HDR_TSL I3C_MSG_HDR_MODE2
385
387#define I3C_MSG_HDR_BT I3C_MSG_HDR_MODE3
388
390
395
448
450
459
516
528
530 union {
533
540 void *ptr;
541 };
542};
543
551typedef void (*i3c_callback_t)(const struct device *dev, int result, void *data);
552
559struct i3c_device_desc;
560struct i3c_device_id;
562struct i3c_target_config;
563struct i3c_config_target;
564
565__subsystem struct i3c_driver_api {
575 struct i2c_driver_api i2c_api;
576
589 int (*configure)(const struct device *dev,
590 enum i3c_config_type type, void *config);
591
604 int (*config_get)(const struct device *dev,
605 enum i3c_config_type type, void *config);
606#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
619 int (*recover_bus)(const struct device *dev);
620
634 int (*attach_i3c_device)(const struct device *dev,
635 struct i3c_device_desc *target);
636
651 int (*reattach_i3c_device)(const struct device *dev,
652 struct i3c_device_desc *target,
653 uint8_t old_dyn_addr);
654
668 int (*detach_i3c_device)(const struct device *dev,
669 struct i3c_device_desc *target);
670
684 int (*attach_i2c_device)(const struct device *dev,
685 struct i3c_i2c_device_desc *target);
686
700 int (*detach_i2c_device)(const struct device *dev,
701 struct i3c_i2c_device_desc *target);
702
715 int (*do_daa)(const struct device *dev);
716
730 int (*do_ccc)(const struct device *dev,
731 struct i3c_ccc_payload *payload);
732
746 int (*i3c_xfers)(const struct device *dev,
747 struct i3c_device_desc *target,
748 struct i3c_msg *msgs,
749 uint8_t num_msgs);
750#if defined(CONFIG_I3C_CALLBACK) || defined(__DOXYGEN__)
766 int (*do_ccc_cb)(const struct device *dev,
767 struct i3c_ccc_payload *payload,
769 void *userdata);
770
786 int (*i3c_xfers_cb)(const struct device *dev,
787 struct i3c_device_desc *target,
788 struct i3c_msg *msgs,
789 uint8_t num_msgs,
791 void *userdata);
792#endif /* CONFIG_I3C_CALLBACK */
808 struct i3c_device_desc *(*i3c_device_find)(const struct device *dev,
809 const struct i3c_device_id *id);
810#endif /* CONFIG_I3C_CONTROLLER */
811#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
812#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
826 int (*ibi_raise)(const struct device *dev,
827 struct i3c_ibi *request);
828#endif /* CONFIG_I3C_TARGET */
829#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
841 int (*ibi_hj_response)(const struct device *dev,
842 bool ack);
843
855 int (*ibi_crr_response)(struct i3c_device_desc *target,
856 bool ack);
857
871 int (*ibi_enable)(const struct device *dev,
872 struct i3c_device_desc *target);
873
887 int (*ibi_disable)(const struct device *dev,
888 struct i3c_device_desc *target);
889#endif /* CONFIG_I3C_CONTROLLER */
890#endif /* CONFIG_I3C_USE_IBI */
891#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
908 int (*target_register)(const struct device *dev,
909 struct i3c_target_config *cfg);
910
927 int (*target_unregister)(const struct device *dev,
928 struct i3c_target_config *cfg);
929
947 int (*target_tx_write)(const struct device *dev,
948 uint8_t *buf, uint16_t len, uint8_t hdr_mode);
949
966 int (*target_controller_handoff)(const struct device *dev,
967 bool accept);
968#endif /* CONFIG_I3C_TARGET */
969#if defined(CONFIG_I3C_RTIO) || defined(__DOXYGEN__)
981 void (*iodev_submit)(const struct device *dev,
982 struct rtio_iodev_sqe *iodev_sqe);
983#endif /* CONFIG_I3C_RTIO */
984};
985
986DEVICE_API_EXTENDS(i3c, i2c, i2c_api);
987
991
998};
999
1008#define I3C_DEVICE_ID(pid) \
1009 { \
1010 .pid = pid \
1011 }
1012
1031
1033 const struct device *bus;
1034
1036 const struct device *dev;
1037
1040
1054
1065
1074
1089
1095
1103
1107 struct {
1110
1113
1117
1121 struct {
1124
1127
1131
1134
1136 struct {
1137 union {
1146
1156 };
1157
1166
1179
1186
1188 struct {
1197
1208
1213 void *controller_priv;
1215
1216#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
1222#endif /* CONFIG_I3C_USE_IBI */
1223};
1224
1240
1242 const struct device *bus;
1243
1246
1252
1257 void *controller_priv;
1259};
1260
1293
1306 struct i3c_device_desc * const i3c;
1307
1311 struct i3c_i2c_device_desc * const i2c;
1312
1317
1322};
1323
1330#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1333
1336
1339#elif defined(CONFIG_CPP)
1340 /* Empty struct has size 0 in C, size 1 in C++. Force them to be the same. */
1341 uint8_t unused_cpp_size_compatibility;
1342#endif
1343};
1344
1345#if defined(CONFIG_CPP)
1346BUILD_ASSERT(sizeof(struct i3c_driver_config) >= 1);
1347#endif
1348
1356#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1359#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1362
1365#endif /* CONFIG_I3C_TARGET */
1366#endif /* CONFIG_I3C_CONTROLLER */
1367};
1368
1369#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1379#define I3C_BUS_FOR_EACH_I3CDEV(bus, desc) \
1380 SYS_SLIST_FOR_EACH_CONTAINER( \
1381 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, node)
1382
1392#define I3C_BUS_FOR_EACH_I2CDEV(bus, desc) \
1393 SYS_SLIST_FOR_EACH_CONTAINER( \
1394 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, node)
1395
1406#define I3C_BUS_FOR_EACH_I3CDEV_SAFE(bus, desc, desc_s) \
1407 SYS_SLIST_FOR_EACH_CONTAINER_SAFE( \
1408 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, desc_s, \
1409 node)
1410
1421#define I3C_BUS_FOR_EACH_I2CDEV_SAFE(bus, desc, desc_s) \
1422 SYS_SLIST_FOR_EACH_CONTAINER_SAFE( \
1423 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, desc_s, \
1424 node)
1425
1440struct i3c_device_desc *i3c_dev_list_find(const struct i3c_dev_list *dev_list,
1441 const struct i3c_device_id *id);
1442
1458 uint8_t addr);
1459
1475 uint8_t addr);
1476
1492 uint16_t addr);
1493
1547 uint64_t pid, bool must_match,
1548 bool assigned_okay,
1549 struct i3c_device_desc **target,
1550 uint8_t *addr);
1551#endif /* CONFIG_I3C_CONTROLLER */
1552
1566static inline int i3c_configure(const struct device *dev,
1567 enum i3c_config_type type, void *config)
1568{
1569 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1570
1571 if (api->configure == NULL) {
1572 return -ENOSYS;
1573 }
1574
1575 return api->configure(dev, type, config);
1576}
1577
1578#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1596static inline int i3c_configure_controller(const struct device *dev,
1597 struct i3c_config_controller *config)
1598{
1599 return i3c_configure(dev, I3C_CONFIG_CONTROLLER, config);
1600}
1601#endif /* CONFIG_I3C_CONTROLLER */
1602
1603#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1621static inline int i3c_configure_target(const struct device *dev,
1622 struct i3c_config_target *config)
1623{
1624 return i3c_configure(dev, I3C_CONFIG_TARGET, config);
1625}
1626#endif /* CONFIG_I3C_TARGET */
1627
1648static inline int i3c_config_get(const struct device *dev,
1649 enum i3c_config_type type, void *config)
1650{
1651 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1652
1653 if (api->config_get == NULL) {
1654 return -ENOSYS;
1655 }
1656
1657 return api->config_get(dev, type, config);
1658}
1659
1660#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1678static inline int i3c_config_get_controller(const struct device *dev,
1679 struct i3c_config_controller *config)
1680{
1681 return i3c_config_get(dev, I3C_CONFIG_CONTROLLER, config);
1682}
1683#endif /* CONFIG_I3C_CONTROLLER */
1684
1685#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1703static inline int i3c_config_get_target(const struct device *dev,
1704 struct i3c_config_target *config)
1705{
1706 return i3c_config_get(dev, I3C_CONFIG_TARGET, config);
1707}
1708#endif /* CONFIG_I3C_TARGET */
1709
1710#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1723static inline int i3c_recover_bus(const struct device *dev)
1724{
1725 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1726
1727 if (api->recover_bus == NULL) {
1728 return -ENOSYS;
1729 }
1730
1731 return api->recover_bus(dev);
1732}
1733
1756
1783int i3c_reattach_i3c_device(struct i3c_device_desc *target, uint8_t old_dyn_addr);
1784
1807
1821static inline bool i3c_is_i3c_device_attached(struct i3c_device_desc *target)
1822{
1823 struct i3c_device_desc *desc;
1824
1825 I3C_BUS_FOR_EACH_I3CDEV(target->bus, desc) {
1826 if (desc == target) {
1827 return true;
1828 }
1829 }
1830 return false;
1831}
1832
1854
1875
1887static inline bool i3c_is_i2c_device_attached(struct i3c_i2c_device_desc *target)
1888{
1889 struct i3c_i2c_device_desc *desc;
1890
1891 I3C_BUS_FOR_EACH_I2CDEV(target->bus, desc) {
1892 if (desc == target) {
1893 return true;
1894 }
1895 }
1896 return false;
1897}
1898
1924static inline int i3c_do_daa(const struct device *dev)
1925{
1926 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1927
1928 if (api->do_daa == NULL) {
1929 return -ENOSYS;
1930 }
1931
1932 return api->do_daa(dev);
1933}
1934
1950__syscall int i3c_do_ccc(const struct device *dev,
1951 struct i3c_ccc_payload *payload);
1952
1953static inline int z_impl_i3c_do_ccc(const struct device *dev,
1954 struct i3c_ccc_payload *payload)
1955{
1956 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1957
1958 if (api->do_ccc == NULL) {
1959 return -ENOSYS;
1960 }
1961
1962 return api->do_ccc(dev, payload);
1963}
1964
1965#if defined(CONFIG_I3C_CALLBACK) || defined(__DOXYGEN__)
1988__syscall int i3c_do_ccc_cb(const struct device *dev,
1989 struct i3c_ccc_payload *payload,
1990 i3c_callback_t cb,
1991 void *userdata);
1992
1993static inline int z_impl_i3c_do_ccc_cb(const struct device *dev,
1994 struct i3c_ccc_payload *payload,
1995 i3c_callback_t cb,
1996 void *userdata)
1997{
1998 const struct i3c_driver_api *api =
1999 (const struct i3c_driver_api *)dev->api;
2000
2001 if (api->do_ccc_cb == NULL) {
2002 return -ENOSYS;
2003 }
2004
2005 return api->do_ccc_cb(dev, payload, cb, userdata);
2006}
2007#endif /* CONFIG_I3C_CALLBACK */
2008
2013
2044__syscall int i3c_transfer(struct i3c_device_desc *target,
2045 struct i3c_msg *msgs, uint8_t num_msgs);
2046
2047static inline int z_impl_i3c_transfer(struct i3c_device_desc *target,
2048 struct i3c_msg *msgs, uint8_t num_msgs)
2049{
2050 return DEVICE_API_GET(i3c, target->bus)->i3c_xfers(target->bus, target, msgs, num_msgs);
2051}
2052
2053#if defined(CONFIG_I3C_CALLBACK) || defined(__DOXYGEN__)
2084__syscall int i3c_transfer_cb(struct i3c_device_desc *target,
2085 struct i3c_msg *msgs,
2086 uint8_t num_msgs,
2087 i3c_callback_t cb,
2088 void *userdata);
2089
2090static inline int z_impl_i3c_transfer_cb(struct i3c_device_desc *target,
2091 struct i3c_msg *msgs,
2092 uint8_t num_msgs,
2093 i3c_callback_t cb,
2094 void *userdata)
2095{
2096 const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api;
2097
2098 if (api->i3c_xfers_cb == NULL) {
2099 return -ENOSYS;
2100 }
2101
2102 return api->i3c_xfers_cb(target->bus, target, msgs, num_msgs, cb, userdata);
2103}
2104#endif /* CONFIG_I3C_CALLBACK */
2105
2107
2124static inline
2126 const struct i3c_device_id *id)
2127{
2128 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2129
2130 if (api->i3c_device_find == NULL) {
2131 return NULL;
2132 }
2133
2134 return api->i3c_device_find(dev, id);
2135}
2136#endif /* CONFIG_I3C_CONTROLLER */
2137
2138#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
2143
2144#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2159static inline int i3c_ibi_hj_response(const struct device *dev,
2160 bool ack)
2161{
2162 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2163
2164 if (api->ibi_hj_response == NULL) {
2165 return -ENOSYS;
2166 }
2167
2168 return api->ibi_hj_response(dev, ack);
2169}
2170
2185static inline int i3c_ibi_crr_response(struct i3c_device_desc *target,
2186 bool ack)
2187{
2188 const struct i3c_driver_api *api =
2189 (const struct i3c_driver_api *)target->bus->api;
2190
2191 if (api->ibi_crr_response == NULL) {
2192 return -ENOSYS;
2193 }
2194
2195 return api->ibi_crr_response(target, ack);
2196}
2197#endif /* CONFIG_I3C_CONTROLLER */
2198
2199#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
2213static inline int i3c_ibi_raise(const struct device *dev,
2214 struct i3c_ibi *request)
2215{
2216 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2217
2218 if (api->ibi_raise == NULL) {
2219 return -ENOSYS;
2220 }
2221
2222 return api->ibi_raise(dev, request);
2223}
2224#endif /* CONFIG_I3C_TARGET */
2225
2226#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2243static inline int i3c_ibi_enable(struct i3c_device_desc *target)
2244{
2245 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, target->bus);
2246
2247 if (api->ibi_enable == NULL) {
2248 return -ENOSYS;
2249 }
2250
2251 return api->ibi_enable(target->bus, target);
2252}
2253
2268static inline int i3c_ibi_disable(struct i3c_device_desc *target)
2269{
2270 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, target->bus);
2271
2272 if (api->ibi_disable == NULL) {
2273 return -ENOSYS;
2274 }
2275
2276 return api->ibi_disable(target->bus, target);
2277}
2278#endif /* CONFIG_I3C_CONTROLLER */
2279#endif /* CONFIG_I3C_USE_IBI */
2280
2292static inline int i3c_ibi_has_payload(struct i3c_device_desc *target)
2293{
2294 return (target->bcr & I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE)
2296}
2297
2309static inline int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
2310{
2311 return (target->bcr & I3C_BCR_IBI_REQUEST_CAPABLE)
2313}
2314
2326static inline int i3c_device_is_controller_capable(struct i3c_device_desc *target)
2327{
2328 return I3C_BCR_DEVICE_ROLE(target->bcr)
2330}
2331
2333
2334#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2339
2355static inline int i3c_write(struct i3c_device_desc *target,
2356 const uint8_t *buf, uint32_t num_bytes)
2357{
2358 struct i3c_msg msg;
2359
2360 msg.buf = (uint8_t *)buf;
2361 msg.len = num_bytes;
2363 msg.hdr_mode = 0;
2364 msg.hdr_cmd_code = 0;
2365
2366 return i3c_transfer(target, &msg, 1);
2367}
2368
2384static inline int i3c_read(struct i3c_device_desc *target,
2385 uint8_t *buf, uint32_t num_bytes)
2386{
2387 struct i3c_msg msg;
2388
2389 msg.buf = buf;
2390 msg.len = num_bytes;
2392 msg.hdr_mode = 0;
2393 msg.hdr_cmd_code = 0;
2394
2395 return i3c_transfer(target, &msg, 1);
2396}
2397
2417static inline int i3c_write_read(struct i3c_device_desc *target,
2418 const void *write_buf, size_t num_write,
2419 void *read_buf, size_t num_read)
2420{
2421 struct i3c_msg msg[2];
2422
2423 msg[0].buf = (uint8_t *)write_buf;
2424 msg[0].len = num_write;
2425 msg[0].flags = I3C_MSG_WRITE;
2426 msg[0].hdr_mode = 0;
2427 msg[0].hdr_cmd_code = 0;
2428
2429 msg[1].buf = (uint8_t *)read_buf;
2430 msg[1].len = num_read;
2432 msg[1].hdr_mode = 0;
2433 msg[1].hdr_cmd_code = 0;
2434
2435 return i3c_transfer(target, msg, 2);
2436}
2437
2457static inline int i3c_burst_read(struct i3c_device_desc *target,
2458 uint8_t start_addr,
2459 uint8_t *buf,
2460 uint32_t num_bytes)
2461{
2462 return i3c_write_read(target,
2463 &start_addr, sizeof(start_addr),
2464 buf, num_bytes);
2465}
2466
2489static inline int i3c_burst_write(struct i3c_device_desc *target,
2490 uint8_t start_addr,
2491 const uint8_t *buf,
2492 uint32_t num_bytes)
2493{
2494 struct i3c_msg msg[2];
2495
2496 msg[0].buf = &start_addr;
2497 msg[0].len = 1U;
2498 msg[0].flags = I3C_MSG_WRITE;
2499 msg[0].hdr_mode = 0;
2500 msg[0].hdr_cmd_code = 0;
2501
2502 msg[1].buf = (uint8_t *)buf;
2503 msg[1].len = num_bytes;
2504 msg[1].flags = I3C_MSG_WRITE | I3C_MSG_STOP;
2505 msg[1].hdr_mode = 0;
2506 msg[1].hdr_cmd_code = 0;
2507
2508 return i3c_transfer(target, msg, 2);
2509}
2510
2527static inline int i3c_reg_read_byte(struct i3c_device_desc *target,
2528 uint8_t reg_addr, uint8_t *value)
2529{
2530 return i3c_write_read(target,
2531 &reg_addr, sizeof(reg_addr),
2532 value, sizeof(*value));
2533}
2534
2554static inline int i3c_reg_write_byte(struct i3c_device_desc *target,
2555 uint8_t reg_addr, uint8_t value)
2556{
2557 uint8_t tx_buf[2] = {reg_addr, value};
2558
2559 return i3c_write(target, tx_buf, 2);
2560}
2561
2582static inline int i3c_reg_update_byte(struct i3c_device_desc *target,
2583 uint8_t reg_addr, uint8_t mask,
2584 uint8_t value)
2585{
2586 uint8_t old_value, new_value;
2587 int rc;
2588
2589 rc = i3c_reg_read_byte(target, reg_addr, &old_value);
2590 if (rc != 0) {
2591 return rc;
2592 }
2593
2594 new_value = (old_value & ~mask) | (value & mask);
2595 if (new_value == old_value) {
2596 return 0;
2597 }
2598
2599 return i3c_reg_write_byte(target, reg_addr, new_value);
2600}
2601
2628void i3c_dump_msgs(const char *name, const struct i3c_msg *msgs,
2629 uint8_t num_msgs, struct i3c_device_desc *target);
2630
2632
2650int i3c_bus_init(const struct device *dev,
2651 const struct i3c_dev_list *i3c_dev_list);
2652
2673
2699
2723static inline int i3c_device_info_get(struct i3c_device_desc *target)
2724{
2725 int rc;
2726
2727 rc = i3c_device_basic_info_get(target);
2728 if (rc != 0) {
2729 return rc;
2730 }
2731
2732 return i3c_device_adv_info_get(target);
2733}
2734
2747enum i3c_bus_mode i3c_bus_mode(const struct i3c_dev_list *dev_list);
2748
2761bool i3c_bus_has_sec_controller(const struct device *dev);
2762
2775int i3c_bus_rstdaa_all(const struct device *dev);
2776
2791int i3c_bus_setdasa(struct i3c_device_desc *desc, uint8_t dynamic_addr);
2792
2807int i3c_bus_setnewda(struct i3c_device_desc *desc, uint8_t dynamic_addr);
2808
2821int i3c_bus_setaasa(const struct device *dev);
2822
2836
2850
2864
2878
2892
2907int i3c_bus_setmrl(struct i3c_device_desc *desc, uint16_t mrl, uint8_t ibi_len);
2908
2923
2939int i3c_bus_setmrl_all(const struct device *dev, uint16_t mrl, uint8_t ibi_len, bool has_ibi_size);
2940
2954int i3c_bus_setmwl_all(const struct device *dev, uint16_t mwl);
2955
2956#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
2970
2984int i3c_bus_deftgts(const struct device *dev);
2985#endif /* CONFIG_I3C_TARGET */
2986
2999
3016int i3c_device_controller_handoff(struct i3c_device_desc *target, bool requested);
3017#endif /* CONFIG_I3C_CONTROLLER */
3018
3019#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
3020#if (defined(CONFIG_I3C_CONTROLLER) && defined(CONFIG_I3C_TARGET)) || defined(__DOXYGEN__)
3034void i3c_sec_handoffed(struct k_work *work);
3035#endif /* CONFIG_I3C_CONTROLLER && CONFIG_I3C_TARGET */
3036#endif /* CONFIG_I3C_USE_IBI */
3037
3038#if (defined(CONFIG_I3C_NUM_OF_DESC_MEM_SLABS) && CONFIG_I3C_NUM_OF_DESC_MEM_SLABS > 0) || \
3039 defined(__DOXYGEN__)
3040
3052
3063
3076
3077#else
3078
3079static inline struct i3c_device_desc *i3c_device_desc_alloc(void)
3080{
3081 return NULL;
3082}
3083
3084static inline void i3c_device_desc_free(struct i3c_device_desc *desc)
3085{
3086 ARG_UNUSED(desc);
3087}
3088
3089static inline bool i3c_device_desc_in_pool(struct i3c_device_desc *desc)
3090{
3091 ARG_UNUSED(desc);
3092 return false;
3093}
3094
3095#endif /* CONFIG_I3C_NUM_OF_DESC_MEM_SLABS > 0 */
3096
3097#if (defined(CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS) && CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS > 0) || \
3098 defined(__DOXYGEN__)
3099
3111
3122
3135
3136#else
3137
3138static inline struct i3c_i2c_device_desc *i3c_i2c_device_desc_alloc(void)
3139{
3140 return NULL;
3141}
3142
3143static inline void i3c_i2c_device_desc_free(struct i3c_i2c_device_desc *desc)
3144{
3145 ARG_UNUSED(desc);
3146}
3147
3148static inline bool i3c_i2c_device_desc_in_pool(struct i3c_i2c_device_desc *desc)
3149{
3150 ARG_UNUSED(desc);
3151 return false;
3152}
3153
3154#endif /* CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS > 0 */
3155
3156#if defined(CONFIG_I3C_RTIO) || defined(__DOXYGEN__)
3157
3159 const struct device *bus;
3160 const struct i3c_device_id dev_id;
3161};
3162
3175void i3c_iodev_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe);
3176
3185static inline void i3c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
3186{
3187 const struct i3c_iodev_data *data =
3188 (const struct i3c_iodev_data *)iodev_sqe->sqe.iodev->data;
3189 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, data->bus);
3190
3191 if (api->iodev_submit == NULL) {
3192 rtio_iodev_sqe_err(iodev_sqe, -ENOSYS);
3193 return;
3194 }
3195 api->iodev_submit(data->bus, iodev_sqe);
3196}
3197
3198extern const struct rtio_iodev_api i3c_iodev_api;
3199
3211#define I3C_DT_IODEV_DEFINE(name, node_id) \
3212 const struct i3c_iodev_data _i3c_iodev_data_##name = { \
3213 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
3214 .dev_id = I3C_DEVICE_ID_DT(node_id), \
3215 }; \
3216 RTIO_IODEV_DEFINE(name, &i3c_iodev_api, (void *)&_i3c_iodev_data_##name)
3217
3229#define I3C_DT_INST_IODEV_DEFINE(name, inst) \
3230 I3C_DT_IODEV_DEFINE(name, DT_DRV_INST(inst))
3231
3245struct rtio_sqe *i3c_rtio_copy(struct rtio *r,
3246 struct rtio_iodev *iodev,
3247 const struct i3c_msg *msgs,
3248 uint8_t num_msgs);
3249
3250#endif /* CONFIG_I3C_RTIO */
3251
3252#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
3253/*
3254 * This needs to be after declaration of struct i3c_driver_api,
3255 * or else compiler complains about undefined type inside
3256 * the static inline API wrappers.
3257 */
3259#endif /* CONFIG_I3C_TARGET */
3260
3261#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
3262/*
3263 * Include High-Data-Rate (HDR) inline helper functions
3264 */
3266#endif /* CONFIG_I3C_CONTROLLER */
3267
3268#ifdef __cplusplus
3269}
3270#endif
3271
3275
3276#include <zephyr/syscalls/i3c.h>
3277
3278#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_H_ */
APIs and macros for the Zephyr device model.
#define DEVICE_API_EXTENDS(_child, _parent, _member)
Declare that API class _child is an extension of device API class _parent.
Definition device.h:1451
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1486
Main header file for I2C (Inter-Integrated Circuit) driver API.
System error numbers.
i3c_sdr_controller_error_types
I3C SDR Controller Error Types.
Definition error_types.h:24
static int i3c_ibi_disable(struct i3c_device_desc *target)
Disable IBI of a target device.
Definition i3c.h:2268
static int i3c_ibi_has_payload(struct i3c_device_desc *target)
Check if target's IBI has payload.
Definition i3c.h:2292
static int i3c_ibi_crr_response(struct i3c_device_desc *target, bool ack)
ACK or NACK IBI Controller Role Requests.
Definition i3c.h:2185
static int i3c_ibi_raise(const struct device *dev, struct i3c_ibi *request)
Raise an In-Band Interrupt (IBI).
Definition i3c.h:2213
static int i3c_device_is_controller_capable(struct i3c_device_desc *target)
Check if the target is controller capable.
Definition i3c.h:2326
static int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
Check if device is IBI capable.
Definition i3c.h:2309
static int i3c_ibi_enable(struct i3c_device_desc *target)
Enable IBI of a target device.
Definition i3c.h:2243
int(* i3c_target_ibi_cb_t)(struct i3c_device_desc *target, struct i3c_ibi_payload *payload)
Function called when In-Band Interrupt received from target device.
Definition ibi.h:146
static int i3c_ibi_hj_response(const struct device *dev, bool ack)
ACK or NACK IBI HJ Requests.
Definition i3c.h:2159
int i3c_attach_i3c_device(struct i3c_device_desc *target)
Attach an I3C device.
#define I3C_BCR_IBI_REQUEST_CAPABLE
IBI Request Capable bit.
Definition i3c.h:103
#define I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE
Device Role - I3C Controller Capable.
Definition i3c.h:143
struct i3c_device_desc * i3c_dev_list_i3c_addr_find(const struct device *dev, uint8_t addr)
Find a I3C target device descriptor by dynamic address.
static struct i3c_device_desc * i3c_device_find(const struct device *dev, const struct i3c_device_id *id)
Find a registered I3C target device.
Definition i3c.h:2125
int i3c_bus_getpid(struct i3c_device_desc *desc)
Retrieve the Provisional ID (PID) of a device.
bool i3c_bus_has_sec_controller(const struct device *dev)
Check if the bus has a secondary controller.
int i3c_bus_rstdaa_all(const struct device *dev)
Reset all devices on the bus and clear their dynamic addresses.
struct i3c_i2c_device_desc * i3c_i2c_device_desc_alloc(void)
Allocate memory for a i3c i2c device descriptor.
void i3c_sec_handoffed(struct k_work *work)
Call back for when Controllership is Handoffed to itself.
void i3c_device_desc_free(struct i3c_device_desc *desc)
Free memory from a i3c device descriptor.
int i3c_bus_setmrl_all(const struct device *dev, uint16_t mrl, uint8_t ibi_len, bool has_ibi_size)
Set the Maximum Read Length (MRL) for all devices on the bus.
int i3c_bus_setdasa(struct i3c_device_desc *desc, uint8_t dynamic_addr)
Assign a dynamic address to a device using its static address.
static int i3c_configure(const struct device *dev, enum i3c_config_type type, void *config)
Configure the I3C hardware.
Definition i3c.h:1566
static int i3c_device_info_get(struct i3c_device_desc *target)
Get all information from device and update device descriptor.
Definition i3c.h:2723
static void i3c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
Submit request(s) to an I3C device with RTIO.
Definition i3c.h:3185
#define I3C_BUS_FOR_EACH_I3CDEV(bus, desc)
iterate over all I3C devices present on the bus
Definition i3c.h:1379
int i3c_dev_list_daa_addr_helper(const struct device *dev, uint64_t pid, bool must_match, bool assigned_okay, struct i3c_device_desc **target, uint8_t *addr)
Helper function to find a usable address during ENTDAA.
#define I3C_BUS_FOR_EACH_I2CDEV(bus, desc)
iterate over all I2C devices present on the bus
Definition i3c.h:1392
static bool i3c_is_i2c_device_attached(struct i3c_i2c_device_desc *target)
Check if an I2C device is attached to the bus.
Definition i3c.h:1887
int i3c_device_adv_info_get(struct i3c_device_desc *target)
Get advanced information from device and update device descriptor.
int i3c_bus_getmrl(struct i3c_device_desc *desc)
Retrieve the Maximum Read Length (MRL) of a device.
int i3c_bus_deftgts(const struct device *dev)
Send the CCC DEFTGTS.
int i3c_bus_setnewda(struct i3c_device_desc *desc, uint8_t dynamic_addr)
Assign a new dynamic address to a device.
i3c_config_type
Type of configuration being passed to configure function.
Definition i3c.h:454
int i3c_attach_i2c_device(struct i3c_i2c_device_desc *target)
Attach an I2C device.
void i3c_i2c_device_desc_free(struct i3c_i2c_device_desc *desc)
Free memory from a i3c i2c device descriptor.
i3c_i2c_speed_type
I2C bus speed under I3C bus.
Definition i3c.h:274
int i3c_detach_i3c_device(struct i3c_device_desc *target)
Detach I3C Device.
int i3c_bus_setmrl(struct i3c_device_desc *desc, uint16_t mrl, uint8_t ibi_len)
Set the Maximum Read Length (MRL) for a device.
int i3c_do_ccc_cb(const struct device *dev, struct i3c_ccc_payload *payload, i3c_callback_t cb, void *userdata)
Send an async CCC to the bus with a callback.
i3c_bus_mode
I3C bus mode.
Definition i3c.h:241
static int i3c_recover_bus(const struct device *dev)
Attempt bus recovery on the I3C bus.
Definition i3c.h:1723
static int i3c_configure_target(const struct device *dev, struct i3c_config_target *config)
Set the target device configuration for an I3C device.
Definition i3c.h:1621
int i3c_bus_setmwl(struct i3c_device_desc *desc, uint16_t mwl)
Set the Maximum Write Length (MWL) for a device.
static int i3c_config_get(const struct device *dev, enum i3c_config_type type, void *config)
Get configuration of the I3C hardware.
Definition i3c.h:1648
int i3c_bus_getacccr(struct i3c_device_desc *desc)
Retrieve the Active Controller's Dynamic Address (ACCCR).
int i3c_bus_getmwl(struct i3c_device_desc *desc)
Retrieve the Maximum Write Length (MWL) of a device.
int i3c_detach_i2c_device(struct i3c_i2c_device_desc *target)
Detach I2C Device.
static int i3c_config_get_target(const struct device *dev, struct i3c_config_target *config)
Get the target device configuration for an I3C device.
Definition i3c.h:1703
#define I3C_BCR_DEVICE_ROLE(bcr)
Device Role.
Definition i3c.h:155
void i3c_iodev_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
Fallback submit implementation.
static int i3c_config_get_controller(const struct device *dev, struct i3c_config_controller *config)
Get the controller device configuration for an I3C device.
Definition i3c.h:1678
struct i3c_device_desc * i3c_dev_list_find(const struct i3c_dev_list *dev_list, const struct i3c_device_id *id)
Find a I3C target device descriptor by ID.
int i3c_bus_init(const struct device *dev, const struct i3c_dev_list *i3c_dev_list)
Generic helper function to perform bus initialization.
int i3c_do_ccc(const struct device *dev, struct i3c_ccc_payload *payload)
Send CCC to the bus.
int i3c_bus_getdcr(struct i3c_device_desc *desc)
Retrieve the Device Characteristics Register (DCR) of a device.
int i3c_device_basic_info_get(struct i3c_device_desc *target)
Get basic information from device and update device descriptor.
uint8_t i3c_odd_parity(uint8_t p)
Calculate odd parity.
struct rtio_sqe * i3c_rtio_copy(struct rtio *r, struct rtio_iodev *iodev, const struct i3c_msg *msgs, uint8_t num_msgs)
Copy the i3c_msgs into a set of RTIO requests.
int i3c_bus_setaasa(const struct device *dev)
Assign static addresses as dynamic addresses for all devices on the bus.
struct i3c_device_desc * i3c_device_desc_alloc(void)
Allocate memory for a i3c device descriptor.
static int i3c_do_daa(const struct device *dev)
Perform Dynamic Address Assignment on the I3C bus.
Definition i3c.h:1924
bool i3c_i2c_device_desc_in_pool(struct i3c_i2c_device_desc *desc)
Report if the i3c i2c device descriptor was from a mem slab.
static bool i3c_is_i3c_device_attached(struct i3c_device_desc *target)
Check if an I3C device is attached to the bus.
Definition i3c.h:1821
void(* i3c_callback_t)(const struct device *dev, int result, void *data)
I3C callback for asynchronous transfer requests.
Definition i3c.h:551
int i3c_bus_getbcr(struct i3c_device_desc *desc)
Retrieve the Bus Characteristics Register (BCR) of a device.
const struct rtio_iodev_api i3c_iodev_api
int i3c_bus_setmwl_all(const struct device *dev, uint16_t mwl)
Set the Maximum Write Length (MWL) for all devices on the bus.
#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE
IBI Payload bit.
Definition i3c.h:112
int i3c_reattach_i3c_device(struct i3c_device_desc *target, uint8_t old_dyn_addr)
Reattach I3C device.
i3c_data_rate
I3C data rate.
Definition i3c.h:290
static int i3c_configure_controller(const struct device *dev, struct i3c_config_controller *config)
Set the controller device configuration for an I3C device.
Definition i3c.h:1596
struct i3c_device_desc * i3c_dev_list_i3c_static_addr_find(const struct device *dev, uint8_t addr)
Find a I3C target device descriptor by static address.
int i3c_device_controller_handoff(struct i3c_device_desc *target, bool requested)
Perform Controller Handoff.
bool i3c_device_desc_in_pool(struct i3c_device_desc *desc)
Report if the i3c device descriptor was from a mem slab.
struct i3c_i2c_device_desc * i3c_dev_list_i2c_addr_find(const struct device *dev, uint16_t addr)
Find a I2C target device descriptor by address.
@ I3C_CONFIG_TARGET
Definition i3c.h:456
@ I3C_CONFIG_CUSTOM
Definition i3c.h:457
@ I3C_CONFIG_CONTROLLER
Definition i3c.h:455
@ I3C_I2C_SPEED_INVALID
Definition i3c.h:282
@ I3C_I2C_SPEED_MAX
Definition i3c.h:281
@ I3C_I2C_SPEED_FMPLUS
I2C FM+ mode.
Definition i3c.h:279
@ I3C_I2C_SPEED_FM
I2C FM mode.
Definition i3c.h:276
@ I3C_BUS_MODE_INVALID
Definition i3c.h:266
@ I3C_BUS_MODE_PURE
Only I3C devices are on the bus.
Definition i3c.h:243
@ I3C_BUS_MODE_MIXED_FAST
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:249
@ I3C_BUS_MODE_MAX
Definition i3c.h:265
@ I3C_BUS_MODE_MIXED_LIMITED
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:256
@ I3C_BUS_MODE_MIXED_SLOW
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:263
@ I3C_DATA_RATE_MAX
Definition i3c.h:306
@ I3C_DATA_RATE_INVALID
Definition i3c.h:307
@ I3C_DATA_RATE_HDR_TSP
High Data Rate - Ternary Symbol for Pure Bus.
Definition i3c.h:301
@ I3C_DATA_RATE_HDR_DDR
High Data Rate - Double Data Rate messaging.
Definition i3c.h:295
@ I3C_DATA_RATE_SDR
Single Data Rate messaging.
Definition i3c.h:292
@ I3C_DATA_RATE_HDR_TSL
High Data Rate - Ternary Symbol Legacy-inclusive-Bus.
Definition i3c.h:298
@ I3C_DATA_RATE_HDR_BT
High Data Rate - Bulk Transport.
Definition i3c.h:304
int i3c_transfer(struct i3c_device_desc *target, struct i3c_msg *msgs, uint8_t num_msgs)
Perform data transfer from the controller to a I3C target device.
#define I3C_MSG_STOP
Send STOP after this message.
Definition i3c.h:331
int i3c_transfer_cb(struct i3c_device_desc *target, struct i3c_msg *msgs, uint8_t num_msgs, i3c_callback_t cb, void *userdata)
Perform an async data transfer from the controller to a I3C target device with a callback.
static int i3c_write_read(struct i3c_device_desc *target, const void *write_buf, size_t num_write, void *read_buf, size_t num_read)
Write then read data from an I3C target device.
Definition i3c.h:2417
static int i3c_burst_read(struct i3c_device_desc *target, uint8_t start_addr, uint8_t *buf, uint32_t num_bytes)
Read multiple bytes from an internal address of an I3C target device.
Definition i3c.h:2457
static int i3c_reg_update_byte(struct i3c_device_desc *target, uint8_t reg_addr, uint8_t mask, uint8_t value)
Update internal register of an I3C target device.
Definition i3c.h:2582
void i3c_dump_msgs(const char *name, const struct i3c_msg *msgs, uint8_t num_msgs, struct i3c_device_desc *target)
Dump out an I3C message.
#define I3C_MSG_READ
Read message from I3C bus.
Definition i3c.h:324
#define I3C_MSG_WRITE
Write message to I3C bus.
Definition i3c.h:321
static int i3c_reg_read_byte(struct i3c_device_desc *target, uint8_t reg_addr, uint8_t *value)
Read internal register of an I3C target device.
Definition i3c.h:2527
static int i3c_write(struct i3c_device_desc *target, const uint8_t *buf, uint32_t num_bytes)
Write a set amount of data to an I3C target device.
Definition i3c.h:2355
static int i3c_read(struct i3c_device_desc *target, uint8_t *buf, uint32_t num_bytes)
Read a set amount of data from an I3C target device.
Definition i3c.h:2384
#define I3C_MSG_RESTART
RESTART I3C transaction for this message.
Definition i3c.h:342
static int i3c_burst_write(struct i3c_device_desc *target, uint8_t start_addr, const uint8_t *buf, uint32_t num_bytes)
Write multiple bytes to an internal address of an I3C target device.
Definition i3c.h:2489
static int i3c_reg_write_byte(struct i3c_device_desc *target, uint8_t reg_addr, uint8_t value)
Write internal register of an I3C target device.
Definition i3c.h:2554
static void rtio_iodev_sqe_err(struct rtio_iodev_sqe *iodev_sqe, int result)
Inform the executor of a submissions completion with error.
Definition rtio.h:735
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:54
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
#define ENOSYS
Function not implemented.
Definition errno.h:83
int accept(int sock, struct sockaddr *addr, socklen_t *addrlen)
Real-Time IO device API for moving bytes with low effort.
Header file for the single-linked list API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:543
void * data
Address of the device instance private data.
Definition device.h:553
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:549
<span class="mlabel">Driver Operations</span> I2C driver operations
Definition i2c.h:339
Structure to keep track of addresses on I3C bus.
Definition addresses.h:58
Payload for DEFTGTS CCC (Define List of Targets).
Definition ccc.h:477
Payload structure for one CCC transaction.
Definition ccc.h:283
Configuration parameters for I3C hardware to act as controller.
Definition i3c.h:463
struct i3c_config_controller::@171175234007106124341357122051356217163277103172 scl_od_min
struct i3c_config_controller::@014075316065214041357310317133027267244366227361 scl_pp_min
Requested minimum SCL Push-Pull clock periods.
uint32_t i3c
SCL frequency (in Hz) for I3C transfers.
Definition i3c.h:472
uint8_t supported_hdr
Bit mask of supported HDR modes (0 - 7).
Definition i3c.h:514
bool is_secondary
True if the controller is to be the secondary controller of the bus.
Definition i3c.h:468
uint32_t i2c
SCL frequency (in Hz) for I2C transfers.
Definition i3c.h:475
uint32_t low_ns
Requested minimum SCL Open-Drain LOW period in nanoseconds.
Definition i3c.h:491
struct i3c_config_controller::@056135366137020063162136324011126070110331100007 scl
uint32_t high_ns
Requested minimum SCL Open Drain High period in Nanoseconds.
Definition i3c.h:486
Custom I3C configuration parameters.
Definition i3c.h:525
void * ptr
Pointer to configuration parameter.
Definition i3c.h:540
uint32_t id
ID of the configuration parameter.
Definition i3c.h:527
uintptr_t val
Value of configuration parameter.
Definition i3c.h:532
Configuration parameters for I3C hardware to act as target device.
Definition target_device.h:36
Structure for describing attached devices for a controller.
Definition i3c.h:1269
sys_slist_t i3c
Linked list of attached I3C devices.
Definition i3c.h:1285
sys_slist_t i2c
Linked list of attached I2C devices.
Definition i3c.h:1290
struct i3c_addr_slots addr_slots
Address slots:
Definition i3c.h:1276
struct i3c_dev_attached_list::@043171057314352332015067106373053220000327262053 devices
Linked lists of attached I3C and I2C devices.
Structure for describing known devices for a controller.
Definition i3c.h:1302
struct i3c_i2c_device_desc *const i2c
Pointer to array of known I2C devices.
Definition i3c.h:1311
const uint8_t num_i3c
Number of I3C devices in array.
Definition i3c.h:1316
struct i3c_device_desc *const i3c
Pointer to array of known I3C devices.
Definition i3c.h:1306
const uint8_t num_i2c
Number of I2C devices in array.
Definition i3c.h:1321
Structure describing a I3C target device.
Definition i3c.h:1029
uint8_t maxwr
Maximum Write Speed.
Definition i3c.h:1112
const uint8_t init_dynamic_addr
Initial dynamic address.
Definition i3c.h:1064
uint8_t getcap1
I3C v1.1+ GETCAPS1 (I3C_CCC_GETCAPS1_*).
Definition i3c.h:1155
uint8_t static_addr
Static address for this target device.
Definition i3c.h:1053
uint8_t getcap2
GETCAPS2 (I3C_CCC_GETCAPS2_*).
Definition i3c.h:1165
uint8_t crcaps2
CRCAPS2.
Definition i3c.h:1206
uint32_t max_read_turnaround
Maximum Read turnaround time in microseconds.
Definition i3c.h:1115
uint8_t getcap4
GETCAPS4.
Definition i3c.h:1184
uint64_t pid
Device Provisioned ID.
Definition i3c.h:1039
uint8_t max_ibi
Maximum IBI Payload Size.
Definition i3c.h:1129
i3c_target_ibi_cb_t ibi_cb
In-Band Interrupt (IBI) callback.
Definition i3c.h:1221
uint16_t mwl
Maximum Write Length.
Definition i3c.h:1126
uint8_t crhdly1
Controller Handoff Delay Parameters.
Definition i3c.h:1133
uint8_t getcap3
GETCAPS3 (I3C_CCC_GETCAPS3_*).
Definition i3c.h:1178
uint8_t dynamic_addr
Dynamic Address for this target device used for communication.
Definition i3c.h:1088
uint8_t crcaps1
CRCAPS1.
Definition i3c.h:1196
const uint8_t flags
Device Flags.
Definition i3c.h:1073
sys_snode_t node
Definition i3c.h:1030
const struct device * bus
I3C bus to which this target device is attached.
Definition i3c.h:1033
struct i3c_device_desc::@354012327114236120073125301213366107212276207024 getcaps
Describes advanced (Target) capabilities and features.
uint16_t mrl
Maximum Read Length.
Definition i3c.h:1123
uint8_t maxrd
Maximum Read Speed.
Definition i3c.h:1109
struct i3c_device_desc::@025161371003043020356247061065002050371177151366 data_speed
Maximum data speed (GETMXDS CCC).
uint8_t gethdrcap
I3C v1.0 HDR Capabilities (I3C_CCC_GETCAPS1_*).
Definition i3c.h:1145
uint8_t bcr
Bus Characteristic Register (BCR).
Definition i3c.h:1094
uint8_t dcr
Device Characteristic Register (DCR).
Definition i3c.h:1102
const struct device * dev
Device driver instance of the I3C device.
Definition i3c.h:1036
struct i3c_device_desc::@233130030357247267201022070232022115366221343347 crcaps
Describes Controller Feature Capabilities.
struct i3c_device_desc::@171122044300150030070232076155234262120067102161 data_length
Maximum data lengths (GETMXDS CCC).
Structure used for matching I3C devices.
Definition i3c.h:995
uint64_t pid
Device Provisioned ID.
Definition i3c.h:997
This structure is common to all I3C drivers and is expected to be the first element in the object poi...
Definition i3c.h:1329
uint8_t primary_controller_da
I3C Primary Controller Dynamic Address.
Definition i3c.h:1335
uint8_t flags
Driver config flags.
Definition i3c.h:1338
struct i3c_dev_list dev_list
I3C/I2C device list struct.
Definition i3c.h:1332
This structure is common to all I3C drivers and is expected to be the first element in the driver's s...
Definition i3c.h:1353
struct i3c_config_controller ctrl_config
Controller Configuration.
Definition i3c.h:1355
struct i3c_ccc_deftgts * deftgts
Received DEFTGTS Pointer.
Definition i3c.h:1361
bool deftgts_refreshed
DEFTGTS refreshed.
Definition i3c.h:1364
struct i3c_dev_attached_list attached_dev
Attached I3C/I2C devices and addresses.
Definition i3c.h:1358
Structure describing a I2C device on I3C bus.
Definition i3c.h:1238
const struct device * bus
I3C bus to which this I2C device is attached.
Definition i3c.h:1242
uint8_t lvr
Legacy Virtual Register (LVR).
Definition i3c.h:1251
uint16_t addr
Static address for this I2C device.
Definition i3c.h:1245
sys_snode_t node
Definition i3c.h:1239
Struct for IBI request.
Definition ibi.h:58
Definition i3c.h:3158
const struct device * bus
Definition i3c.h:3159
const struct i3c_device_id dev_id
Definition i3c.h:3160
One I3C Message.
Definition i3c.h:410
uint8_t flags
Flags for this message.
Definition i3c.h:435
uint8_t hdr_mode
HDR mode (I3C_MSG_HDR_MODE*) for transfer if any I3C_MSG_HDR_* is set in flags.
Definition i3c.h:443
uint32_t num_xfer
Total number of bytes transferred.
Definition i3c.h:424
uint8_t * buf
Data buffer in bytes.
Definition i3c.h:412
uint8_t hdr_cmd_code
HDR command code field (7-bit) for HDR-DDR, HDR-TSP and HDR-TSL.
Definition i3c.h:446
uint32_t len
Length of buffer in bytes.
Definition i3c.h:415
enum i3c_sdr_controller_error_types err
SDR Error Type.
Definition i3c.h:432
Structure describing a device that supports the I3C target API.
Definition target_device.h:101
A structure used to submit work.
Definition kernel.h:4649
API that an RTIO IO device should implement.
Definition iodev.h:34
IO device submission queue entry.
Definition sqe.h:403
struct rtio_sqe sqe
Submission this entry carries.
Definition sqe.h:404
An IO device with a function table for submitting requests.
Definition iodev.h:49
void * data
Data associated with this iodev.
Definition iodev.h:54
A submission queue event.
Definition sqe.h:310
const struct rtio_iodev * iodev
Device to operation on.
Definition sqe.h:319
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:83
Misc utilities.