Zephyr API Documentation 4.5.99
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_val) {.pid = pid_val}
1009
1028
1030 const struct device *bus;
1031
1033 const struct device *dev;
1034
1037
1051
1062
1071
1086
1092
1100
1104 struct {
1107
1110
1114
1118 struct {
1121
1124
1128
1131
1133 struct {
1134 union {
1143
1153 };
1154
1163
1176
1183
1185 struct {
1194
1205
1210 void *controller_priv;
1212
1213#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
1219#endif /* CONFIG_I3C_USE_IBI */
1220};
1221
1237
1239 const struct device *bus;
1240
1243
1249
1254 void *controller_priv;
1256};
1257
1290
1303 struct i3c_device_desc * const i3c;
1304
1308 struct i3c_i2c_device_desc * const i2c;
1309
1314
1319};
1320
1327#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1330
1333
1336#elif defined(CONFIG_CPP)
1337 /* Empty struct has size 0 in C, size 1 in C++. Force them to be the same. */
1338 uint8_t unused_cpp_size_compatibility;
1339#endif
1340};
1341
1342#if defined(CONFIG_CPP)
1343BUILD_ASSERT(sizeof(struct i3c_driver_config) >= 1);
1344#endif
1345
1353#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1356#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1359
1362#endif /* CONFIG_I3C_TARGET */
1363#endif /* CONFIG_I3C_CONTROLLER */
1364};
1365
1366#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1376#define I3C_BUS_FOR_EACH_I3CDEV(bus, desc) \
1377 SYS_SLIST_FOR_EACH_CONTAINER( \
1378 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, node)
1379
1389#define I3C_BUS_FOR_EACH_I2CDEV(bus, desc) \
1390 SYS_SLIST_FOR_EACH_CONTAINER( \
1391 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, node)
1392
1403#define I3C_BUS_FOR_EACH_I3CDEV_SAFE(bus, desc, desc_s) \
1404 SYS_SLIST_FOR_EACH_CONTAINER_SAFE( \
1405 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, desc_s, \
1406 node)
1407
1418#define I3C_BUS_FOR_EACH_I2CDEV_SAFE(bus, desc, desc_s) \
1419 SYS_SLIST_FOR_EACH_CONTAINER_SAFE( \
1420 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, desc_s, \
1421 node)
1422
1437struct i3c_device_desc *i3c_dev_list_find(const struct i3c_dev_list *dev_list,
1438 const struct i3c_device_id *id);
1439
1455 uint8_t addr);
1456
1472 uint8_t addr);
1473
1489 uint16_t addr);
1490
1544 uint64_t pid, bool must_match,
1545 bool assigned_okay,
1546 struct i3c_device_desc **target,
1547 uint8_t *addr);
1548#endif /* CONFIG_I3C_CONTROLLER */
1549
1563static inline int i3c_configure(const struct device *dev,
1564 enum i3c_config_type type, void *config)
1565{
1566 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1567
1568 if (api->configure == NULL) {
1569 return -ENOSYS;
1570 }
1571
1572 return api->configure(dev, type, config);
1573}
1574
1575#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1593static inline int i3c_configure_controller(const struct device *dev,
1594 struct i3c_config_controller *config)
1595{
1596 return i3c_configure(dev, I3C_CONFIG_CONTROLLER, config);
1597}
1598#endif /* CONFIG_I3C_CONTROLLER */
1599
1600#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1618static inline int i3c_configure_target(const struct device *dev,
1619 struct i3c_config_target *config)
1620{
1621 return i3c_configure(dev, I3C_CONFIG_TARGET, config);
1622}
1623#endif /* CONFIG_I3C_TARGET */
1624
1645static inline int i3c_config_get(const struct device *dev,
1646 enum i3c_config_type type, void *config)
1647{
1648 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1649
1650 if (api->config_get == NULL) {
1651 return -ENOSYS;
1652 }
1653
1654 return api->config_get(dev, type, config);
1655}
1656
1657#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1675static inline int i3c_config_get_controller(const struct device *dev,
1676 struct i3c_config_controller *config)
1677{
1678 return i3c_config_get(dev, I3C_CONFIG_CONTROLLER, config);
1679}
1680#endif /* CONFIG_I3C_CONTROLLER */
1681
1682#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1700static inline int i3c_config_get_target(const struct device *dev,
1701 struct i3c_config_target *config)
1702{
1703 return i3c_config_get(dev, I3C_CONFIG_TARGET, config);
1704}
1705#endif /* CONFIG_I3C_TARGET */
1706
1707#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1720static inline int i3c_recover_bus(const struct device *dev)
1721{
1722 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1723
1724 if (api->recover_bus == NULL) {
1725 return -ENOSYS;
1726 }
1727
1728 return api->recover_bus(dev);
1729}
1730
1753
1780int i3c_reattach_i3c_device(struct i3c_device_desc *target, uint8_t old_dyn_addr);
1781
1804
1818static inline bool i3c_is_i3c_device_attached(struct i3c_device_desc *target)
1819{
1820 struct i3c_device_desc *desc;
1821
1822 I3C_BUS_FOR_EACH_I3CDEV(target->bus, desc) {
1823 if (desc == target) {
1824 return true;
1825 }
1826 }
1827 return false;
1828}
1829
1851
1872
1884static inline bool i3c_is_i2c_device_attached(struct i3c_i2c_device_desc *target)
1885{
1886 struct i3c_i2c_device_desc *desc;
1887
1888 I3C_BUS_FOR_EACH_I2CDEV(target->bus, desc) {
1889 if (desc == target) {
1890 return true;
1891 }
1892 }
1893 return false;
1894}
1895
1921static inline int i3c_do_daa(const struct device *dev)
1922{
1923 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1924
1925 if (api->do_daa == NULL) {
1926 return -ENOSYS;
1927 }
1928
1929 return api->do_daa(dev);
1930}
1931
1947__syscall int i3c_do_ccc(const struct device *dev,
1948 struct i3c_ccc_payload *payload);
1949
1950static inline int z_impl_i3c_do_ccc(const struct device *dev,
1951 struct i3c_ccc_payload *payload)
1952{
1953 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1954
1955 if (api->do_ccc == NULL) {
1956 return -ENOSYS;
1957 }
1958
1959 return api->do_ccc(dev, payload);
1960}
1961
1962#if defined(CONFIG_I3C_CALLBACK) || defined(__DOXYGEN__)
1985__syscall int i3c_do_ccc_cb(const struct device *dev,
1986 struct i3c_ccc_payload *payload,
1987 i3c_callback_t cb,
1988 void *userdata);
1989
1990static inline int z_impl_i3c_do_ccc_cb(const struct device *dev,
1991 struct i3c_ccc_payload *payload,
1992 i3c_callback_t cb,
1993 void *userdata)
1994{
1995 const struct i3c_driver_api *api =
1996 (const struct i3c_driver_api *)dev->api;
1997
1998 if (api->do_ccc_cb == NULL) {
1999 return -ENOSYS;
2000 }
2001
2002 return api->do_ccc_cb(dev, payload, cb, userdata);
2003}
2004#endif /* CONFIG_I3C_CALLBACK */
2005
2010
2041__syscall int i3c_transfer(struct i3c_device_desc *target,
2042 struct i3c_msg *msgs, uint8_t num_msgs);
2043
2044static inline int z_impl_i3c_transfer(struct i3c_device_desc *target,
2045 struct i3c_msg *msgs, uint8_t num_msgs)
2046{
2047 return DEVICE_API_GET(i3c, target->bus)->i3c_xfers(target->bus, target, msgs, num_msgs);
2048}
2049
2050#if defined(CONFIG_I3C_CALLBACK) || defined(__DOXYGEN__)
2081__syscall int i3c_transfer_cb(struct i3c_device_desc *target,
2082 struct i3c_msg *msgs,
2083 uint8_t num_msgs,
2084 i3c_callback_t cb,
2085 void *userdata);
2086
2087static inline int z_impl_i3c_transfer_cb(struct i3c_device_desc *target,
2088 struct i3c_msg *msgs,
2089 uint8_t num_msgs,
2090 i3c_callback_t cb,
2091 void *userdata)
2092{
2093 const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api;
2094
2095 if (api->i3c_xfers_cb == NULL) {
2096 return -ENOSYS;
2097 }
2098
2099 return api->i3c_xfers_cb(target->bus, target, msgs, num_msgs, cb, userdata);
2100}
2101#endif /* CONFIG_I3C_CALLBACK */
2102
2104
2121static inline
2123 const struct i3c_device_id *id)
2124{
2125 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2126
2127 if (api->i3c_device_find == NULL) {
2128 return NULL;
2129 }
2130
2131 return api->i3c_device_find(dev, id);
2132}
2133#endif /* CONFIG_I3C_CONTROLLER */
2134
2135#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
2140
2141#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2156static inline int i3c_ibi_hj_response(const struct device *dev,
2157 bool ack)
2158{
2159 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2160
2161 if (api->ibi_hj_response == NULL) {
2162 return -ENOSYS;
2163 }
2164
2165 return api->ibi_hj_response(dev, ack);
2166}
2167
2182static inline int i3c_ibi_crr_response(struct i3c_device_desc *target,
2183 bool ack)
2184{
2185 const struct i3c_driver_api *api =
2186 (const struct i3c_driver_api *)target->bus->api;
2187
2188 if (api->ibi_crr_response == NULL) {
2189 return -ENOSYS;
2190 }
2191
2192 return api->ibi_crr_response(target, ack);
2193}
2194#endif /* CONFIG_I3C_CONTROLLER */
2195
2196#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
2210static inline int i3c_ibi_raise(const struct device *dev,
2211 struct i3c_ibi *request)
2212{
2213 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2214
2215 if (api->ibi_raise == NULL) {
2216 return -ENOSYS;
2217 }
2218
2219 return api->ibi_raise(dev, request);
2220}
2221#endif /* CONFIG_I3C_TARGET */
2222
2223#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2240static inline int i3c_ibi_enable(struct i3c_device_desc *target)
2241{
2242 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, target->bus);
2243
2244 if (api->ibi_enable == NULL) {
2245 return -ENOSYS;
2246 }
2247
2248 return api->ibi_enable(target->bus, target);
2249}
2250
2265static inline int i3c_ibi_disable(struct i3c_device_desc *target)
2266{
2267 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, target->bus);
2268
2269 if (api->ibi_disable == NULL) {
2270 return -ENOSYS;
2271 }
2272
2273 return api->ibi_disable(target->bus, target);
2274}
2275#endif /* CONFIG_I3C_CONTROLLER */
2276#endif /* CONFIG_I3C_USE_IBI */
2277
2289static inline int i3c_ibi_has_payload(struct i3c_device_desc *target)
2290{
2291 return (target->bcr & I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE)
2293}
2294
2306static inline int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
2307{
2308 return (target->bcr & I3C_BCR_IBI_REQUEST_CAPABLE)
2310}
2311
2323static inline int i3c_device_is_controller_capable(struct i3c_device_desc *target)
2324{
2325 return I3C_BCR_DEVICE_ROLE(target->bcr)
2327}
2328
2330
2331#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2336
2352static inline int i3c_write(struct i3c_device_desc *target,
2353 const uint8_t *buf, uint32_t num_bytes)
2354{
2355 struct i3c_msg msg;
2356
2357 msg.buf = (uint8_t *)buf;
2358 msg.len = num_bytes;
2360 msg.hdr_mode = 0;
2361 msg.hdr_cmd_code = 0;
2362
2363 return i3c_transfer(target, &msg, 1);
2364}
2365
2381static inline int i3c_read(struct i3c_device_desc *target,
2382 uint8_t *buf, uint32_t num_bytes)
2383{
2384 struct i3c_msg msg;
2385
2386 msg.buf = buf;
2387 msg.len = num_bytes;
2389 msg.hdr_mode = 0;
2390 msg.hdr_cmd_code = 0;
2391
2392 return i3c_transfer(target, &msg, 1);
2393}
2394
2414static inline int i3c_write_read(struct i3c_device_desc *target,
2415 const void *write_buf, size_t num_write,
2416 void *read_buf, size_t num_read)
2417{
2418 struct i3c_msg msg[2];
2419
2420 msg[0].buf = (uint8_t *)write_buf;
2421 msg[0].len = num_write;
2422 msg[0].flags = I3C_MSG_WRITE;
2423 msg[0].hdr_mode = 0;
2424 msg[0].hdr_cmd_code = 0;
2425
2426 msg[1].buf = (uint8_t *)read_buf;
2427 msg[1].len = num_read;
2429 msg[1].hdr_mode = 0;
2430 msg[1].hdr_cmd_code = 0;
2431
2432 return i3c_transfer(target, msg, 2);
2433}
2434
2454static inline int i3c_burst_read(struct i3c_device_desc *target,
2455 uint8_t start_addr,
2456 uint8_t *buf,
2457 uint32_t num_bytes)
2458{
2459 return i3c_write_read(target,
2460 &start_addr, sizeof(start_addr),
2461 buf, num_bytes);
2462}
2463
2486static inline int i3c_burst_write(struct i3c_device_desc *target,
2487 uint8_t start_addr,
2488 const uint8_t *buf,
2489 uint32_t num_bytes)
2490{
2491 struct i3c_msg msg[2];
2492
2493 msg[0].buf = &start_addr;
2494 msg[0].len = 1U;
2495 msg[0].flags = I3C_MSG_WRITE;
2496 msg[0].hdr_mode = 0;
2497 msg[0].hdr_cmd_code = 0;
2498
2499 msg[1].buf = (uint8_t *)buf;
2500 msg[1].len = num_bytes;
2501 msg[1].flags = I3C_MSG_WRITE | I3C_MSG_STOP;
2502 msg[1].hdr_mode = 0;
2503 msg[1].hdr_cmd_code = 0;
2504
2505 return i3c_transfer(target, msg, 2);
2506}
2507
2524static inline int i3c_reg_read_byte(struct i3c_device_desc *target,
2525 uint8_t reg_addr, uint8_t *value)
2526{
2527 return i3c_write_read(target,
2528 &reg_addr, sizeof(reg_addr),
2529 value, sizeof(*value));
2530}
2531
2551static inline int i3c_reg_write_byte(struct i3c_device_desc *target,
2552 uint8_t reg_addr, uint8_t value)
2553{
2554 uint8_t tx_buf[2] = {reg_addr, value};
2555
2556 return i3c_write(target, tx_buf, 2);
2557}
2558
2579static inline int i3c_reg_update_byte(struct i3c_device_desc *target,
2580 uint8_t reg_addr, uint8_t mask,
2581 uint8_t value)
2582{
2583 uint8_t old_value, new_value;
2584 int rc;
2585
2586 rc = i3c_reg_read_byte(target, reg_addr, &old_value);
2587 if (rc != 0) {
2588 return rc;
2589 }
2590
2591 new_value = (old_value & ~mask) | (value & mask);
2592 if (new_value == old_value) {
2593 return 0;
2594 }
2595
2596 return i3c_reg_write_byte(target, reg_addr, new_value);
2597}
2598
2625void i3c_dump_msgs(const char *name, const struct i3c_msg *msgs,
2626 uint8_t num_msgs, struct i3c_device_desc *target);
2627
2629
2647int i3c_bus_init(const struct device *dev,
2648 const struct i3c_dev_list *i3c_dev_list);
2649
2670
2696
2720static inline int i3c_device_info_get(struct i3c_device_desc *target)
2721{
2722 int rc;
2723
2724 rc = i3c_device_basic_info_get(target);
2725 if (rc != 0) {
2726 return rc;
2727 }
2728
2729 return i3c_device_adv_info_get(target);
2730}
2731
2744enum i3c_bus_mode i3c_bus_mode(const struct i3c_dev_list *dev_list);
2745
2758bool i3c_bus_has_sec_controller(const struct device *dev);
2759
2772int i3c_bus_rstdaa_all(const struct device *dev);
2773
2788int i3c_bus_setdasa(struct i3c_device_desc *desc, uint8_t dynamic_addr);
2789
2804int i3c_bus_setnewda(struct i3c_device_desc *desc, uint8_t dynamic_addr);
2805
2818int i3c_bus_setaasa(const struct device *dev);
2819
2833
2847
2861
2875
2889
2904int i3c_bus_setmrl(struct i3c_device_desc *desc, uint16_t mrl, uint8_t ibi_len);
2905
2920
2936int i3c_bus_setmrl_all(const struct device *dev, uint16_t mrl, uint8_t ibi_len, bool has_ibi_size);
2937
2951int i3c_bus_setmwl_all(const struct device *dev, uint16_t mwl);
2952
2953#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
2967
2981int i3c_bus_deftgts(const struct device *dev);
2982#endif /* CONFIG_I3C_TARGET */
2983
2996
3013int i3c_device_controller_handoff(struct i3c_device_desc *target, bool requested);
3014#endif /* CONFIG_I3C_CONTROLLER */
3015
3016#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
3017#if (defined(CONFIG_I3C_CONTROLLER) && defined(CONFIG_I3C_TARGET)) || defined(__DOXYGEN__)
3031void i3c_sec_handoffed(struct k_work *work);
3032#endif /* CONFIG_I3C_CONTROLLER && CONFIG_I3C_TARGET */
3033#endif /* CONFIG_I3C_USE_IBI */
3034
3035#if (defined(CONFIG_I3C_NUM_OF_DESC_MEM_SLABS) && CONFIG_I3C_NUM_OF_DESC_MEM_SLABS > 0) || \
3036 defined(__DOXYGEN__)
3037
3049
3060
3073
3074#else
3075
3076static inline struct i3c_device_desc *i3c_device_desc_alloc(void)
3077{
3078 return NULL;
3079}
3080
3081static inline void i3c_device_desc_free(struct i3c_device_desc *desc)
3082{
3083 ARG_UNUSED(desc);
3084}
3085
3086static inline bool i3c_device_desc_in_pool(struct i3c_device_desc *desc)
3087{
3088 ARG_UNUSED(desc);
3089 return false;
3090}
3091
3092#endif /* CONFIG_I3C_NUM_OF_DESC_MEM_SLABS > 0 */
3093
3094#if (defined(CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS) && CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS > 0) || \
3095 defined(__DOXYGEN__)
3096
3108
3119
3132
3133#else
3134
3135static inline struct i3c_i2c_device_desc *i3c_i2c_device_desc_alloc(void)
3136{
3137 return NULL;
3138}
3139
3140static inline void i3c_i2c_device_desc_free(struct i3c_i2c_device_desc *desc)
3141{
3142 ARG_UNUSED(desc);
3143}
3144
3145static inline bool i3c_i2c_device_desc_in_pool(struct i3c_i2c_device_desc *desc)
3146{
3147 ARG_UNUSED(desc);
3148 return false;
3149}
3150
3151#endif /* CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS > 0 */
3152
3153#if defined(CONFIG_I3C_RTIO) || defined(__DOXYGEN__)
3154
3156 const struct device *bus;
3157 const struct i3c_device_id dev_id;
3158};
3159
3172void i3c_iodev_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe);
3173
3182static inline void i3c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
3183{
3184 const struct i3c_iodev_data *data =
3185 (const struct i3c_iodev_data *)iodev_sqe->sqe.iodev->data;
3186 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, data->bus);
3187
3188 if (api->iodev_submit == NULL) {
3189 rtio_iodev_sqe_err(iodev_sqe, -ENOSYS);
3190 return;
3191 }
3192 api->iodev_submit(data->bus, iodev_sqe);
3193}
3194
3195extern const struct rtio_iodev_api i3c_iodev_api;
3196
3208#define I3C_DT_IODEV_DEFINE(name, node_id) \
3209 const struct i3c_iodev_data _i3c_iodev_data_##name = { \
3210 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
3211 .dev_id = I3C_DEVICE_ID_DT(node_id), \
3212 }; \
3213 RTIO_IODEV_DEFINE(name, &i3c_iodev_api, (void *)&_i3c_iodev_data_##name)
3214
3226#define I3C_DT_INST_IODEV_DEFINE(name, inst) \
3227 I3C_DT_IODEV_DEFINE(name, DT_DRV_INST(inst))
3228
3242struct rtio_sqe *i3c_rtio_copy(struct rtio *r,
3243 struct rtio_iodev *iodev,
3244 const struct i3c_msg *msgs,
3245 uint8_t num_msgs);
3246
3247#endif /* CONFIG_I3C_RTIO */
3248
3249#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
3250/*
3251 * This needs to be after declaration of struct i3c_driver_api,
3252 * or else compiler complains about undefined type inside
3253 * the static inline API wrappers.
3254 */
3256#endif /* CONFIG_I3C_TARGET */
3257
3258#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
3259/*
3260 * Include High-Data-Rate (HDR) inline helper functions
3261 */
3263#endif /* CONFIG_I3C_CONTROLLER */
3264
3265#ifdef __cplusplus
3266}
3267#endif
3268
3272
3273#include <zephyr/syscalls/i3c.h>
3274
3275#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:1466
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1501
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:2265
static int i3c_ibi_has_payload(struct i3c_device_desc *target)
Check if target's IBI has payload.
Definition i3c.h:2289
static int i3c_ibi_crr_response(struct i3c_device_desc *target, bool ack)
ACK or NACK IBI Controller Role Requests.
Definition i3c.h:2182
static int i3c_ibi_raise(const struct device *dev, struct i3c_ibi *request)
Raise an In-Band Interrupt (IBI).
Definition i3c.h:2210
static int i3c_device_is_controller_capable(struct i3c_device_desc *target)
Check if the target is controller capable.
Definition i3c.h:2323
static int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
Check if device is IBI capable.
Definition i3c.h:2306
static int i3c_ibi_enable(struct i3c_device_desc *target)
Enable IBI of a target device.
Definition i3c.h:2240
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:2156
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:2122
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:1563
static int i3c_device_info_get(struct i3c_device_desc *target)
Get all information from device and update device descriptor.
Definition i3c.h:2720
static void i3c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
Submit request(s) to an I3C device with RTIO.
Definition i3c.h:3182
#define I3C_BUS_FOR_EACH_I3CDEV(bus, desc)
iterate over all I3C devices present on the bus
Definition i3c.h:1376
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:1389
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:1884
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:1720
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:1618
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:1645
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:1700
#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:1675
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:1921
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:1818
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:1593
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:2414
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:2454
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:2579
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:2524
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:2352
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:2381
#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:2486
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:2551
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:738
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:1266
sys_slist_t i3c
Linked list of attached I3C devices.
Definition i3c.h:1282
sys_slist_t i2c
Linked list of attached I2C devices.
Definition i3c.h:1287
struct i3c_addr_slots addr_slots
Address slots:
Definition i3c.h:1273
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:1299
struct i3c_i2c_device_desc *const i2c
Pointer to array of known I2C devices.
Definition i3c.h:1308
const uint8_t num_i3c
Number of I3C devices in array.
Definition i3c.h:1313
struct i3c_device_desc *const i3c
Pointer to array of known I3C devices.
Definition i3c.h:1303
const uint8_t num_i2c
Number of I2C devices in array.
Definition i3c.h:1318
Structure describing a I3C target device.
Definition i3c.h:1026
uint8_t maxwr
Maximum Write Speed.
Definition i3c.h:1109
const uint8_t init_dynamic_addr
Initial dynamic address.
Definition i3c.h:1061
uint8_t getcap1
I3C v1.1+ GETCAPS1 (I3C_CCC_GETCAPS1_*).
Definition i3c.h:1152
uint8_t static_addr
Static address for this target device.
Definition i3c.h:1050
uint8_t getcap2
GETCAPS2 (I3C_CCC_GETCAPS2_*).
Definition i3c.h:1162
uint8_t crcaps2
CRCAPS2.
Definition i3c.h:1203
uint32_t max_read_turnaround
Maximum Read turnaround time in microseconds.
Definition i3c.h:1112
uint8_t getcap4
GETCAPS4.
Definition i3c.h:1181
uint64_t pid
Device Provisioned ID.
Definition i3c.h:1036
uint8_t max_ibi
Maximum IBI Payload Size.
Definition i3c.h:1126
i3c_target_ibi_cb_t ibi_cb
In-Band Interrupt (IBI) callback.
Definition i3c.h:1218
uint16_t mwl
Maximum Write Length.
Definition i3c.h:1123
uint8_t crhdly1
Controller Handoff Delay Parameters.
Definition i3c.h:1130
uint8_t getcap3
GETCAPS3 (I3C_CCC_GETCAPS3_*).
Definition i3c.h:1175
uint8_t dynamic_addr
Dynamic Address for this target device used for communication.
Definition i3c.h:1085
uint8_t crcaps1
CRCAPS1.
Definition i3c.h:1193
const uint8_t flags
Device Flags.
Definition i3c.h:1070
sys_snode_t node
Definition i3c.h:1027
const struct device * bus
I3C bus to which this target device is attached.
Definition i3c.h:1030
struct i3c_device_desc::@354012327114236120073125301213366107212276207024 getcaps
Describes advanced (Target) capabilities and features.
uint16_t mrl
Maximum Read Length.
Definition i3c.h:1120
uint8_t maxrd
Maximum Read Speed.
Definition i3c.h:1106
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:1142
uint8_t bcr
Bus Characteristic Register (BCR).
Definition i3c.h:1091
uint8_t dcr
Device Characteristic Register (DCR).
Definition i3c.h:1099
const struct device * dev
Device driver instance of the I3C device.
Definition i3c.h:1033
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:1326
uint8_t primary_controller_da
I3C Primary Controller Dynamic Address.
Definition i3c.h:1332
uint8_t flags
Driver config flags.
Definition i3c.h:1335
struct i3c_dev_list dev_list
I3C/I2C device list struct.
Definition i3c.h:1329
This structure is common to all I3C drivers and is expected to be the first element in the driver's s...
Definition i3c.h:1350
struct i3c_config_controller ctrl_config
Controller Configuration.
Definition i3c.h:1352
struct i3c_ccc_deftgts * deftgts
Received DEFTGTS Pointer.
Definition i3c.h:1358
bool deftgts_refreshed
DEFTGTS refreshed.
Definition i3c.h:1361
struct i3c_dev_attached_list attached_dev
Attached I3C/I2C devices and addresses.
Definition i3c.h:1355
Structure describing a I2C device on I3C bus.
Definition i3c.h:1235
const struct device * bus
I3C bus to which this I2C device is attached.
Definition i3c.h:1239
uint8_t lvr
Legacy Virtual Register (LVR).
Definition i3c.h:1248
uint16_t addr
Static address for this I2C device.
Definition i3c.h:1242
sys_snode_t node
Definition i3c.h:1236
Struct for IBI request.
Definition ibi.h:58
Definition i3c.h:3155
const struct device * bus
Definition i3c.h:3156
const struct i3c_device_id dev_id
Definition i3c.h:3157
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:4663
API that an RTIO IO device should implement.
Definition iodev.h:38
IO device submission queue entry.
Definition sqe.h:468
struct rtio_sqe sqe
The submission queue entry this wraps.
Definition sqe.h:470
An IO device with a function table for submitting requests.
Definition iodev.h:83
void * data
Data associated with this iodev.
Definition iodev.h:88
A submission queue event.
Definition sqe.h:346
const struct rtio_iodev * iodev
Device to operation on.
Definition sqe.h:355
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:85
Misc utilities.