Zephyr API Documentation 4.0.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
8#ifndef ZEPHYR_INCLUDE_DRIVERS_I3C_H_
9#define ZEPHYR_INCLUDE_DRIVERS_I3C_H_
10
20#include <errno.h>
21#include <stdint.h>
22#include <stddef.h>
23
24#include <zephyr/device.h>
29#include <zephyr/drivers/i2c.h>
30#include <zephyr/sys/slist.h>
31#include <zephyr/sys/util.h>
32#include <zephyr/rtio/rtio.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
85#define I3C_BCR_MAX_DATA_SPEED_LIMIT BIT(0)
86
88#define I3C_BCR_IBI_REQUEST_CAPABLE BIT(1)
89
97#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE BIT(2)
98
105#define I3C_BCR_OFFLINE_CAPABLE BIT(3)
106
113#define I3C_BCR_VIRTUAL_TARGET BIT(4)
114
122#define I3C_BCR_ADV_CAPABILITIES BIT(5)
123
125#define I3C_BCR_DEVICE_ROLE_I3C_TARGET 0U
126
128#define I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE 1U
129
131#define I3C_BCR_DEVICE_ROLE_MASK GENMASK(7U, 6U)
132
140#define I3C_BCR_DEVICE_ROLE(bcr) \
141 FIELD_GET(I3C_BCR_DEVICE_ROLE_MASK, (bcr))
142
166#define I3C_LVR_I2C_FM_PLUS_MODE 0
167
169#define I3C_LVR_I2C_FM_MODE 1
170
172#define I3C_LVR_I2C_MODE_MASK BIT(4)
173
181#define I3C_LVR_I2C_MODE(lvr) \
182 FIELD_GET(I3C_LVR_I2C_MODE_MASK, (lvr))
183
190#define I3C_LVR_I2C_DEV_IDX_0 0
191
198#define I3C_LVR_I2C_DEV_IDX_1 1
199
206#define I3C_LVR_I2C_DEV_IDX_2 2
207
209#define I3C_LVR_I2C_DEV_IDX_MASK GENMASK(7U, 5U)
210
218#define I3C_LVR_I2C_DEV_IDX(lvr) \
219 FIELD_GET(I3C_LVR_I2C_DEV_IDX_MASK, (lvr))
220
253
269
294
327
375
382/*
383 * I3C_MSG_* are I3C Message flags.
384 */
385
387#define I3C_MSG_WRITE (0U << 0U)
388
390#define I3C_MSG_READ BIT(0)
391
393#define I3C_MSG_RW_MASK BIT(0)
397#define I3C_MSG_STOP BIT(1)
398
408#define I3C_MSG_RESTART BIT(2)
409
411#define I3C_MSG_HDR BIT(3)
412
414#define I3C_MSG_NBCH BIT(4)
415
417#define I3C_MSG_HDR_MODE0 BIT(0)
418
420#define I3C_MSG_HDR_MODE1 BIT(1)
421
423#define I3C_MSG_HDR_MODE2 BIT(2)
424
426#define I3C_MSG_HDR_MODE3 BIT(3)
427
429#define I3C_MSG_HDR_MODE4 BIT(4)
430
432#define I3C_MSG_HDR_MODE5 BIT(5)
433
435#define I3C_MSG_HDR_MODE6 BIT(6)
436
438#define I3C_MSG_HDR_MODE7 BIT(7)
439
441#define I3C_MSG_HDR_DDR I3C_MSG_HDR_MODE0
442
444#define I3C_MSG_HDR_TSP I3C_MSG_HDR_MODE1
445
447#define I3C_MSG_HDR_TSL I3C_MSG_HDR_MODE2
448
450#define I3C_MSG_HDR_BT I3C_MSG_HDR_MODE3
451
503
514
541
553
554 union {
557
564 void *ptr;
565 };
566};
567
574struct i3c_device_desc;
575struct i3c_device_id;
577struct i3c_target_config;
578
579__subsystem struct i3c_driver_api {
589 struct i2c_driver_api i2c_api;
590
603 int (*configure)(const struct device *dev,
604 enum i3c_config_type type, void *config);
605
618 int (*config_get)(const struct device *dev,
619 enum i3c_config_type type, void *config);
620
632 int (*recover_bus)(const struct device *dev);
633
646 int (*attach_i3c_device)(const struct device *dev,
647 struct i3c_device_desc *target);
648
662 int (*reattach_i3c_device)(const struct device *dev,
663 struct i3c_device_desc *target,
664 uint8_t old_dyn_addr);
665
678 int (*detach_i3c_device)(const struct device *dev,
679 struct i3c_device_desc *target);
680
693 int (*attach_i2c_device)(const struct device *dev,
694 struct i3c_i2c_device_desc *target);
695
708 int (*detach_i2c_device)(const struct device *dev,
709 struct i3c_i2c_device_desc *target);
710
722 int (*do_daa)(const struct device *dev);
723
736 int (*do_ccc)(const struct device *dev,
737 struct i3c_ccc_payload *payload);
738
751 int (*i3c_xfers)(const struct device *dev,
752 struct i3c_device_desc *target,
753 struct i3c_msg *msgs,
754 uint8_t num_msgs);
755
769 struct i3c_device_desc *(*i3c_device_find)(const struct device *dev,
770 const struct i3c_device_id *id);
771
784 int (*ibi_raise)(const struct device *dev,
785 struct i3c_ibi *request);
786
799 int (*ibi_enable)(const struct device *dev,
800 struct i3c_device_desc *target);
801
814 int (*ibi_disable)(const struct device *dev,
815 struct i3c_device_desc *target);
816
832 int (*target_register)(const struct device *dev,
833 struct i3c_target_config *cfg);
834
850 int (*target_unregister)(const struct device *dev,
851 struct i3c_target_config *cfg);
852
869 int (*target_tx_write)(const struct device *dev,
870 uint8_t *buf, uint16_t len, uint8_t hdr_mode);
871
872#ifdef CONFIG_I3C_RTIO
883 void (*iodev_submit)(const struct device *dev,
884 struct rtio_iodev_sqe *iodev_sqe);
885#endif
886};
887
897 const uint64_t pid:48;
898};
899
908#define I3C_DEVICE_ID(pid) \
909 { \
910 .pid = pid \
911 }
912
931
933 const struct device * const bus;
934
936 const struct device * const dev;
937
939 const uint64_t pid:48;
940
954
965
973
988
989#if defined(CONFIG_I3C_USE_GROUP_ADDR) || defined(__DOXYGEN__)
999#endif /* CONFIG_I3C_USE_GROUP_ADDR */
1000
1006
1014
1015 struct {
1018
1021
1025
1026 struct {
1029
1032
1036
1038 struct {
1039 union {
1048
1058 };
1059
1068
1081
1088
1093 void *controller_priv;
1096#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
1102#endif /* CONFIG_I3C_USE_IBI */
1103};
1104
1120
1122 const struct device *bus;
1123
1126
1132
1137 void *controller_priv;
1139};
1140
1170
1183 struct i3c_device_desc * const i3c;
1184
1188 struct i3c_i2c_device_desc * const i2c;
1189
1194
1199};
1200
1210
1222
1230#define I3C_BUS_FOR_EACH_I3CDEV(bus, desc) \
1231 SYS_SLIST_FOR_EACH_CONTAINER( \
1232 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, node)
1233
1241#define I3C_BUS_FOR_EACH_I2CDEV(bus, desc) \
1242 SYS_SLIST_FOR_EACH_CONTAINER( \
1243 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, node)
1244
1257struct i3c_device_desc *i3c_dev_list_find(const struct i3c_dev_list *dev_list,
1258 const struct i3c_device_id *id);
1259
1273 uint8_t addr);
1274
1288 uint16_t addr);
1289
1342 const struct i3c_dev_list *dev_list,
1343 uint64_t pid, bool must_match,
1344 bool assigned_okay,
1345 struct i3c_device_desc **target,
1346 uint8_t *addr);
1347
1361static inline int i3c_configure(const struct device *dev,
1362 enum i3c_config_type type, void *config)
1363{
1364 const struct i3c_driver_api *api =
1365 (const struct i3c_driver_api *)dev->api;
1366
1367 if (api->configure == NULL) {
1368 return -ENOSYS;
1369 }
1370
1371 return api->configure(dev, type, config);
1372}
1373
1394static inline int i3c_config_get(const struct device *dev,
1395 enum i3c_config_type type, void *config)
1396{
1397 const struct i3c_driver_api *api =
1398 (const struct i3c_driver_api *)dev->api;
1399
1400 if (api->config_get == NULL) {
1401 return -ENOSYS;
1402 }
1403
1404 return api->config_get(dev, type, config);
1405}
1406
1417static inline int i3c_recover_bus(const struct device *dev)
1418{
1419 const struct i3c_driver_api *api =
1420 (const struct i3c_driver_api *)dev->api;
1421
1422 if (api->recover_bus == NULL) {
1423 return -ENOSYS;
1424 }
1425
1426 return api->recover_bus(dev);
1427}
1428
1449
1474int i3c_reattach_i3c_device(struct i3c_device_desc *target, uint8_t old_dyn_addr);
1475
1496
1516
1535
1559static inline int i3c_do_daa(const struct device *dev)
1560{
1561 const struct i3c_driver_api *api =
1562 (const struct i3c_driver_api *)dev->api;
1563
1564 if (api->do_daa == NULL) {
1565 return -ENOSYS;
1566 }
1567
1568 return api->do_daa(dev);
1569}
1570
1584__syscall int i3c_do_ccc(const struct device *dev,
1585 struct i3c_ccc_payload *payload);
1586
1587static inline int z_impl_i3c_do_ccc(const struct device *dev,
1588 struct i3c_ccc_payload *payload)
1589{
1590 const struct i3c_driver_api *api =
1591 (const struct i3c_driver_api *)dev->api;
1592
1593 if (api->do_ccc == NULL) {
1594 return -ENOSYS;
1595 }
1596
1597 return api->do_ccc(dev, payload);
1598}
1599
1631__syscall int i3c_transfer(struct i3c_device_desc *target,
1632 struct i3c_msg *msgs, uint8_t num_msgs);
1633
1634static inline int z_impl_i3c_transfer(struct i3c_device_desc *target,
1635 struct i3c_msg *msgs, uint8_t num_msgs)
1636{
1637 const struct i3c_driver_api *api =
1638 (const struct i3c_driver_api *)target->bus->api;
1639
1640 return api->i3c_xfers(target->bus, target, msgs, num_msgs);
1641}
1642
1659static inline
1661 const struct i3c_device_id *id)
1662{
1663 const struct i3c_driver_api *api =
1664 (const struct i3c_driver_api *)dev->api;
1665
1666 if (api->i3c_device_find == NULL) {
1667 return NULL;
1668 }
1669
1670 return api->i3c_device_find(dev, id);
1671}
1672
1689static inline int i3c_ibi_raise(const struct device *dev,
1690 struct i3c_ibi *request)
1691{
1692 const struct i3c_driver_api *api =
1693 (const struct i3c_driver_api *)dev->api;
1694
1695 if (api->ibi_raise == NULL) {
1696 return -ENOSYS;
1697 }
1698
1699 return api->ibi_raise(dev, request);
1700}
1701
1716static inline int i3c_ibi_enable(struct i3c_device_desc *target)
1717{
1718 const struct i3c_driver_api *api =
1719 (const struct i3c_driver_api *)target->bus->api;
1720
1721 if (api->ibi_enable == NULL) {
1722 return -ENOSYS;
1723 }
1724
1725 return api->ibi_enable(target->bus, target);
1726}
1727
1740static inline int i3c_ibi_disable(struct i3c_device_desc *target)
1741{
1742 const struct i3c_driver_api *api =
1743 (const struct i3c_driver_api *)target->bus->api;
1744
1745 if (api->ibi_disable == NULL) {
1746 return -ENOSYS;
1747 }
1748
1749 return api->ibi_disable(target->bus, target);
1750}
1751
1763static inline int i3c_ibi_has_payload(struct i3c_device_desc *target)
1764{
1765 return (target->bcr & I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE)
1767}
1768
1780static inline int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
1781{
1782 return (target->bcr & I3C_BCR_IBI_REQUEST_CAPABLE)
1784}
1785
1797static inline int i3c_device_is_controller_capable(struct i3c_device_desc *target)
1798{
1799 return I3C_BCR_DEVICE_ROLE(target->bcr)
1801}
1802
1823static inline int i3c_write(struct i3c_device_desc *target,
1824 const uint8_t *buf, uint32_t num_bytes)
1825{
1826 struct i3c_msg msg;
1827
1828 msg.buf = (uint8_t *)buf;
1829 msg.len = num_bytes;
1831 msg.hdr_mode = 0;
1832 msg.hdr_cmd_code = 0;
1833
1834 return i3c_transfer(target, &msg, 1);
1835}
1836
1850static inline int i3c_read(struct i3c_device_desc *target,
1851 uint8_t *buf, uint32_t num_bytes)
1852{
1853 struct i3c_msg msg;
1854
1855 msg.buf = buf;
1856 msg.len = num_bytes;
1858 msg.hdr_mode = 0;
1859 msg.hdr_cmd_code = 0;
1860
1861 return i3c_transfer(target, &msg, 1);
1862}
1863
1881static inline int i3c_write_read(struct i3c_device_desc *target,
1882 const void *write_buf, size_t num_write,
1883 void *read_buf, size_t num_read)
1884{
1885 struct i3c_msg msg[2];
1886
1887 msg[0].buf = (uint8_t *)write_buf;
1888 msg[0].len = num_write;
1889 msg[0].flags = I3C_MSG_WRITE;
1890 msg[0].hdr_mode = 0;
1891 msg[0].hdr_cmd_code = 0;
1892
1893 msg[1].buf = (uint8_t *)read_buf;
1894 msg[1].len = num_read;
1896 msg[1].hdr_mode = 0;
1897 msg[1].hdr_cmd_code = 0;
1898
1899 return i3c_transfer(target, msg, 2);
1900}
1901
1919static inline int i3c_burst_read(struct i3c_device_desc *target,
1920 uint8_t start_addr,
1921 uint8_t *buf,
1922 uint32_t num_bytes)
1923{
1924 return i3c_write_read(target,
1925 &start_addr, sizeof(start_addr),
1926 buf, num_bytes);
1927}
1928
1949static inline int i3c_burst_write(struct i3c_device_desc *target,
1950 uint8_t start_addr,
1951 const uint8_t *buf,
1952 uint32_t num_bytes)
1953{
1954 struct i3c_msg msg[2];
1955
1956 msg[0].buf = &start_addr;
1957 msg[0].len = 1U;
1958 msg[0].flags = I3C_MSG_WRITE;
1959 msg[0].hdr_mode = 0;
1960 msg[0].hdr_cmd_code = 0;
1961
1962 msg[1].buf = (uint8_t *)buf;
1963 msg[1].len = num_bytes;
1964 msg[1].flags = I3C_MSG_WRITE | I3C_MSG_STOP;
1965 msg[1].hdr_mode = 0;
1966 msg[1].hdr_cmd_code = 0;
1967
1968 return i3c_transfer(target, msg, 2);
1969}
1970
1985static inline int i3c_reg_read_byte(struct i3c_device_desc *target,
1986 uint8_t reg_addr, uint8_t *value)
1987{
1988 return i3c_write_read(target,
1989 &reg_addr, sizeof(reg_addr),
1990 value, sizeof(*value));
1991}
1992
2010static inline int i3c_reg_write_byte(struct i3c_device_desc *target,
2011 uint8_t reg_addr, uint8_t value)
2012{
2013 uint8_t tx_buf[2] = {reg_addr, value};
2014
2015 return i3c_write(target, tx_buf, 2);
2016}
2017
2036static inline int i3c_reg_update_byte(struct i3c_device_desc *target,
2037 uint8_t reg_addr, uint8_t mask,
2038 uint8_t value)
2039{
2040 uint8_t old_value, new_value;
2041 int rc;
2042
2043 rc = i3c_reg_read_byte(target, reg_addr, &old_value);
2044 if (rc != 0) {
2045 return rc;
2046 }
2047
2048 new_value = (old_value & ~mask) | (value & mask);
2049 if (new_value == old_value) {
2050 return 0;
2051 }
2052
2053 return i3c_reg_write_byte(target, reg_addr, new_value);
2054}
2055
2080void i3c_dump_msgs(const char *name, const struct i3c_msg *msgs,
2081 uint8_t num_msgs, struct i3c_device_desc *target);
2082
2100int i3c_bus_init(const struct device *dev,
2101 const struct i3c_dev_list *i3c_dev_list);
2102
2123
2134bool i3c_bus_has_sec_controller(const struct device *dev);
2135
2147int i3c_bus_deftgts(const struct device *dev);
2148
2149#if defined(CONFIG_I3C_RTIO) || defined(__DOXYGEN__)
2150
2152 const struct device *bus;
2153 const struct i3c_device_id dev_id;
2154};
2155
2166void i3c_iodev_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe);
2167
2174static inline void i3c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
2175{
2176 const struct i3c_iodev_data *data =
2177 (const struct i3c_iodev_data *)iodev_sqe->sqe.iodev->data;
2178 const struct i3c_driver_api *api = (const struct i3c_driver_api *)data->bus->api;
2179
2180 if (api->iodev_submit == NULL) {
2181 rtio_iodev_sqe_err(iodev_sqe, -ENOSYS);
2182 return;
2183 }
2184 api->iodev_submit(data->bus, iodev_sqe);
2185}
2186
2187extern const struct rtio_iodev_api i3c_iodev_api;
2188
2198#define I3C_DT_IODEV_DEFINE(name, node_id) \
2199 const struct i3c_iodev_data _i3c_iodev_data_##name = { \
2200 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
2201 .dev_id = I3C_DEVICE_ID_DT(node_id), \
2202 }; \
2203 RTIO_IODEV_DEFINE(name, &i3c_iodev_api, (void *)&_i3c_iodev_data_##name)
2204
2217 struct rtio_iodev *iodev,
2218 const struct i3c_msg *msgs,
2219 uint8_t num_msgs);
2220
2221#endif /* CONFIG_I3C_RTIO */
2222
2223/*
2224 * This needs to be after declaration of struct i3c_driver_api,
2225 * or else compiler complains about undefined type inside
2226 * the static inline API wrappers.
2227 */
2229
2230/*
2231 * Include High-Data-Rate (HDR) inline helper functions
2232 */
2234
2235#ifdef __cplusplus
2236}
2237#endif
2238
2243#include <zephyr/syscalls/i3c.h>
2244
2245#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_H_ */
workaround assembler barfing for ST r
Definition asm-macro-32-bit-gnu.h:24
Public APIs for the I2C drivers.
System error numbers.
static int i3c_ibi_disable(struct i3c_device_desc *target)
Disable IBI of a target device.
Definition i3c.h:1740
static int i3c_ibi_has_payload(struct i3c_device_desc *target)
Check if target's IBI has payload.
Definition i3c.h:1763
static int i3c_ibi_raise(const struct device *dev, struct i3c_ibi *request)
Raise an In-Band Interrupt (IBI).
Definition i3c.h:1689
static int i3c_device_is_controller_capable(struct i3c_device_desc *target)
Check if the target is controller capable.
Definition i3c.h:1797
static int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
Check if device is IBI capable.
Definition i3c.h:1780
static int i3c_ibi_enable(struct i3c_device_desc *target)
Enable IBI of a target device.
Definition i3c.h:1716
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
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:88
#define I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE
Device Role - I3C Controller Capable.
Definition i3c.h:128
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:1660
bool i3c_bus_has_sec_controller(const struct device *dev)
Check if the bus has a secondary controller.
i3c_sdr_target_error_codes
I3C SDR Target Error Codes.
Definition i3c.h:338
static int i3c_configure(const struct device *dev, enum i3c_config_type type, void *config)
Configure the I3C hardware.
Definition i3c.h:1361
int i3c_dev_list_daa_addr_helper(struct i3c_addr_slots *addr_slots, const struct i3c_dev_list *dev_list, 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.
static void i3c_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
Submit request(s) to an I3C device with RTIO.
Definition i3c.h:2174
int i3c_bus_deftgts(const struct device *dev)
Send the CCC DEFTGTS.
i3c_config_type
Type of configuration being passed to configure function.
Definition i3c.h:509
int i3c_attach_i2c_device(struct i3c_i2c_device_desc *target)
Attach an I2C device.
i3c_i2c_speed_type
I2C bus speed under I3C bus.
Definition i3c.h:259
int i3c_detach_i3c_device(struct i3c_device_desc *target)
Detach I3C Device.
i3c_bus_mode
I3C bus mode.
Definition i3c.h:226
static int i3c_recover_bus(const struct device *dev)
Attempt bus recovery on the I3C bus.
Definition i3c.h:1417
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:1394
int i3c_detach_i2c_device(struct i3c_i2c_device_desc *target)
Detach I2C Device.
#define I3C_BCR_DEVICE_ROLE(bcr)
Device Role.
Definition i3c.h:140
void i3c_iodev_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
Fallback submit implementation.
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.
i3c_sdr_controller_error_codes
I3C SDR Controller Error Codes.
Definition i3c.h:305
int i3c_do_ccc(const struct device *dev, struct i3c_ccc_payload *payload)
Send CCC to the bus.
int i3c_device_basic_info_get(struct i3c_device_desc *target)
Get basic information from device and update device descriptor.
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.
static int i3c_do_daa(const struct device *dev)
Perform Dynamic Address Assignment on the I3C bus.
Definition i3c.h:1559
const struct rtio_iodev_api i3c_iodev_api
#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE
IBI Payload bit.
Definition i3c.h:97
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:275
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_ERROR_TE_UNKNOWN
Unknown error (not official error code)
Definition i3c.h:367
@ I3C_ERROR_TE6
Monitoring Error.
Definition i3c.h:361
@ I3C_ERROR_TE4
0x7E/R missing after RESTART during Dynamic Address Arbitration
Definition i3c.h:355
@ I3C_ERROR_TE3
Assigned Address during Dynamic Address Arbitration.
Definition i3c.h:352
@ I3C_ERROR_TE_NONE
No error (not official error code)
Definition i3c.h:370
@ I3C_ERROR_TE_MAX
Definition i3c.h:372
@ I3C_ERROR_TE1
CCC Code.
Definition i3c.h:346
@ I3C_ERROR_TE5
Transaction after detecting CCC.
Definition i3c.h:358
@ I3C_ERROR_DBR
Dead Bus Recovery.
Definition i3c.h:364
@ I3C_ERROR_TE2
Write Data.
Definition i3c.h:349
@ I3C_ERROR_TE_INVALID
Definition i3c.h:373
@ I3C_ERROR_TE0
Invalid Broadcast Address or Dynamic Address after DA assignment.
Definition i3c.h:343
@ I3C_CONFIG_TARGET
Definition i3c.h:511
@ I3C_CONFIG_CUSTOM
Definition i3c.h:512
@ I3C_CONFIG_CONTROLLER
Definition i3c.h:510
@ I3C_I2C_SPEED_INVALID
Definition i3c.h:267
@ I3C_I2C_SPEED_MAX
Definition i3c.h:266
@ I3C_I2C_SPEED_FMPLUS
I2C FM+ mode.
Definition i3c.h:264
@ I3C_I2C_SPEED_FM
I2C FM mode.
Definition i3c.h:261
@ I3C_BUS_MODE_INVALID
Definition i3c.h:251
@ I3C_BUS_MODE_PURE
Only I3C devices are on the bus.
Definition i3c.h:228
@ I3C_BUS_MODE_MIXED_FAST
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:234
@ I3C_BUS_MODE_MAX
Definition i3c.h:250
@ I3C_BUS_MODE_MIXED_LIMITED
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:241
@ I3C_BUS_MODE_MIXED_SLOW
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:248
@ I3C_ERROR_CE0
Transaction after sending CCC.
Definition i3c.h:307
@ I3C_ERROR_CE2
No response to broadcast address (0x7E)
Definition i3c.h:313
@ I3C_ERROR_CE_INVALID
Definition i3c.h:325
@ I3C_ERROR_CE_MAX
Definition i3c.h:324
@ I3C_ERROR_CE_UNKNOWN
Unknown error (not official error code)
Definition i3c.h:319
@ I3C_ERROR_CE3
Failed Controller Handoff.
Definition i3c.h:316
@ I3C_ERROR_CE1
Monitoring Error.
Definition i3c.h:310
@ I3C_ERROR_CE_NONE
No error (not official error code)
Definition i3c.h:322
@ I3C_DATA_RATE_MAX
Definition i3c.h:291
@ I3C_DATA_RATE_INVALID
Definition i3c.h:292
@ I3C_DATA_RATE_HDR_TSP
High Data Rate - Ternary Symbol for Pure Bus.
Definition i3c.h:286
@ I3C_DATA_RATE_HDR_DDR
High Data Rate - Double Data Rate messaging.
Definition i3c.h:280
@ I3C_DATA_RATE_SDR
Single Data Rate messaging.
Definition i3c.h:277
@ I3C_DATA_RATE_HDR_TSL
High Data Rate - Ternary Symbol Legacy-inclusive-Bus.
Definition i3c.h:283
@ I3C_DATA_RATE_HDR_BT
High Data Rate - Bulk Transport.
Definition i3c.h:289
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:397
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:1881
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:1919
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:2036
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:390
#define I3C_MSG_WRITE
Write message to I3C bus.
Definition i3c.h:387
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:1985
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:1823
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:1850
#define I3C_MSG_RESTART
RESTART I3C transaction for this message.
Definition i3c.h:408
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:1949
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:2010
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:1223
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:49
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
#define ENOSYS
Function not implemented.
Definition errno.h:82
Real-Time IO device API for moving bytes with low effort.
__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:411
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:417
Structure to keep track of addresses on I3C bus.
Definition addresses.h:58
Payload structure for one CCC transaction.
Definition ccc.h:267
Configuration parameters for I3C hardware to act as controller.
Definition i3c.h:518
struct i3c_config_controller::@222 scl
uint32_t i3c
SCL frequency (in Hz) for I3C transfers.
Definition i3c.h:527
uint8_t supported_hdr
Bit mask of supported HDR modes (0 - 7).
Definition i3c.h:539
bool is_secondary
True if the controller is to be the secondary controller of the bus.
Definition i3c.h:523
uint32_t i2c
SCL frequency (in Hz) for I2C transfers.
Definition i3c.h:530
Custom I3C configuration parameters.
Definition i3c.h:550
void * ptr
Pointer to configuration parameter.
Definition i3c.h:564
uint32_t id
ID of the configuration parameter.
Definition i3c.h:552
uintptr_t val
Value of configuration parameter.
Definition i3c.h:556
Structure for describing attached devices for a controller.
Definition i3c.h:1149
sys_slist_t i3c
Linked list of attached I3C devices.
Definition i3c.h:1162
sys_slist_t i2c
Linked list of attached I2C devices.
Definition i3c.h:1167
struct i3c_addr_slots addr_slots
Address slots:
Definition i3c.h:1156
struct i3c_dev_attached_list::@230 devices
Structure for describing known devices for a controller.
Definition i3c.h:1179
struct i3c_i2c_device_desc *const i2c
Pointer to array of known I2C devices.
Definition i3c.h:1188
const uint8_t num_i3c
Number of I3C devices in array.
Definition i3c.h:1193
struct i3c_device_desc *const i3c
Pointer to array of known I3C devices.
Definition i3c.h:1183
const uint8_t num_i2c
Number of I2C devices in array.
Definition i3c.h:1198
Structure describing a I3C target device.
Definition i3c.h:929
struct i3c_device_desc::@226 data_length
uint8_t maxwr
Maximum Write Speed.
Definition i3c.h:1020
const uint8_t init_dynamic_addr
Initial dynamic address.
Definition i3c.h:964
uint8_t getcap1
I3C v1.1+ GETCAPS1 (I3C_CCC_GETCAPS1_*)
Definition i3c.h:1057
uint8_t getcap2
GETCAPS2 (I3C_CCC_GETCAPS2_*)
Definition i3c.h:1067
uint32_t max_read_turnaround
Maximum Read turnaround time in microseconds.
Definition i3c.h:1023
const uint8_t static_addr
Static address for this target device.
Definition i3c.h:953
uint8_t getcap4
GETCAPS4.
Definition i3c.h:1086
struct i3c_device_desc::@227 getcaps
Describes advanced (Target) capabilities and features.
uint8_t max_ibi
Maximum IBI Payload Size.
Definition i3c.h:1034
i3c_target_ibi_cb_t ibi_cb
In-Band Interrupt (IBI) callback.
Definition i3c.h:1101
uint8_t group_addr
Group address for this target device.
Definition i3c.h:998
uint16_t mwl
Maximum Write Length.
Definition i3c.h:1031
uint8_t getcap3
GETCAPS3 (I3C_CCC_GETCAPS3_*)
Definition i3c.h:1080
uint8_t dynamic_addr
Dynamic Address for this target device used for communication.
Definition i3c.h:987
const struct device *const dev
Device driver instance of the I3C device.
Definition i3c.h:936
sys_snode_t node
Definition i3c.h:930
uint16_t mrl
Maximum Read Length.
Definition i3c.h:1028
const uint64_t pid
Device Provisioned ID.
Definition i3c.h:939
uint8_t maxrd
Maximum Read Speed.
Definition i3c.h:1017
uint8_t gethdrcap
I3C v1.0 HDR Capabilities (I3C_CCC_GETCAPS1_*)
Definition i3c.h:1047
uint8_t bcr
Bus Characteristic Register (BCR)
Definition i3c.h:1005
uint8_t dcr
Device Characteristic Register (DCR)
Definition i3c.h:1013
const bool supports_setaasa
Device support for SETAASA.
Definition i3c.h:972
struct i3c_device_desc::@225 data_speed
const struct device *const bus
I3C bus to which this target device is attached.
Definition i3c.h:933
Structure used for matching I3C devices.
Definition i3c.h:895
const uint64_t pid
Device Provisioned ID.
Definition i3c.h:897
This structure is common to all I3C drivers and is expected to be the first element in the object poi...
Definition i3c.h:1206
struct i3c_dev_list dev_list
I3C/I2C device list struct.
Definition i3c.h:1208
This structure is common to all I3C drivers and is expected to be the first element in the driver's s...
Definition i3c.h:1215
struct i3c_config_controller ctrl_config
Controller Configuration.
Definition i3c.h:1217
struct i3c_dev_attached_list attached_dev
Attached I3C/I2C devices and addresses.
Definition i3c.h:1220
Structure describing a I2C device on I3C bus.
Definition i3c.h:1118
const struct device * bus
I3C bus to which this I2C device is attached.
Definition i3c.h:1122
const uint16_t addr
Static address for this I2C device.
Definition i3c.h:1125
const uint8_t lvr
Legacy Virtual Register (LVR)
Definition i3c.h:1131
sys_snode_t node
Definition i3c.h:1119
Struct for IBI request.
Definition ibi.h:58
Definition i3c.h:2151
const struct device * bus
Definition i3c.h:2152
const struct i3c_device_id dev_id
Definition i3c.h:2153
One I3C Message.
Definition i3c.h:473
uint8_t flags
Flags for this message.
Definition i3c.h:490
uint8_t hdr_mode
HDR mode (I3C_MSG_HDR_MODE*) for transfer if any I3C_MSG_HDR_* is set in flags.
Definition i3c.h:498
uint32_t num_xfer
Total number of bytes transferred.
Definition i3c.h:487
uint8_t * buf
Data buffer in bytes.
Definition i3c.h:475
uint8_t hdr_cmd_code
HDR command code field (7-bit) for HDR-DDR, HDR-TSP and HDR-TSL.
Definition i3c.h:501
uint32_t len
Length of buffer in bytes.
Definition i3c.h:478
Structure describing a device that supports the I3C target API.
Definition target_device.h:102
API that an RTIO IO device should implement.
Definition rtio.h:502
Compute the mempool block index for a given pointer.
Definition rtio.h:492
struct rtio_sqe sqe
Definition rtio.h:493
An IO device with a function table for submitting requests.
Definition rtio.h:517
void * data
Definition rtio.h:522
A submission queue event.
Definition rtio.h:286
const struct rtio_iodev * iodev
Device to operation on.
Definition rtio.h:295
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:396
Misc utilities.