Zephyr API Documentation 4.4.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_HDR_MODE0 BIT(0)
352
354#define I3C_MSG_HDR_MODE1 BIT(1)
355
357#define I3C_MSG_HDR_MODE2 BIT(2)
358
360#define I3C_MSG_HDR_MODE3 BIT(3)
361
363#define I3C_MSG_HDR_MODE4 BIT(4)
364
366#define I3C_MSG_HDR_MODE5 BIT(5)
367
369#define I3C_MSG_HDR_MODE6 BIT(6)
370
372#define I3C_MSG_HDR_MODE7 BIT(7)
373
375#define I3C_MSG_HDR_DDR I3C_MSG_HDR_MODE0
376
378#define I3C_MSG_HDR_TSP I3C_MSG_HDR_MODE1
379
381#define I3C_MSG_HDR_TSL I3C_MSG_HDR_MODE2
382
384#define I3C_MSG_HDR_BT I3C_MSG_HDR_MODE3
385
387
392
445
447
456
499
511
512 union {
515
522 void *ptr;
523 };
524};
525
533typedef void (*i3c_callback_t)(const struct device *dev, int result, void *data);
534
541struct i3c_device_desc;
542struct i3c_device_id;
544struct i3c_target_config;
545struct i3c_config_target;
546
547__subsystem struct i3c_driver_api {
557 struct i2c_driver_api i2c_api;
558
571 int (*configure)(const struct device *dev,
572 enum i3c_config_type type, void *config);
573
586 int (*config_get)(const struct device *dev,
587 enum i3c_config_type type, void *config);
588#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
601 int (*recover_bus)(const struct device *dev);
602
616 int (*attach_i3c_device)(const struct device *dev,
617 struct i3c_device_desc *target);
618
633 int (*reattach_i3c_device)(const struct device *dev,
634 struct i3c_device_desc *target,
635 uint8_t old_dyn_addr);
636
650 int (*detach_i3c_device)(const struct device *dev,
651 struct i3c_device_desc *target);
652
666 int (*attach_i2c_device)(const struct device *dev,
667 struct i3c_i2c_device_desc *target);
668
682 int (*detach_i2c_device)(const struct device *dev,
683 struct i3c_i2c_device_desc *target);
684
697 int (*do_daa)(const struct device *dev);
698
712 int (*do_ccc)(const struct device *dev,
713 struct i3c_ccc_payload *payload);
714
728 int (*i3c_xfers)(const struct device *dev,
729 struct i3c_device_desc *target,
730 struct i3c_msg *msgs,
731 uint8_t num_msgs);
732#if defined(CONFIG_I3C_CALLBACK) || defined(__DOXYGEN__)
748 int (*do_ccc_cb)(const struct device *dev,
749 struct i3c_ccc_payload *payload,
751 void *userdata);
752
768 int (*i3c_xfers_cb)(const struct device *dev,
769 struct i3c_device_desc *target,
770 struct i3c_msg *msgs,
771 uint8_t num_msgs,
773 void *userdata);
774#endif /* CONFIG_I3C_CALLBACK */
790 struct i3c_device_desc *(*i3c_device_find)(const struct device *dev,
791 const struct i3c_device_id *id);
792#endif /* CONFIG_I3C_CONTROLLER */
793#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
794#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
808 int (*ibi_raise)(const struct device *dev,
809 struct i3c_ibi *request);
810#endif /* CONFIG_I3C_TARGET */
811#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
823 int (*ibi_hj_response)(const struct device *dev,
824 bool ack);
825
837 int (*ibi_crr_response)(struct i3c_device_desc *target,
838 bool ack);
839
853 int (*ibi_enable)(const struct device *dev,
854 struct i3c_device_desc *target);
855
869 int (*ibi_disable)(const struct device *dev,
870 struct i3c_device_desc *target);
871#endif /* CONFIG_I3C_CONTROLLER */
872#endif /* CONFIG_I3C_USE_IBI */
873#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
890 int (*target_register)(const struct device *dev,
891 struct i3c_target_config *cfg);
892
909 int (*target_unregister)(const struct device *dev,
910 struct i3c_target_config *cfg);
911
929 int (*target_tx_write)(const struct device *dev,
930 uint8_t *buf, uint16_t len, uint8_t hdr_mode);
931
948 int (*target_controller_handoff)(const struct device *dev,
949 bool accept);
950#endif /* CONFIG_I3C_TARGET */
951#if defined(CONFIG_I3C_RTIO) || defined(__DOXYGEN__)
963 void (*iodev_submit)(const struct device *dev,
964 struct rtio_iodev_sqe *iodev_sqe);
965#endif /* CONFIG_I3C_RTIO */
966};
967
968DEVICE_API_EXTENDS(i3c, i2c, i2c_api);
969
973
980};
981
990#define I3C_DEVICE_ID(pid) \
991 { \
992 .pid = pid \
993 }
994
1013
1015 const struct device *bus;
1016
1018 const struct device *dev;
1019
1022
1036
1047
1056
1071
1077
1085
1086 struct {
1089
1092
1096
1097 struct {
1100
1103
1107
1110
1112 struct {
1113 union {
1122
1132 };
1133
1142
1155
1162
1163 /* Describes Controller Feature Capabilities */
1164 struct {
1173
1184
1189 void *controller_priv;
1191
1192#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
1198#endif /* CONFIG_I3C_USE_IBI */
1199};
1200
1216
1218 const struct device *bus;
1219
1222
1228
1233 void *controller_priv;
1235};
1236
1266
1279 struct i3c_device_desc * const i3c;
1280
1284 struct i3c_i2c_device_desc * const i2c;
1285
1290
1295};
1296
1303#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1306
1309
1312#elif defined(CONFIG_CPP)
1313 /* Empty struct has size 0 in C, size 1 in C++. Force them to be the same. */
1314 uint8_t unused_cpp_size_compatibility;
1315#endif
1316};
1317
1318#if defined(CONFIG_CPP)
1319BUILD_ASSERT(sizeof(struct i3c_driver_config) >= 1);
1320#endif
1321
1329#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1332#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1335
1338#endif /* CONFIG_I3C_TARGET */
1339#endif /* CONFIG_I3C_CONTROLLER */
1340};
1341
1342#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1352#define I3C_BUS_FOR_EACH_I3CDEV(bus, desc) \
1353 SYS_SLIST_FOR_EACH_CONTAINER( \
1354 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, node)
1355
1365#define I3C_BUS_FOR_EACH_I2CDEV(bus, desc) \
1366 SYS_SLIST_FOR_EACH_CONTAINER( \
1367 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, node)
1368
1379#define I3C_BUS_FOR_EACH_I3CDEV_SAFE(bus, desc, desc_s) \
1380 SYS_SLIST_FOR_EACH_CONTAINER_SAFE( \
1381 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, desc_s, \
1382 node)
1383
1394#define I3C_BUS_FOR_EACH_I2CDEV_SAFE(bus, desc, desc_s) \
1395 SYS_SLIST_FOR_EACH_CONTAINER_SAFE( \
1396 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, desc_s, \
1397 node)
1398
1413struct i3c_device_desc *i3c_dev_list_find(const struct i3c_dev_list *dev_list,
1414 const struct i3c_device_id *id);
1415
1431 uint8_t addr);
1432
1448 uint8_t addr);
1449
1465 uint16_t addr);
1466
1520 uint64_t pid, bool must_match,
1521 bool assigned_okay,
1522 struct i3c_device_desc **target,
1523 uint8_t *addr);
1524#endif /* CONFIG_I3C_CONTROLLER */
1525
1539static inline int i3c_configure(const struct device *dev,
1540 enum i3c_config_type type, void *config)
1541{
1542 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1543
1544 if (api->configure == NULL) {
1545 return -ENOSYS;
1546 }
1547
1548 return api->configure(dev, type, config);
1549}
1550
1551#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1569static inline int i3c_configure_controller(const struct device *dev,
1570 struct i3c_config_controller *config)
1571{
1572 return i3c_configure(dev, I3C_CONFIG_CONTROLLER, config);
1573}
1574#endif /* CONFIG_I3C_CONTROLLER */
1575
1576#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1594static inline int i3c_configure_target(const struct device *dev,
1595 struct i3c_config_target *config)
1596{
1597 return i3c_configure(dev, I3C_CONFIG_TARGET, config);
1598}
1599#endif /* CONFIG_I3C_TARGET */
1600
1621static inline int i3c_config_get(const struct device *dev,
1622 enum i3c_config_type type, void *config)
1623{
1624 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1625
1626 if (api->config_get == NULL) {
1627 return -ENOSYS;
1628 }
1629
1630 return api->config_get(dev, type, config);
1631}
1632
1633#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1651static inline int i3c_config_get_controller(const struct device *dev,
1652 struct i3c_config_controller *config)
1653{
1654 return i3c_config_get(dev, I3C_CONFIG_CONTROLLER, config);
1655}
1656#endif /* CONFIG_I3C_CONTROLLER */
1657
1658#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
1676static inline int i3c_config_get_target(const struct device *dev,
1677 struct i3c_config_target *config)
1678{
1679 return i3c_config_get(dev, I3C_CONFIG_TARGET, config);
1680}
1681#endif /* CONFIG_I3C_TARGET */
1682
1683#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
1696static inline int i3c_recover_bus(const struct device *dev)
1697{
1698 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1699
1700 if (api->recover_bus == NULL) {
1701 return -ENOSYS;
1702 }
1703
1704 return api->recover_bus(dev);
1705}
1706
1729
1756int i3c_reattach_i3c_device(struct i3c_device_desc *target, uint8_t old_dyn_addr);
1757
1780
1794static inline bool i3c_is_i3c_device_attached(struct i3c_device_desc *target)
1795{
1796 struct i3c_device_desc *desc;
1797
1798 I3C_BUS_FOR_EACH_I3CDEV(target->bus, desc) {
1799 if (desc == target) {
1800 return true;
1801 }
1802 }
1803 return false;
1804}
1805
1827
1848
1860static inline bool i3c_is_i2c_device_attached(struct i3c_i2c_device_desc *target)
1861{
1862 struct i3c_i2c_device_desc *desc;
1863
1864 I3C_BUS_FOR_EACH_I2CDEV(target->bus, desc) {
1865 if (desc == target) {
1866 return true;
1867 }
1868 }
1869 return false;
1870}
1871
1897static inline int i3c_do_daa(const struct device *dev)
1898{
1899 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1900
1901 if (api->do_daa == NULL) {
1902 return -ENOSYS;
1903 }
1904
1905 return api->do_daa(dev);
1906}
1907
1923__syscall int i3c_do_ccc(const struct device *dev,
1924 struct i3c_ccc_payload *payload);
1925
1926static inline int z_impl_i3c_do_ccc(const struct device *dev,
1927 struct i3c_ccc_payload *payload)
1928{
1929 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
1930
1931 if (api->do_ccc == NULL) {
1932 return -ENOSYS;
1933 }
1934
1935 return api->do_ccc(dev, payload);
1936}
1937
1938#if defined(CONFIG_I3C_CALLBACK) || defined(__DOXYGEN__)
1961__syscall int i3c_do_ccc_cb(const struct device *dev,
1962 struct i3c_ccc_payload *payload,
1963 i3c_callback_t cb,
1964 void *userdata);
1965
1966static inline int z_impl_i3c_do_ccc_cb(const struct device *dev,
1967 struct i3c_ccc_payload *payload,
1968 i3c_callback_t cb,
1969 void *userdata)
1970{
1971 const struct i3c_driver_api *api =
1972 (const struct i3c_driver_api *)dev->api;
1973
1974 if (api->do_ccc_cb == NULL) {
1975 return -ENOSYS;
1976 }
1977
1978 return api->do_ccc_cb(dev, payload, cb, userdata);
1979}
1980#endif /* CONFIG_I3C_CALLBACK */
1981
1986
2015__syscall int i3c_transfer(struct i3c_device_desc *target,
2016 struct i3c_msg *msgs, uint8_t num_msgs);
2017
2018static inline int z_impl_i3c_transfer(struct i3c_device_desc *target,
2019 struct i3c_msg *msgs, uint8_t num_msgs)
2020{
2021 return DEVICE_API_GET(i3c, target->bus)->i3c_xfers(target->bus, target, msgs, num_msgs);
2022}
2023
2024#if defined(CONFIG_I3C_CALLBACK) || defined(__DOXYGEN__)
2055__syscall int i3c_transfer_cb(struct i3c_device_desc *target,
2056 struct i3c_msg *msgs,
2057 uint8_t num_msgs,
2058 i3c_callback_t cb,
2059 void *userdata);
2060
2061static inline int z_impl_i3c_transfer_cb(struct i3c_device_desc *target,
2062 struct i3c_msg *msgs,
2063 uint8_t num_msgs,
2064 i3c_callback_t cb,
2065 void *userdata)
2066{
2067 const struct i3c_driver_api *api = (const struct i3c_driver_api *)target->bus->api;
2068
2069 if (api->i3c_xfers_cb == NULL) {
2070 return -ENOSYS;
2071 }
2072
2073 return api->i3c_xfers_cb(target->bus, target, msgs, num_msgs, cb, userdata);
2074}
2075#endif /* CONFIG_I3C_CALLBACK */
2076
2078
2095static inline
2097 const struct i3c_device_id *id)
2098{
2099 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2100
2101 if (api->i3c_device_find == NULL) {
2102 return NULL;
2103 }
2104
2105 return api->i3c_device_find(dev, id);
2106}
2107#endif /* CONFIG_I3C_CONTROLLER */
2108
2109#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
2114
2115#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2130static inline int i3c_ibi_hj_response(const struct device *dev,
2131 bool ack)
2132{
2133 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2134
2135 if (api->ibi_hj_response == NULL) {
2136 return -ENOSYS;
2137 }
2138
2139 return api->ibi_hj_response(dev, ack);
2140}
2141
2156static inline int i3c_ibi_crr_response(struct i3c_device_desc *target,
2157 bool ack)
2158{
2159 const struct i3c_driver_api *api =
2160 (const struct i3c_driver_api *)target->bus->api;
2161
2162 if (api->ibi_crr_response == NULL) {
2163 return -ENOSYS;
2164 }
2165
2166 return api->ibi_crr_response(target, ack);
2167}
2168#endif /* CONFIG_I3C_CONTROLLER */
2169
2170#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
2184static inline int i3c_ibi_raise(const struct device *dev,
2185 struct i3c_ibi *request)
2186{
2187 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
2188
2189 if (api->ibi_raise == NULL) {
2190 return -ENOSYS;
2191 }
2192
2193 return api->ibi_raise(dev, request);
2194}
2195#endif /* CONFIG_I3C_TARGET */
2196
2197#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2214static inline int i3c_ibi_enable(struct i3c_device_desc *target)
2215{
2216 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, target->bus);
2217
2218 if (api->ibi_enable == NULL) {
2219 return -ENOSYS;
2220 }
2221
2222 return api->ibi_enable(target->bus, target);
2223}
2224
2239static inline int i3c_ibi_disable(struct i3c_device_desc *target)
2240{
2241 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, target->bus);
2242
2243 if (api->ibi_disable == NULL) {
2244 return -ENOSYS;
2245 }
2246
2247 return api->ibi_disable(target->bus, target);
2248}
2249#endif /* CONFIG_I3C_CONTROLLER */
2250#endif /* CONFIG_I3C_USE_IBI */
2251
2263static inline int i3c_ibi_has_payload(struct i3c_device_desc *target)
2264{
2265 return (target->bcr & I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE)
2267}
2268
2280static inline int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
2281{
2282 return (target->bcr & I3C_BCR_IBI_REQUEST_CAPABLE)
2284}
2285
2297static inline int i3c_device_is_controller_capable(struct i3c_device_desc *target)
2298{
2299 return I3C_BCR_DEVICE_ROLE(target->bcr)
2301}
2302
2304
2305#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
2310
2326static inline int i3c_write(struct i3c_device_desc *target,
2327 const uint8_t *buf, uint32_t num_bytes)
2328{
2329 struct i3c_msg msg;
2330
2331 msg.buf = (uint8_t *)buf;
2332 msg.len = num_bytes;
2334 msg.hdr_mode = 0;
2335 msg.hdr_cmd_code = 0;
2336
2337 return i3c_transfer(target, &msg, 1);
2338}
2339
2355static inline int i3c_read(struct i3c_device_desc *target,
2356 uint8_t *buf, uint32_t num_bytes)
2357{
2358 struct i3c_msg msg;
2359
2360 msg.buf = 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
2388static inline int i3c_write_read(struct i3c_device_desc *target,
2389 const void *write_buf, size_t num_write,
2390 void *read_buf, size_t num_read)
2391{
2392 struct i3c_msg msg[2];
2393
2394 msg[0].buf = (uint8_t *)write_buf;
2395 msg[0].len = num_write;
2396 msg[0].flags = I3C_MSG_WRITE;
2397 msg[0].hdr_mode = 0;
2398 msg[0].hdr_cmd_code = 0;
2399
2400 msg[1].buf = (uint8_t *)read_buf;
2401 msg[1].len = num_read;
2403 msg[1].hdr_mode = 0;
2404 msg[1].hdr_cmd_code = 0;
2405
2406 return i3c_transfer(target, msg, 2);
2407}
2408
2428static inline int i3c_burst_read(struct i3c_device_desc *target,
2429 uint8_t start_addr,
2430 uint8_t *buf,
2431 uint32_t num_bytes)
2432{
2433 return i3c_write_read(target,
2434 &start_addr, sizeof(start_addr),
2435 buf, num_bytes);
2436}
2437
2460static inline int i3c_burst_write(struct i3c_device_desc *target,
2461 uint8_t start_addr,
2462 const uint8_t *buf,
2463 uint32_t num_bytes)
2464{
2465 struct i3c_msg msg[2];
2466
2467 msg[0].buf = &start_addr;
2468 msg[0].len = 1U;
2469 msg[0].flags = I3C_MSG_WRITE;
2470 msg[0].hdr_mode = 0;
2471 msg[0].hdr_cmd_code = 0;
2472
2473 msg[1].buf = (uint8_t *)buf;
2474 msg[1].len = num_bytes;
2475 msg[1].flags = I3C_MSG_WRITE | I3C_MSG_STOP;
2476 msg[1].hdr_mode = 0;
2477 msg[1].hdr_cmd_code = 0;
2478
2479 return i3c_transfer(target, msg, 2);
2480}
2481
2498static inline int i3c_reg_read_byte(struct i3c_device_desc *target,
2499 uint8_t reg_addr, uint8_t *value)
2500{
2501 return i3c_write_read(target,
2502 &reg_addr, sizeof(reg_addr),
2503 value, sizeof(*value));
2504}
2505
2525static inline int i3c_reg_write_byte(struct i3c_device_desc *target,
2526 uint8_t reg_addr, uint8_t value)
2527{
2528 uint8_t tx_buf[2] = {reg_addr, value};
2529
2530 return i3c_write(target, tx_buf, 2);
2531}
2532
2553static inline int i3c_reg_update_byte(struct i3c_device_desc *target,
2554 uint8_t reg_addr, uint8_t mask,
2555 uint8_t value)
2556{
2557 uint8_t old_value, new_value;
2558 int rc;
2559
2560 rc = i3c_reg_read_byte(target, reg_addr, &old_value);
2561 if (rc != 0) {
2562 return rc;
2563 }
2564
2565 new_value = (old_value & ~mask) | (value & mask);
2566 if (new_value == old_value) {
2567 return 0;
2568 }
2569
2570 return i3c_reg_write_byte(target, reg_addr, new_value);
2571}
2572
2599void i3c_dump_msgs(const char *name, const struct i3c_msg *msgs,
2600 uint8_t num_msgs, struct i3c_device_desc *target);
2601
2603
2621int i3c_bus_init(const struct device *dev,
2622 const struct i3c_dev_list *i3c_dev_list);
2623
2644
2670
2694static inline int i3c_device_info_get(struct i3c_device_desc *target)
2695{
2696 int rc;
2697
2698 rc = i3c_device_basic_info_get(target);
2699 if (rc != 0) {
2700 return rc;
2701 }
2702
2703 return i3c_device_adv_info_get(target);
2704}
2705
2718enum i3c_bus_mode i3c_bus_mode(const struct i3c_dev_list *dev_list);
2719
2732bool i3c_bus_has_sec_controller(const struct device *dev);
2733
2746int i3c_bus_rstdaa_all(const struct device *dev);
2747
2762int i3c_bus_setdasa(struct i3c_device_desc *desc, uint8_t dynamic_addr);
2763
2778int i3c_bus_setnewda(struct i3c_device_desc *desc, uint8_t dynamic_addr);
2779
2792int i3c_bus_setaasa(const struct device *dev);
2793
2807
2821
2835
2849
2863
2878int i3c_bus_setmrl(struct i3c_device_desc *desc, uint16_t mrl, uint8_t ibi_len);
2879
2894
2910int i3c_bus_setmrl_all(const struct device *dev, uint16_t mrl, uint8_t ibi_len, bool has_ibi_size);
2911
2925int i3c_bus_setmwl_all(const struct device *dev, uint16_t mwl);
2926
2927#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
2941
2955int i3c_bus_deftgts(const struct device *dev);
2956#endif /* CONFIG_I3C_TARGET */
2957
2970
2987int i3c_device_controller_handoff(struct i3c_device_desc *target, bool requested);
2988#endif /* CONFIG_I3C_CONTROLLER */
2989
2990#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
2991#if (defined(CONFIG_I3C_CONTROLLER) && defined(CONFIG_I3C_TARGET)) || defined(__DOXYGEN__)
3005void i3c_sec_handoffed(struct k_work *work);
3006#endif /* CONFIG_I3C_CONTROLLER && CONFIG_I3C_TARGET */
3007#endif /* CONFIG_I3C_USE_IBI */
3008
3009#if (defined(CONFIG_I3C_NUM_OF_DESC_MEM_SLABS) && CONFIG_I3C_NUM_OF_DESC_MEM_SLABS > 0) || \
3010 defined(__DOXYGEN__)
3011
3023
3034
3047
3048#else
3049
3050static inline struct i3c_device_desc *i3c_device_desc_alloc(void)
3051{
3052 return NULL;
3053}
3054
3055static inline void i3c_device_desc_free(struct i3c_device_desc *desc)
3056{
3057 ARG_UNUSED(desc);
3058}
3059
3060static inline bool i3c_device_desc_in_pool(struct i3c_device_desc *desc)
3061{
3062 ARG_UNUSED(desc);
3063 return false;
3064}
3065
3066#endif /* CONFIG_I3C_NUM_OF_DESC_MEM_SLABS > 0 */
3067
3068#if (defined(CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS) && CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS > 0) || \
3069 defined(__DOXYGEN__)
3070
3082
3093
3106
3107#else
3108
3109static inline struct i3c_i2c_device_desc *i3c_i2c_device_desc_alloc(void)
3110{
3111 return NULL;
3112}
3113
3114static inline void i3c_i2c_device_desc_free(struct i3c_i2c_device_desc *desc)
3115{
3116 ARG_UNUSED(desc);
3117}
3118
3119static inline bool i3c_i2c_device_desc_in_pool(struct i3c_i2c_device_desc *desc)
3120{
3121 ARG_UNUSED(desc);
3122 return false;
3123}
3124
3125#endif /* CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS > 0 */
3126
3127#if defined(CONFIG_I3C_RTIO) || defined(__DOXYGEN__)
3128
3130 const struct device *bus;
3131 const struct i3c_device_id dev_id;
3132};
3133
3146void i3c_iodev_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe);
3147
3156static inline void i3c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
3157{
3158 const struct i3c_iodev_data *data =
3159 (const struct i3c_iodev_data *)iodev_sqe->sqe.iodev->data;
3160 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, data->bus);
3161
3162 if (api->iodev_submit == NULL) {
3163 rtio_iodev_sqe_err(iodev_sqe, -ENOSYS);
3164 return;
3165 }
3166 api->iodev_submit(data->bus, iodev_sqe);
3167}
3168
3169extern const struct rtio_iodev_api i3c_iodev_api;
3170
3182#define I3C_DT_IODEV_DEFINE(name, node_id) \
3183 const struct i3c_iodev_data _i3c_iodev_data_##name = { \
3184 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
3185 .dev_id = I3C_DEVICE_ID_DT(node_id), \
3186 }; \
3187 RTIO_IODEV_DEFINE(name, &i3c_iodev_api, (void *)&_i3c_iodev_data_##name)
3188
3200#define I3C_DT_INST_IODEV_DEFINE(name, inst) \
3201 I3C_DT_IODEV_DEFINE(name, DT_DRV_INST(inst))
3202
3216struct rtio_sqe *i3c_rtio_copy(struct rtio *r,
3217 struct rtio_iodev *iodev,
3218 const struct i3c_msg *msgs,
3219 uint8_t num_msgs);
3220
3221#endif /* CONFIG_I3C_RTIO */
3222
3223#if defined(CONFIG_I3C_TARGET) || defined(__DOXYGEN__)
3224/*
3225 * This needs to be after declaration of struct i3c_driver_api,
3226 * or else compiler complains about undefined type inside
3227 * the static inline API wrappers.
3228 */
3230#endif /* CONFIG_I3C_TARGET */
3231
3232#if defined(CONFIG_I3C_CONTROLLER) || defined(__DOXYGEN__)
3233/*
3234 * Include High-Data-Rate (HDR) inline helper functions
3235 */
3237#endif /* CONFIG_I3C_CONTROLLER */
3238
3239#ifdef __cplusplus
3240}
3241#endif
3242
3246
3247#include <zephyr/syscalls/i3c.h>
3248
3249#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_H_ */
#define DEVICE_API_EXTENDS(_child, _parent, _member)
Declare that API class _child is an extension of device API class _parent.
Definition device.h:1414
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1449
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:2239
static int i3c_ibi_has_payload(struct i3c_device_desc *target)
Check if target's IBI has payload.
Definition i3c.h:2263
static int i3c_ibi_crr_response(struct i3c_device_desc *target, bool ack)
ACK or NACK IBI Controller Role Requests.
Definition i3c.h:2156
static int i3c_ibi_raise(const struct device *dev, struct i3c_ibi *request)
Raise an In-Band Interrupt (IBI).
Definition i3c.h:2184
static int i3c_device_is_controller_capable(struct i3c_device_desc *target)
Check if the target is controller capable.
Definition i3c.h:2297
static int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
Check if device is IBI capable.
Definition i3c.h:2280
static int i3c_ibi_enable(struct i3c_device_desc *target)
Enable IBI of a target device.
Definition i3c.h:2214
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:2130
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:2096
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:1539
static int i3c_device_info_get(struct i3c_device_desc *target)
Get all information from device and update device descriptor.
Definition i3c.h:2694
static void i3c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
Submit request(s) to an I3C device with RTIO.
Definition i3c.h:3156
#define I3C_BUS_FOR_EACH_I3CDEV(bus, desc)
iterate over all I3C devices present on the bus
Definition i3c.h:1352
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:1365
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:1860
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:451
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:1696
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:1594
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:1621
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:1676
#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:1651
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:1897
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:1794
void(* i3c_callback_t)(const struct device *dev, int result, void *data)
I3C callback for asynchronous transfer requests.
Definition i3c.h:533
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:1569
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:453
@ I3C_CONFIG_CUSTOM
Definition i3c.h:454
@ I3C_CONFIG_CONTROLLER
Definition i3c.h:452
@ 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:2388
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:2428
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:2553
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:2498
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:2326
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:2355
#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:2460
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:2525
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:673
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:513
void * data
Address of the device instance private data.
Definition device.h:523
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
<span class="mlabel">Driver Operations</span> I2C driver operations
Definition i2c.h:325
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:460
struct i3c_config_controller::@171175234007106124341357122051356217163277103172 scl_od_min
uint32_t i3c
SCL frequency (in Hz) for I3C transfers.
Definition i3c.h:469
uint8_t supported_hdr
Bit mask of supported HDR modes (0 - 7).
Definition i3c.h:497
bool is_secondary
True if the controller is to be the secondary controller of the bus.
Definition i3c.h:465
uint32_t i2c
SCL frequency (in Hz) for I2C transfers.
Definition i3c.h:472
uint32_t low_ns
Requested minimum SCL Open-Drain LOW period in nanoseconds.
Definition i3c.h:488
struct i3c_config_controller::@056135366137020063162136324011126070110331100007 scl
uint32_t high_ns
Requested minimum SCL Open Drain High period in Nanoseconds.
Definition i3c.h:483
Custom I3C configuration parameters.
Definition i3c.h:508
void * ptr
Pointer to configuration parameter.
Definition i3c.h:522
uint32_t id
ID of the configuration parameter.
Definition i3c.h:510
uintptr_t val
Value of configuration parameter.
Definition i3c.h:514
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:1245
sys_slist_t i3c
Linked list of attached I3C devices.
Definition i3c.h:1258
struct i3c_dev_attached_list::@376142005326063102166306177206174071064206117170 devices
sys_slist_t i2c
Linked list of attached I2C devices.
Definition i3c.h:1263
struct i3c_addr_slots addr_slots
Address slots:
Definition i3c.h:1252
Structure for describing known devices for a controller.
Definition i3c.h:1275
struct i3c_i2c_device_desc *const i2c
Pointer to array of known I2C devices.
Definition i3c.h:1284
const uint8_t num_i3c
Number of I3C devices in array.
Definition i3c.h:1289
struct i3c_device_desc *const i3c
Pointer to array of known I3C devices.
Definition i3c.h:1279
const uint8_t num_i2c
Number of I2C devices in array.
Definition i3c.h:1294
Structure describing a I3C target device.
Definition i3c.h:1011
uint8_t maxwr
Maximum Write Speed.
Definition i3c.h:1091
const uint8_t init_dynamic_addr
Initial dynamic address.
Definition i3c.h:1046
uint8_t getcap1
I3C v1.1+ GETCAPS1 (I3C_CCC_GETCAPS1_*).
Definition i3c.h:1131
uint8_t static_addr
Static address for this target device.
Definition i3c.h:1035
uint8_t getcap2
GETCAPS2 (I3C_CCC_GETCAPS2_*).
Definition i3c.h:1141
uint8_t crcaps2
CRCAPS2.
Definition i3c.h:1182
uint32_t max_read_turnaround
Maximum Read turnaround time in microseconds.
Definition i3c.h:1094
uint8_t getcap4
GETCAPS4.
Definition i3c.h:1160
uint64_t pid
Device Provisioned ID.
Definition i3c.h:1021
uint8_t max_ibi
Maximum IBI Payload Size.
Definition i3c.h:1105
struct i3c_device_desc::@171122044300150030070232076155234262120067102161 getcaps
Describes advanced (Target) capabilities and features.
i3c_target_ibi_cb_t ibi_cb
In-Band Interrupt (IBI) callback.
Definition i3c.h:1197
uint16_t mwl
Maximum Write Length.
Definition i3c.h:1102
struct i3c_device_desc::@374166210137153225365322260210124156025250214226 data_speed
struct i3c_device_desc::@354012327114236120073125301213366107212276207024 crcaps
uint8_t crhdly1
Controller Handoff Delay Parameters.
Definition i3c.h:1109
uint8_t getcap3
GETCAPS3 (I3C_CCC_GETCAPS3_*).
Definition i3c.h:1154
uint8_t dynamic_addr
Dynamic Address for this target device used for communication.
Definition i3c.h:1070
uint8_t crcaps1
CRCAPS1.
Definition i3c.h:1172
const uint8_t flags
Device Flags.
Definition i3c.h:1055
sys_snode_t node
Definition i3c.h:1012
const struct device * bus
I3C bus to which this target device is attached.
Definition i3c.h:1015
struct i3c_device_desc::@025161371003043020356247061065002050371177151366 data_length
uint16_t mrl
Maximum Read Length.
Definition i3c.h:1099
uint8_t maxrd
Maximum Read Speed.
Definition i3c.h:1088
uint8_t gethdrcap
I3C v1.0 HDR Capabilities (I3C_CCC_GETCAPS1_*).
Definition i3c.h:1121
uint8_t bcr
Bus Characteristic Register (BCR).
Definition i3c.h:1076
uint8_t dcr
Device Characteristic Register (DCR).
Definition i3c.h:1084
const struct device * dev
Device driver instance of the I3C device.
Definition i3c.h:1018
Structure used for matching I3C devices.
Definition i3c.h:977
uint64_t pid
Device Provisioned ID.
Definition i3c.h:979
This structure is common to all I3C drivers and is expected to be the first element in the object poi...
Definition i3c.h:1302
uint8_t primary_controller_da
I3C Primary Controller Dynamic Address.
Definition i3c.h:1308
uint8_t flags
Driver config flags.
Definition i3c.h:1311
struct i3c_dev_list dev_list
I3C/I2C device list struct.
Definition i3c.h:1305
This structure is common to all I3C drivers and is expected to be the first element in the driver's s...
Definition i3c.h:1326
struct i3c_config_controller ctrl_config
Controller Configuration.
Definition i3c.h:1328
struct i3c_ccc_deftgts * deftgts
Received DEFTGTS Pointer.
Definition i3c.h:1334
bool deftgts_refreshed
DEFTGTS refreshed.
Definition i3c.h:1337
struct i3c_dev_attached_list attached_dev
Attached I3C/I2C devices and addresses.
Definition i3c.h:1331
Structure describing a I2C device on I3C bus.
Definition i3c.h:1214
const struct device * bus
I3C bus to which this I2C device is attached.
Definition i3c.h:1218
uint8_t lvr
Legacy Virtual Register (LVR).
Definition i3c.h:1227
uint16_t addr
Static address for this I2C device.
Definition i3c.h:1221
sys_snode_t node
Definition i3c.h:1215
Struct for IBI request.
Definition ibi.h:58
Definition i3c.h:3129
const struct device * bus
Definition i3c.h:3130
const struct i3c_device_id dev_id
Definition i3c.h:3131
One I3C Message.
Definition i3c.h:407
uint8_t flags
Flags for this message.
Definition i3c.h:432
uint8_t hdr_mode
HDR mode (I3C_MSG_HDR_MODE*) for transfer if any I3C_MSG_HDR_* is set in flags.
Definition i3c.h:440
uint32_t num_xfer
Total number of bytes transferred.
Definition i3c.h:421
uint8_t * buf
Data buffer in bytes.
Definition i3c.h:409
uint8_t hdr_cmd_code
HDR command code field (7-bit) for HDR-DDR, HDR-TSP and HDR-TSL.
Definition i3c.h:443
uint32_t len
Length of buffer in bytes.
Definition i3c.h:412
enum i3c_sdr_controller_error_types err
SDR Error Type.
Definition i3c.h:429
Structure describing a device that supports the I3C target API.
Definition target_device.h:101
A structure used to submit work.
Definition kernel.h:4717
API that an RTIO IO device should implement.
Definition iodev.h:33
IO device submission queue entry.
Definition sqe.h:394
struct rtio_sqe sqe
Definition sqe.h:395
An IO device with a function table for submitting requests.
Definition iodev.h:48
void * data
Definition iodev.h:53
A submission queue event.
Definition sqe.h:304
const struct rtio_iodev * iodev
Device to operation on.
Definition sqe.h:313
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:70
Misc utilities.