Zephyr API Documentation 4.0.0-rc2
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
33#ifdef __cplusplus
34extern "C" {
35#endif
36
84#define I3C_BCR_MAX_DATA_SPEED_LIMIT BIT(0)
85
87#define I3C_BCR_IBI_REQUEST_CAPABLE BIT(1)
88
96#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE BIT(2)
97
104#define I3C_BCR_OFFLINE_CAPABLE BIT(3)
105
112#define I3C_BCR_VIRTUAL_TARGET BIT(4)
113
121#define I3C_BCR_ADV_CAPABILITIES BIT(5)
122
124#define I3C_BCR_DEVICE_ROLE_I3C_TARGET 0U
125
127#define I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE 1U
128
130#define I3C_BCR_DEVICE_ROLE_MASK GENMASK(7U, 6U)
131
139#define I3C_BCR_DEVICE_ROLE(bcr) \
140 FIELD_GET(I3C_BCR_DEVICE_ROLE_MASK, (bcr))
141
165#define I3C_LVR_I2C_FM_PLUS_MODE 0
166
168#define I3C_LVR_I2C_FM_MODE 1
169
171#define I3C_LVR_I2C_MODE_MASK BIT(4)
172
180#define I3C_LVR_I2C_MODE(lvr) \
181 FIELD_GET(I3C_LVR_I2C_MODE_MASK, (lvr))
182
189#define I3C_LVR_I2C_DEV_IDX_0 0
190
197#define I3C_LVR_I2C_DEV_IDX_1 1
198
205#define I3C_LVR_I2C_DEV_IDX_2 2
206
208#define I3C_LVR_I2C_DEV_IDX_MASK GENMASK(7U, 5U)
209
217#define I3C_LVR_I2C_DEV_IDX(lvr) \
218 FIELD_GET(I3C_LVR_I2C_DEV_IDX_MASK, (lvr))
219
252
268
293
326
374
381/*
382 * I3C_MSG_* are I3C Message flags.
383 */
384
386#define I3C_MSG_WRITE (0U << 0U)
387
389#define I3C_MSG_READ BIT(0)
390
392#define I3C_MSG_RW_MASK BIT(0)
396#define I3C_MSG_STOP BIT(1)
397
407#define I3C_MSG_RESTART BIT(2)
408
410#define I3C_MSG_HDR BIT(3)
411
413#define I3C_MSG_NBCH BIT(4)
414
416#define I3C_MSG_HDR_MODE0 BIT(0)
417
419#define I3C_MSG_HDR_MODE1 BIT(1)
420
422#define I3C_MSG_HDR_MODE2 BIT(2)
423
425#define I3C_MSG_HDR_MODE3 BIT(3)
426
428#define I3C_MSG_HDR_MODE4 BIT(4)
429
431#define I3C_MSG_HDR_MODE5 BIT(5)
432
434#define I3C_MSG_HDR_MODE6 BIT(6)
435
437#define I3C_MSG_HDR_MODE7 BIT(7)
438
440#define I3C_MSG_HDR_DDR I3C_MSG_HDR_MODE0
441
443#define I3C_MSG_HDR_TSP I3C_MSG_HDR_MODE1
444
446#define I3C_MSG_HDR_TSL I3C_MSG_HDR_MODE2
447
449#define I3C_MSG_HDR_BT I3C_MSG_HDR_MODE3
450
502
513
540
552
553 union {
556
563 void *ptr;
564 };
565};
566
573struct i3c_device_desc;
574struct i3c_device_id;
576struct i3c_target_config;
577
578__subsystem struct i3c_driver_api {
588 struct i2c_driver_api i2c_api;
589
602 int (*configure)(const struct device *dev,
603 enum i3c_config_type type, void *config);
604
617 int (*config_get)(const struct device *dev,
618 enum i3c_config_type type, void *config);
619
631 int (*recover_bus)(const struct device *dev);
632
645 int (*attach_i3c_device)(const struct device *dev,
646 struct i3c_device_desc *target);
647
661 int (*reattach_i3c_device)(const struct device *dev,
662 struct i3c_device_desc *target,
663 uint8_t old_dyn_addr);
664
677 int (*detach_i3c_device)(const struct device *dev,
678 struct i3c_device_desc *target);
679
692 int (*attach_i2c_device)(const struct device *dev,
693 struct i3c_i2c_device_desc *target);
694
707 int (*detach_i2c_device)(const struct device *dev,
708 struct i3c_i2c_device_desc *target);
709
721 int (*do_daa)(const struct device *dev);
722
735 int (*do_ccc)(const struct device *dev,
736 struct i3c_ccc_payload *payload);
737
750 int (*i3c_xfers)(const struct device *dev,
751 struct i3c_device_desc *target,
752 struct i3c_msg *msgs,
753 uint8_t num_msgs);
754
768 struct i3c_device_desc *(*i3c_device_find)(const struct device *dev,
769 const struct i3c_device_id *id);
770
783 int (*ibi_raise)(const struct device *dev,
784 struct i3c_ibi *request);
785
798 int (*ibi_enable)(const struct device *dev,
799 struct i3c_device_desc *target);
800
813 int (*ibi_disable)(const struct device *dev,
814 struct i3c_device_desc *target);
815
831 int (*target_register)(const struct device *dev,
832 struct i3c_target_config *cfg);
833
849 int (*target_unregister)(const struct device *dev,
850 struct i3c_target_config *cfg);
851
868 int (*target_tx_write)(const struct device *dev,
869 uint8_t *buf, uint16_t len, uint8_t hdr_mode);
870};
871
881 const uint64_t pid:48;
882};
883
892#define I3C_DEVICE_ID(pid) \
893 { \
894 .pid = pid \
895 }
896
915
917 const struct device * const bus;
918
920 const struct device * const dev;
921
923 const uint64_t pid:48;
924
938
949
957
972
973#if defined(CONFIG_I3C_USE_GROUP_ADDR) || defined(__DOXYGEN__)
983#endif /* CONFIG_I3C_USE_GROUP_ADDR */
984
990
998
999 struct {
1002
1005
1009
1010 struct {
1013
1016
1020
1022 struct {
1023 union {
1032
1042 };
1043
1052
1065
1072
1077 void *controller_priv;
1080#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
1086#endif /* CONFIG_I3C_USE_IBI */
1087};
1088
1104
1106 const struct device *bus;
1107
1110
1116
1121 void *controller_priv;
1123};
1124
1154
1167 struct i3c_device_desc * const i3c;
1168
1172 struct i3c_i2c_device_desc * const i2c;
1173
1178
1183};
1184
1194
1206
1214#define I3C_BUS_FOR_EACH_I3CDEV(bus, desc) \
1215 SYS_SLIST_FOR_EACH_CONTAINER( \
1216 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, node)
1217
1225#define I3C_BUS_FOR_EACH_I2CDEV(bus, desc) \
1226 SYS_SLIST_FOR_EACH_CONTAINER( \
1227 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, node)
1228
1241struct i3c_device_desc *i3c_dev_list_find(const struct i3c_dev_list *dev_list,
1242 const struct i3c_device_id *id);
1243
1257 uint8_t addr);
1258
1272 uint16_t addr);
1273
1326 const struct i3c_dev_list *dev_list,
1327 uint64_t pid, bool must_match,
1328 bool assigned_okay,
1329 struct i3c_device_desc **target,
1330 uint8_t *addr);
1331
1345static inline int i3c_configure(const struct device *dev,
1346 enum i3c_config_type type, void *config)
1347{
1348 const struct i3c_driver_api *api =
1349 (const struct i3c_driver_api *)dev->api;
1350
1351 if (api->configure == NULL) {
1352 return -ENOSYS;
1353 }
1354
1355 return api->configure(dev, type, config);
1356}
1357
1378static inline int i3c_config_get(const struct device *dev,
1379 enum i3c_config_type type, void *config)
1380{
1381 const struct i3c_driver_api *api =
1382 (const struct i3c_driver_api *)dev->api;
1383
1384 if (api->config_get == NULL) {
1385 return -ENOSYS;
1386 }
1387
1388 return api->config_get(dev, type, config);
1389}
1390
1401static inline int i3c_recover_bus(const struct device *dev)
1402{
1403 const struct i3c_driver_api *api =
1404 (const struct i3c_driver_api *)dev->api;
1405
1406 if (api->recover_bus == NULL) {
1407 return -ENOSYS;
1408 }
1409
1410 return api->recover_bus(dev);
1411}
1412
1433
1458int i3c_reattach_i3c_device(struct i3c_device_desc *target, uint8_t old_dyn_addr);
1459
1480
1500
1519
1543static inline int i3c_do_daa(const struct device *dev)
1544{
1545 const struct i3c_driver_api *api =
1546 (const struct i3c_driver_api *)dev->api;
1547
1548 if (api->do_daa == NULL) {
1549 return -ENOSYS;
1550 }
1551
1552 return api->do_daa(dev);
1553}
1554
1568__syscall int i3c_do_ccc(const struct device *dev,
1569 struct i3c_ccc_payload *payload);
1570
1571static inline int z_impl_i3c_do_ccc(const struct device *dev,
1572 struct i3c_ccc_payload *payload)
1573{
1574 const struct i3c_driver_api *api =
1575 (const struct i3c_driver_api *)dev->api;
1576
1577 if (api->do_ccc == NULL) {
1578 return -ENOSYS;
1579 }
1580
1581 return api->do_ccc(dev, payload);
1582}
1583
1615__syscall int i3c_transfer(struct i3c_device_desc *target,
1616 struct i3c_msg *msgs, uint8_t num_msgs);
1617
1618static inline int z_impl_i3c_transfer(struct i3c_device_desc *target,
1619 struct i3c_msg *msgs, uint8_t num_msgs)
1620{
1621 const struct i3c_driver_api *api =
1622 (const struct i3c_driver_api *)target->bus->api;
1623
1624 return api->i3c_xfers(target->bus, target, msgs, num_msgs);
1625}
1626
1643static inline
1645 const struct i3c_device_id *id)
1646{
1647 const struct i3c_driver_api *api =
1648 (const struct i3c_driver_api *)dev->api;
1649
1650 if (api->i3c_device_find == NULL) {
1651 return NULL;
1652 }
1653
1654 return api->i3c_device_find(dev, id);
1655}
1656
1673static inline int i3c_ibi_raise(const struct device *dev,
1674 struct i3c_ibi *request)
1675{
1676 const struct i3c_driver_api *api =
1677 (const struct i3c_driver_api *)dev->api;
1678
1679 if (api->ibi_raise == NULL) {
1680 return -ENOSYS;
1681 }
1682
1683 return api->ibi_raise(dev, request);
1684}
1685
1700static inline int i3c_ibi_enable(struct i3c_device_desc *target)
1701{
1702 const struct i3c_driver_api *api =
1703 (const struct i3c_driver_api *)target->bus->api;
1704
1705 if (api->ibi_enable == NULL) {
1706 return -ENOSYS;
1707 }
1708
1709 return api->ibi_enable(target->bus, target);
1710}
1711
1724static inline int i3c_ibi_disable(struct i3c_device_desc *target)
1725{
1726 const struct i3c_driver_api *api =
1727 (const struct i3c_driver_api *)target->bus->api;
1728
1729 if (api->ibi_disable == NULL) {
1730 return -ENOSYS;
1731 }
1732
1733 return api->ibi_disable(target->bus, target);
1734}
1735
1747static inline int i3c_ibi_has_payload(struct i3c_device_desc *target)
1748{
1749 return (target->bcr & I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE)
1751}
1752
1764static inline int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
1765{
1766 return (target->bcr & I3C_BCR_IBI_REQUEST_CAPABLE)
1768}
1769
1781static inline int i3c_device_is_controller_capable(struct i3c_device_desc *target)
1782{
1783 return I3C_BCR_DEVICE_ROLE(target->bcr)
1785}
1786
1807static inline int i3c_write(struct i3c_device_desc *target,
1808 const uint8_t *buf, uint32_t num_bytes)
1809{
1810 struct i3c_msg msg;
1811
1812 msg.buf = (uint8_t *)buf;
1813 msg.len = num_bytes;
1815 msg.hdr_mode = 0;
1816 msg.hdr_cmd_code = 0;
1817
1818 return i3c_transfer(target, &msg, 1);
1819}
1820
1834static inline int i3c_read(struct i3c_device_desc *target,
1835 uint8_t *buf, uint32_t num_bytes)
1836{
1837 struct i3c_msg msg;
1838
1839 msg.buf = buf;
1840 msg.len = num_bytes;
1842 msg.hdr_mode = 0;
1843 msg.hdr_cmd_code = 0;
1844
1845 return i3c_transfer(target, &msg, 1);
1846}
1847
1865static inline int i3c_write_read(struct i3c_device_desc *target,
1866 const void *write_buf, size_t num_write,
1867 void *read_buf, size_t num_read)
1868{
1869 struct i3c_msg msg[2];
1870
1871 msg[0].buf = (uint8_t *)write_buf;
1872 msg[0].len = num_write;
1873 msg[0].flags = I3C_MSG_WRITE;
1874 msg[0].hdr_mode = 0;
1875 msg[0].hdr_cmd_code = 0;
1876
1877 msg[1].buf = (uint8_t *)read_buf;
1878 msg[1].len = num_read;
1880 msg[1].hdr_mode = 0;
1881 msg[1].hdr_cmd_code = 0;
1882
1883 return i3c_transfer(target, msg, 2);
1884}
1885
1903static inline int i3c_burst_read(struct i3c_device_desc *target,
1904 uint8_t start_addr,
1905 uint8_t *buf,
1906 uint32_t num_bytes)
1907{
1908 return i3c_write_read(target,
1909 &start_addr, sizeof(start_addr),
1910 buf, num_bytes);
1911}
1912
1933static inline int i3c_burst_write(struct i3c_device_desc *target,
1934 uint8_t start_addr,
1935 const uint8_t *buf,
1936 uint32_t num_bytes)
1937{
1938 struct i3c_msg msg[2];
1939
1940 msg[0].buf = &start_addr;
1941 msg[0].len = 1U;
1942 msg[0].flags = I3C_MSG_WRITE;
1943 msg[0].hdr_mode = 0;
1944 msg[0].hdr_cmd_code = 0;
1945
1946 msg[1].buf = (uint8_t *)buf;
1947 msg[1].len = num_bytes;
1948 msg[1].flags = I3C_MSG_WRITE | I3C_MSG_STOP;
1949 msg[1].hdr_mode = 0;
1950 msg[1].hdr_cmd_code = 0;
1951
1952 return i3c_transfer(target, msg, 2);
1953}
1954
1969static inline int i3c_reg_read_byte(struct i3c_device_desc *target,
1970 uint8_t reg_addr, uint8_t *value)
1971{
1972 return i3c_write_read(target,
1973 &reg_addr, sizeof(reg_addr),
1974 value, sizeof(*value));
1975}
1976
1994static inline int i3c_reg_write_byte(struct i3c_device_desc *target,
1995 uint8_t reg_addr, uint8_t value)
1996{
1997 uint8_t tx_buf[2] = {reg_addr, value};
1998
1999 return i3c_write(target, tx_buf, 2);
2000}
2001
2020static inline int i3c_reg_update_byte(struct i3c_device_desc *target,
2021 uint8_t reg_addr, uint8_t mask,
2022 uint8_t value)
2023{
2024 uint8_t old_value, new_value;
2025 int rc;
2026
2027 rc = i3c_reg_read_byte(target, reg_addr, &old_value);
2028 if (rc != 0) {
2029 return rc;
2030 }
2031
2032 new_value = (old_value & ~mask) | (value & mask);
2033 if (new_value == old_value) {
2034 return 0;
2035 }
2036
2037 return i3c_reg_write_byte(target, reg_addr, new_value);
2038}
2039
2064void i3c_dump_msgs(const char *name, const struct i3c_msg *msgs,
2065 uint8_t num_msgs, struct i3c_device_desc *target);
2066
2084int i3c_bus_init(const struct device *dev,
2085 const struct i3c_dev_list *i3c_dev_list);
2086
2107
2118bool i3c_bus_has_sec_controller(const struct device *dev);
2119
2131int i3c_bus_deftgts(const struct device *dev);
2132
2133/*
2134 * This needs to be after declaration of struct i3c_driver_api,
2135 * or else compiler complains about undefined type inside
2136 * the static inline API wrappers.
2137 */
2139
2140/*
2141 * Include High-Data-Rate (HDR) inline helper functions
2142 */
2144
2145#ifdef __cplusplus
2146}
2147#endif
2148
2153#include <zephyr/syscalls/i3c.h>
2154
2155#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_H_ */
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:1724
static int i3c_ibi_has_payload(struct i3c_device_desc *target)
Check if target's IBI has payload.
Definition i3c.h:1747
static int i3c_ibi_raise(const struct device *dev, struct i3c_ibi *request)
Raise an In-Band Interrupt (IBI).
Definition i3c.h:1673
static int i3c_device_is_controller_capable(struct i3c_device_desc *target)
Check if the target is controller capable.
Definition i3c.h:1781
static int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
Check if device is IBI capable.
Definition i3c.h:1764
static int i3c_ibi_enable(struct i3c_device_desc *target)
Enable IBI of a target device.
Definition i3c.h:1700
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:87
#define I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE
Device Role - I3C Controller Capable.
Definition i3c.h:127
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:1644
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:337
static int i3c_configure(const struct device *dev, enum i3c_config_type type, void *config)
Configure the I3C hardware.
Definition i3c.h:1345
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.
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:508
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:258
int i3c_detach_i3c_device(struct i3c_device_desc *target)
Detach I3C Device.
i3c_bus_mode
I3C bus mode.
Definition i3c.h:225
static int i3c_recover_bus(const struct device *dev)
Attempt bus recovery on the I3C bus.
Definition i3c.h:1401
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:1378
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:139
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:304
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.
static int i3c_do_daa(const struct device *dev)
Perform Dynamic Address Assignment on the I3C bus.
Definition i3c.h:1543
#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE
IBI Payload bit.
Definition i3c.h:96
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:274
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:366
@ I3C_ERROR_TE6
Monitoring Error.
Definition i3c.h:360
@ I3C_ERROR_TE4
0x7E/R missing after RESTART during Dynamic Address Arbitration
Definition i3c.h:354
@ I3C_ERROR_TE3
Assigned Address during Dynamic Address Arbitration.
Definition i3c.h:351
@ I3C_ERROR_TE_NONE
No error (not official error code)
Definition i3c.h:369
@ I3C_ERROR_TE_MAX
Definition i3c.h:371
@ I3C_ERROR_TE1
CCC Code.
Definition i3c.h:345
@ I3C_ERROR_TE5
Transaction after detecting CCC.
Definition i3c.h:357
@ I3C_ERROR_DBR
Dead Bus Recovery.
Definition i3c.h:363
@ I3C_ERROR_TE2
Write Data.
Definition i3c.h:348
@ I3C_ERROR_TE_INVALID
Definition i3c.h:372
@ I3C_ERROR_TE0
Invalid Broadcast Address or Dynamic Address after DA assignment.
Definition i3c.h:342
@ I3C_CONFIG_TARGET
Definition i3c.h:510
@ I3C_CONFIG_CUSTOM
Definition i3c.h:511
@ I3C_CONFIG_CONTROLLER
Definition i3c.h:509
@ I3C_I2C_SPEED_INVALID
Definition i3c.h:266
@ I3C_I2C_SPEED_MAX
Definition i3c.h:265
@ I3C_I2C_SPEED_FMPLUS
I2C FM+ mode.
Definition i3c.h:263
@ I3C_I2C_SPEED_FM
I2C FM mode.
Definition i3c.h:260
@ I3C_BUS_MODE_INVALID
Definition i3c.h:250
@ I3C_BUS_MODE_PURE
Only I3C devices are on the bus.
Definition i3c.h:227
@ I3C_BUS_MODE_MIXED_FAST
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:233
@ I3C_BUS_MODE_MAX
Definition i3c.h:249
@ I3C_BUS_MODE_MIXED_LIMITED
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:240
@ I3C_BUS_MODE_MIXED_SLOW
Both I3C and legacy I2C devices are on the bus.
Definition i3c.h:247
@ I3C_ERROR_CE0
Transaction after sending CCC.
Definition i3c.h:306
@ I3C_ERROR_CE2
No response to broadcast address (0x7E)
Definition i3c.h:312
@ I3C_ERROR_CE_INVALID
Definition i3c.h:324
@ I3C_ERROR_CE_MAX
Definition i3c.h:323
@ I3C_ERROR_CE_UNKNOWN
Unknown error (not official error code)
Definition i3c.h:318
@ I3C_ERROR_CE3
Failed Controller Handoff.
Definition i3c.h:315
@ I3C_ERROR_CE1
Monitoring Error.
Definition i3c.h:309
@ I3C_ERROR_CE_NONE
No error (not official error code)
Definition i3c.h:321
@ I3C_DATA_RATE_MAX
Definition i3c.h:290
@ I3C_DATA_RATE_INVALID
Definition i3c.h:291
@ I3C_DATA_RATE_HDR_TSP
High Data Rate - Ternary Symbol for Pure Bus.
Definition i3c.h:285
@ I3C_DATA_RATE_HDR_DDR
High Data Rate - Double Data Rate messaging.
Definition i3c.h:279
@ I3C_DATA_RATE_SDR
Single Data Rate messaging.
Definition i3c.h:276
@ I3C_DATA_RATE_HDR_TSL
High Data Rate - Ternary Symbol Legacy-inclusive-Bus.
Definition i3c.h:282
@ I3C_DATA_RATE_HDR_BT
High Data Rate - Bulk Transport.
Definition i3c.h:288
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:396
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:1865
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:1903
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:2020
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:389
#define I3C_MSG_WRITE
Write message to I3C bus.
Definition i3c.h:386
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:1969
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:1807
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:1834
#define I3C_MSG_RESTART
RESTART I3C transaction for this message.
Definition i3c.h:407
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:1933
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:1994
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
__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:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418
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:517
struct i3c_config_controller::@220 scl
uint32_t i3c
SCL frequency (in Hz) for I3C transfers.
Definition i3c.h:526
uint8_t supported_hdr
Bit mask of supported HDR modes (0 - 7).
Definition i3c.h:538
bool is_secondary
True if the controller is to be the secondary controller of the bus.
Definition i3c.h:522
uint32_t i2c
SCL frequency (in Hz) for I2C transfers.
Definition i3c.h:529
Custom I3C configuration parameters.
Definition i3c.h:549
void * ptr
Pointer to configuration parameter.
Definition i3c.h:563
uint32_t id
ID of the configuration parameter.
Definition i3c.h:551
uintptr_t val
Value of configuration parameter.
Definition i3c.h:555
Structure for describing attached devices for a controller.
Definition i3c.h:1133
sys_slist_t i3c
Linked list of attached I3C devices.
Definition i3c.h:1146
struct i3c_dev_attached_list::@228 devices
sys_slist_t i2c
Linked list of attached I2C devices.
Definition i3c.h:1151
struct i3c_addr_slots addr_slots
Address slots:
Definition i3c.h:1140
Structure for describing known devices for a controller.
Definition i3c.h:1163
struct i3c_i2c_device_desc *const i2c
Pointer to array of known I2C devices.
Definition i3c.h:1172
const uint8_t num_i3c
Number of I3C devices in array.
Definition i3c.h:1177
struct i3c_device_desc *const i3c
Pointer to array of known I3C devices.
Definition i3c.h:1167
const uint8_t num_i2c
Number of I2C devices in array.
Definition i3c.h:1182
Structure describing a I3C target device.
Definition i3c.h:913
uint8_t maxwr
Maximum Write Speed.
Definition i3c.h:1004
const uint8_t init_dynamic_addr
Initial dynamic address.
Definition i3c.h:948
uint8_t getcap1
I3C v1.1+ GETCAPS1 (I3C_CCC_GETCAPS1_*)
Definition i3c.h:1041
uint8_t getcap2
GETCAPS2 (I3C_CCC_GETCAPS2_*)
Definition i3c.h:1051
uint32_t max_read_turnaround
Maximum Read turnaround time in microseconds.
Definition i3c.h:1007
const uint8_t static_addr
Static address for this target device.
Definition i3c.h:937
uint8_t getcap4
GETCAPS4.
Definition i3c.h:1070
uint8_t max_ibi
Maximum IBI Payload Size.
Definition i3c.h:1018
i3c_target_ibi_cb_t ibi_cb
In-Band Interrupt (IBI) callback.
Definition i3c.h:1085
uint8_t group_addr
Group address for this target device.
Definition i3c.h:982
uint16_t mwl
Maximum Write Length.
Definition i3c.h:1015
uint8_t getcap3
GETCAPS3 (I3C_CCC_GETCAPS3_*)
Definition i3c.h:1064
struct i3c_device_desc::@225 getcaps
Describes advanced (Target) capabilities and features.
uint8_t dynamic_addr
Dynamic Address for this target device used for communication.
Definition i3c.h:971
const struct device *const dev
Device driver instance of the I3C device.
Definition i3c.h:920
sys_snode_t node
Definition i3c.h:914
uint16_t mrl
Maximum Read Length.
Definition i3c.h:1012
const uint64_t pid
Device Provisioned ID.
Definition i3c.h:923
struct i3c_device_desc::@223 data_speed
uint8_t maxrd
Maximum Read Speed.
Definition i3c.h:1001
struct i3c_device_desc::@224 data_length
uint8_t gethdrcap
I3C v1.0 HDR Capabilities (I3C_CCC_GETCAPS1_*)
Definition i3c.h:1031
uint8_t bcr
Bus Characteristic Register (BCR)
Definition i3c.h:989
uint8_t dcr
Device Characteristic Register (DCR)
Definition i3c.h:997
const bool supports_setaasa
Device support for SETAASA.
Definition i3c.h:956
const struct device *const bus
I3C bus to which this target device is attached.
Definition i3c.h:917
Structure used for matching I3C devices.
Definition i3c.h:879
const uint64_t pid
Device Provisioned ID.
Definition i3c.h:881
This structure is common to all I3C drivers and is expected to be the first element in the object poi...
Definition i3c.h:1190
struct i3c_dev_list dev_list
I3C/I2C device list struct.
Definition i3c.h:1192
This structure is common to all I3C drivers and is expected to be the first element in the driver's s...
Definition i3c.h:1199
struct i3c_config_controller ctrl_config
Controller Configuration.
Definition i3c.h:1201
struct i3c_dev_attached_list attached_dev
Attached I3C/I2C devices and addresses.
Definition i3c.h:1204
Structure describing a I2C device on I3C bus.
Definition i3c.h:1102
const struct device * bus
I3C bus to which this I2C device is attached.
Definition i3c.h:1106
const uint16_t addr
Static address for this I2C device.
Definition i3c.h:1109
const uint8_t lvr
Legacy Virtual Register (LVR)
Definition i3c.h:1115
sys_snode_t node
Definition i3c.h:1103
Struct for IBI request.
Definition ibi.h:58
One I3C Message.
Definition i3c.h:472
uint8_t flags
Flags for this message.
Definition i3c.h:489
uint8_t hdr_mode
HDR mode (I3C_MSG_HDR_MODE*) for transfer if any I3C_MSG_HDR_* is set in flags.
Definition i3c.h:497
uint32_t num_xfer
Total number of bytes transferred.
Definition i3c.h:486
uint8_t * buf
Data buffer in bytes.
Definition i3c.h:474
uint8_t hdr_cmd_code
HDR command code field (7-bit) for HDR-DDR, HDR-TSP and HDR-TSL.
Definition i3c.h:500
uint32_t len
Length of buffer in bytes.
Definition i3c.h:477
Structure describing a device that supports the I3C target API.
Definition target_device.h:102
Misc utilities.