Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
18#include <zephyr/types.h>
19#include <zephyr/device.h>
20
25#include <zephyr/drivers/i2c.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
77#define I3C_BCR_MAX_DATA_SPEED_LIMIT BIT(0)
78
80#define I3C_BCR_IBI_REQUEST_CAPABLE BIT(1)
81
89#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE BIT(2)
90
97#define I3C_BCR_OFFLINE_CAPABLE BIT(3)
98
105#define I3C_BCR_VIRTUAL_TARGET BIT(4)
106
114#define I3C_BCR_ADV_CAPABILITIES BIT(5)
115
117#define I3C_BCR_DEVICE_ROLE_I3C_TARGET 0U
118
120#define I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE 1U
121
123#define I3C_BCR_DEVICE_ROLE_SHIFT 6U
124
126#define I3C_BCR_DEVICE_ROLE_MASK (0x03U << I3C_BCR_DEVICE_ROLE_SHIFT)
127
135#define I3C_BCR_DEVICE_ROLE(bcr) \
136 (((bcr) & I3C_BCR_DEVICE_ROLE_MASK) >> I3C_BCR_DEVICE_ROLE_SHIFT)
137
160#define I3C_LVR_I2C_FM_PLUS_MODE 0
161
163#define I3C_LVR_I2C_FM_MODE 1
164
166#define I3C_LVR_I2C_MODE_SHIFT 4
167
169#define I3C_LVR_I2C_MODE_MASK BIT(4)
170
178#define I3C_LVR_I2C_MODE(lvr) \
179 (((lvr) & I3C_LVR_I2C_MODE_MASK) >> I3C_LVR_I2C_MODE_SHIFT)
180
187#define I3C_LVR_I2C_DEV_IDX_0 0
188
195#define I3C_LVR_I2C_DEV_IDX_1 1
196
203#define I3C_LVR_I2C_DEV_IDX_2 2
204
206#define I3C_LVR_I2C_DEV_IDX_SHIFT 5
207
209#define I3C_LVR_I2C_DEV_IDX_MASK (0x07U << I3C_LVR_I2C_DEV_IDX_SHIFT)
210
218#define I3C_LVR_I2C_DEV_IDX(lvr) \
219 (((lvr) & I3C_LVR_I2C_DEV_IDX_MASK) >> I3C_LVR_I2C_DEV_IDX_SHIFT)
220
229
235
242
249
252};
253
262
265
268};
269
278
281
284
287
290
293};
294
308
311
314
317
320
323
326};
327
344
347
350
353
356
359
362
365
368
371
374};
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
473struct i3c_msg {
476
479
488
491
499};
500
510};
511
521
522 struct {
525
529
537};
538
550
551 union {
554
561 void *ptr;
562 };
563};
564
571struct i3c_device_desc;
572struct i3c_device_id;
574struct i3c_target_config;
575
576__subsystem struct i3c_driver_api {
584 struct i2c_driver_api i2c_api;
585
598 int (*configure)(const struct device *dev,
599 enum i3c_config_type type, void *config);
600
613 int (*config_get)(const struct device *dev,
614 enum i3c_config_type type, void *config);
615
627 int (*recover_bus)(const struct device *dev);
628
642 int (*attach_i3c_device)(const struct device *dev,
643 struct i3c_device_desc *target,
644 uint8_t addr);
645
659 int (*reattach_i3c_device)(const struct device *dev,
660 struct i3c_device_desc *target,
661 uint8_t old_dyn_addr);
662
675 int (*detach_i3c_device)(const struct device *dev,
676 struct i3c_device_desc *target);
677
690 int (*attach_i2c_device)(const struct device *dev,
691 struct i3c_i2c_device_desc *target);
692
705 int (*detach_i2c_device)(const struct device *dev,
706 struct i3c_i2c_device_desc *target);
707
719 int (*do_daa)(const struct device *dev);
720
733 int (*do_ccc)(const struct device *dev,
734 struct i3c_ccc_payload *payload);
735
748 int (*i3c_xfers)(const struct device *dev,
749 struct i3c_device_desc *target,
750 struct i3c_msg *msgs,
751 uint8_t num_msgs);
752
766 struct i3c_device_desc *(*i3c_device_find)(const struct device *dev,
767 const struct i3c_device_id *id);
768
781 int (*ibi_raise)(const struct device *dev,
782 struct i3c_ibi *request);
783
796 int (*ibi_enable)(const struct device *dev,
797 struct i3c_device_desc *target);
798
811 int (*ibi_disable)(const struct device *dev,
812 struct i3c_device_desc *target);
813
829 int (*target_register)(const struct device *dev,
830 struct i3c_target_config *cfg);
831
847 int (*target_unregister)(const struct device *dev,
848 struct i3c_target_config *cfg);
849
865 int (*target_tx_write)(const struct device *dev,
866 uint8_t *buf, uint16_t len);
867};
868
878 const uint64_t pid:48;
879};
880
889#define I3C_DEVICE_ID(pid) \
890 { \
891 .pid = pid \
892 }
893
917 sys_snode_t node;
921 const struct device * const bus;
922
924 const struct device * const dev;
925
927 const uint64_t pid:48;
928
942
953
968
969#if defined(CONFIG_I3C_USE_GROUP_ADDR) || defined(__DOXYGEN__)
978#endif /* CONFIG_I3C_USE_GROUP_ADDR */
979
1010
1018
1019 struct {
1022
1025
1029
1030 struct {
1033
1036
1040
1046 void *controller_priv;
1049#if defined(CONFIG_I3C_USE_IBI) || defined(__DOXYGEN__)
1054#endif /* CONFIG_I3C_USE_IBI */
1055};
1056
1076 sys_snode_t node;
1080 const struct device *bus;
1081
1084
1100
1106 void *controller_priv;
1108};
1109
1126
1127 struct {
1132
1138};
1139
1152 struct i3c_device_desc * const i3c;
1153
1157 struct i3c_i2c_device_desc * const i2c;
1158
1163
1168};
1169
1178};
1179
1187
1190};
1191
1204struct i3c_device_desc *i3c_dev_list_find(const struct i3c_dev_list *dev_list,
1205 const struct i3c_device_id *id);
1206
1220 uint8_t addr);
1221
1235 uint16_t addr);
1236
1251
1304 const struct i3c_dev_list *dev_list,
1305 uint64_t pid, bool must_match,
1306 bool assigned_okay,
1307 struct i3c_device_desc **target,
1308 uint8_t *addr);
1309
1323static inline int i3c_configure(const struct device *dev,
1324 enum i3c_config_type type, void *config)
1325{
1326 const struct i3c_driver_api *api =
1327 (const struct i3c_driver_api *)dev->api;
1328
1329 if (api->configure == NULL) {
1330 return -ENOSYS;
1331 }
1332
1333 return api->configure(dev, type, config);
1334}
1335
1356static inline int i3c_config_get(const struct device *dev,
1357 enum i3c_config_type type, void *config)
1358{
1359 const struct i3c_driver_api *api =
1360 (const struct i3c_driver_api *)dev->api;
1361
1362 if (api->config_get == NULL) {
1363 return -ENOSYS;
1364 }
1365
1366 return api->config_get(dev, type, config);
1367}
1368
1379static inline int i3c_recover_bus(const struct device *dev)
1380{
1381 const struct i3c_driver_api *api =
1382 (const struct i3c_driver_api *)dev->api;
1383
1384 if (api->recover_bus == NULL) {
1385 return -ENOSYS;
1386 }
1387
1388 return api->recover_bus(dev);
1389}
1390
1411
1436int i3c_reattach_i3c_device(struct i3c_device_desc *target, uint8_t old_dyn_addr);
1437
1458
1478
1497
1521static inline int i3c_do_daa(const struct device *dev)
1522{
1523 const struct i3c_driver_api *api =
1524 (const struct i3c_driver_api *)dev->api;
1525
1526 if (api->do_daa == NULL) {
1527 return -ENOSYS;
1528 }
1529
1530 return api->do_daa(dev);
1531}
1532
1546__syscall int i3c_do_ccc(const struct device *dev,
1547 struct i3c_ccc_payload *payload);
1548
1549static inline int z_impl_i3c_do_ccc(const struct device *dev,
1550 struct i3c_ccc_payload *payload)
1551{
1552 const struct i3c_driver_api *api =
1553 (const struct i3c_driver_api *)dev->api;
1554
1555 if (api->do_ccc == NULL) {
1556 return -ENOSYS;
1557 }
1558
1559 return api->do_ccc(dev, payload);
1560}
1561
1593__syscall int i3c_transfer(struct i3c_device_desc *target,
1594 struct i3c_msg *msgs, uint8_t num_msgs);
1595
1596static inline int z_impl_i3c_transfer(struct i3c_device_desc *target,
1597 struct i3c_msg *msgs, uint8_t num_msgs)
1598{
1599 const struct i3c_driver_api *api =
1600 (const struct i3c_driver_api *)target->bus->api;
1601
1602 return api->i3c_xfers(target->bus, target, msgs, num_msgs);
1603}
1604
1621static inline
1623 const struct i3c_device_id *id)
1624{
1625 const struct i3c_driver_api *api =
1626 (const struct i3c_driver_api *)dev->api;
1627
1628 if (api->i3c_device_find == NULL) {
1629 return NULL;
1630 }
1631
1632 return api->i3c_device_find(dev, id);
1633}
1634
1651static inline int i3c_ibi_raise(const struct device *dev,
1652 struct i3c_ibi *request)
1653{
1654 const struct i3c_driver_api *api =
1655 (const struct i3c_driver_api *)dev->api;
1656
1657 if (api->ibi_raise == NULL) {
1658 return -ENOSYS;
1659 }
1660
1661 return api->ibi_raise(dev, request);
1662}
1663
1678static inline int i3c_ibi_enable(struct i3c_device_desc *target)
1679{
1680 const struct i3c_driver_api *api =
1681 (const struct i3c_driver_api *)target->bus->api;
1682
1683 if (api->ibi_enable == NULL) {
1684 return -ENOSYS;
1685 }
1686
1687 return api->ibi_enable(target->bus, target);
1688}
1689
1702static inline int i3c_ibi_disable(struct i3c_device_desc *target)
1703{
1704 const struct i3c_driver_api *api =
1705 (const struct i3c_driver_api *)target->bus->api;
1706
1707 if (api->ibi_disable == NULL) {
1708 return -ENOSYS;
1709 }
1710
1711 return api->ibi_disable(target->bus, target);
1712}
1713
1725static inline int i3c_ibi_has_payload(struct i3c_device_desc *target)
1726{
1727 return (target->bcr & I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE)
1729}
1730
1742static inline int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
1743{
1744 return (target->bcr & I3C_BCR_IBI_REQUEST_CAPABLE)
1746}
1747
1768static inline int i3c_write(struct i3c_device_desc *target,
1769 const uint8_t *buf, uint32_t num_bytes)
1770{
1771 struct i3c_msg msg;
1772
1773 msg.buf = (uint8_t *)buf;
1774 msg.len = num_bytes;
1776
1777 return i3c_transfer(target, &msg, 1);
1778}
1779
1793static inline int i3c_read(struct i3c_device_desc *target,
1794 uint8_t *buf, uint32_t num_bytes)
1795{
1796 struct i3c_msg msg;
1797
1798 msg.buf = buf;
1799 msg.len = num_bytes;
1801
1802 return i3c_transfer(target, &msg, 1);
1803}
1804
1822static inline int i3c_write_read(struct i3c_device_desc *target,
1823 const void *write_buf, size_t num_write,
1824 void *read_buf, size_t num_read)
1825{
1826 struct i3c_msg msg[2];
1827
1828 msg[0].buf = (uint8_t *)write_buf;
1829 msg[0].len = num_write;
1830 msg[0].flags = I3C_MSG_WRITE;
1831
1832 msg[1].buf = (uint8_t *)read_buf;
1833 msg[1].len = num_read;
1835
1836 return i3c_transfer(target, msg, 2);
1837}
1838
1856static inline int i3c_burst_read(struct i3c_device_desc *target,
1857 uint8_t start_addr,
1858 uint8_t *buf,
1859 uint32_t num_bytes)
1860{
1861 return i3c_write_read(target,
1862 &start_addr, sizeof(start_addr),
1863 buf, num_bytes);
1864}
1865
1886static inline int i3c_burst_write(struct i3c_device_desc *target,
1887 uint8_t start_addr,
1888 const uint8_t *buf,
1889 uint32_t num_bytes)
1890{
1891 struct i3c_msg msg[2];
1892
1893 msg[0].buf = &start_addr;
1894 msg[0].len = 1U;
1895 msg[0].flags = I3C_MSG_WRITE;
1896
1897 msg[1].buf = (uint8_t *)buf;
1898 msg[1].len = num_bytes;
1899 msg[1].flags = I3C_MSG_WRITE | I3C_MSG_STOP;
1900
1901 return i3c_transfer(target, msg, 2);
1902}
1903
1918static inline int i3c_reg_read_byte(struct i3c_device_desc *target,
1919 uint8_t reg_addr, uint8_t *value)
1920{
1921 return i3c_write_read(target,
1922 &reg_addr, sizeof(reg_addr),
1923 value, sizeof(*value));
1924}
1925
1943static inline int i3c_reg_write_byte(struct i3c_device_desc *target,
1944 uint8_t reg_addr, uint8_t value)
1945{
1946 uint8_t tx_buf[2] = {reg_addr, value};
1947
1948 return i3c_write(target, tx_buf, 2);
1949}
1950
1969static inline int i3c_reg_update_byte(struct i3c_device_desc *target,
1970 uint8_t reg_addr, uint8_t mask,
1971 uint8_t value)
1972{
1973 uint8_t old_value, new_value;
1974 int rc;
1975
1976 rc = i3c_reg_read_byte(target, reg_addr, &old_value);
1977 if (rc != 0) {
1978 return rc;
1979 }
1980
1981 new_value = (old_value & ~mask) | (value & mask);
1982 if (new_value == old_value) {
1983 return 0;
1984 }
1985
1986 return i3c_reg_write_byte(target, reg_addr, new_value);
1987}
1988
2013void i3c_dump_msgs(const char *name, const struct i3c_msg *msgs,
2014 uint8_t num_msgs, struct i3c_device_desc *target);
2015
2033int i3c_bus_init(const struct device *dev,
2034 const struct i3c_dev_list *i3c_dev_list);
2035
2056
2057/*
2058 * This needs to be after declaration of struct i3c_driver_api,
2059 * or else compiler complains about undefined type inside
2060 * the static inline API wrappers.
2061 */
2063
2064#ifdef __cplusplus
2065}
2066#endif
2067
2072#include <syscalls/i3c.h>
2073
2074#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_H_ */
Public APIs for the I2C drivers.
static int i3c_ibi_disable(struct i3c_device_desc *target)
Disable IBI of a target device.
Definition: i3c.h:1702
static int i3c_ibi_has_payload(struct i3c_device_desc *target)
Check if target's IBI has payload.
Definition: i3c.h:1725
static int i3c_ibi_raise(const struct device *dev, struct i3c_ibi *request)
Raise an In-Band Interrupt (IBI).
Definition: i3c.h:1651
static int i3c_device_is_ibi_capable(struct i3c_device_desc *target)
Check if device is IBI capable.
Definition: i3c.h:1742
static int i3c_ibi_enable(struct i3c_device_desc *target)
Enable IBI of a target device.
Definition: i3c.h:1678
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:151
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:80
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:1622
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:1323
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.
i3c_config_type
Type of configuration being passed to configure function.
Definition: i3c.h:506
int i3c_attach_i2c_device(struct i3c_i2c_device_desc *target)
Attach an I2C device.
int i3c_determine_default_addr(struct i3c_device_desc *target, uint8_t *addr)
Helper function to find the default address an i3c device is attached with.
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:1379
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:1356
int i3c_detach_i2c_device(struct i3c_i2c_device_desc *target)
Detach I2C Device.
struct i3c_i2c_device_desc * i3c_dev_list_i2c_addr_find(struct i3c_dev_attached_list *dev_list, uint16_t addr)
Find a I2C target device descriptor by address.
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.
struct i3c_device_desc * i3c_dev_list_i3c_addr_find(struct i3c_dev_attached_list *dev_list, uint8_t addr)
Find a I3C target device descriptor by dynamic address.
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:1521
#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE
IBI Payload bit.
Definition: i3c.h:89
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
@ 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:508
@ I3C_CONFIG_CUSTOM
Definition: i3c.h:509
@ I3C_CONFIG_CONTROLLER
Definition: i3c.h:507
@ 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:1822
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:1856
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:1969
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:1918
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:1768
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:1793
#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:1886
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:1943
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:83
__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:387
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:393
Structure to keep track of addresses on I3C bus.
Definition: addresses.h:57
Payload structure for one CCC transaction.
Definition: ccc.h:266
Configuration parameters for I3C hardware to act as controller.
Definition: i3c.h:515
uint32_t i3c
SCL frequency (in Hz) for I3C transfers.
Definition: i3c.h:524
uint8_t supported_hdr
Bit mask of supported HDR modes (0 - 7).
Definition: i3c.h:536
bool is_secondary
True if the controller is to be the secondary controller of the bus.
Definition: i3c.h:520
uint32_t i2c
SCL frequency (in Hz) for I2C transfers.
Definition: i3c.h:527
struct i3c_config_controller::@159 scl
Custom I3C configuration parameters.
Definition: i3c.h:547
void * ptr
Pointer to configuration parameter.
Definition: i3c.h:561
uint32_t id
ID of the configuration parameter.
Definition: i3c.h:549
uintptr_t val
Value of configuration parameter.
Definition: i3c.h:553
Structure for describing attached devices for a controller.
Definition: i3c.h:1118
struct i3c_dev_attached_list::@164 devices
sys_slist_t i3c
Linked list of attached I3C devices.
Definition: i3c.h:1131
sys_slist_t i2c
Linked list of attached I2C devices.
Definition: i3c.h:1136
struct i3c_addr_slots addr_slots
Address slots:
Definition: i3c.h:1125
Structure for describing known devices for a controller.
Definition: i3c.h:1148
struct i3c_i2c_device_desc *const i2c
Pointer to array of known I2C devices.
Definition: i3c.h:1157
const uint8_t num_i3c
Number of I3C devices in array.
Definition: i3c.h:1162
struct i3c_device_desc *const i3c
Pointer to array of known I3C devices.
Definition: i3c.h:1152
const uint8_t num_i2c
Number of I2C devices in array.
Definition: i3c.h:1167
Structure describing a I3C target device.
Definition: i3c.h:911
uint8_t maxwr
Maximum Write Speed.
Definition: i3c.h:1024
const uint8_t init_dynamic_addr
Initial dynamic address.
Definition: i3c.h:952
uint32_t max_read_turnaround
Maximum Read turnaround time in microseconds.
Definition: i3c.h:1027
const uint8_t static_addr
Static address for this target device.
Definition: i3c.h:941
uint8_t max_ibi
Maximum IBI Payload Size.
Definition: i3c.h:1038
i3c_target_ibi_cb_t ibi_cb
Private data by the controller to aid in transactions.
Definition: i3c.h:1053
uint8_t group_addr
Group address for this target device.
Definition: i3c.h:977
uint16_t mwl
Maximum Write Length.
Definition: i3c.h:1035
struct i3c_device_desc::@162 data_speed
uint8_t dynamic_addr
Dynamic Address for this target device used for communication.
Definition: i3c.h:967
const struct device *const dev
Device driver instance of the I3C device.
Definition: i3c.h:924
struct i3c_device_desc::@163 data_length
uint16_t mrl
Maximum Read Length.
Definition: i3c.h:1032
const uint64_t pid
Device Provisioned ID.
Definition: i3c.h:927
uint8_t maxrd
Maximum Read Speed.
Definition: i3c.h:1021
uint8_t bcr
Bus Characteristic Register (BCR)
Definition: i3c.h:1009
uint8_t dcr
Device Characteristic Register (DCR)
Definition: i3c.h:1017
const struct device *const bus
Used to attach this node onto a linked list.
Definition: i3c.h:921
Structure used for matching I3C devices.
Definition: i3c.h:876
const uint64_t pid
Device Provisioned ID.
Definition: i3c.h:878
This structure is common to all I3C drivers and is expected to be the first element in the object poi...
Definition: i3c.h:1175
struct i3c_dev_list dev_list
I3C/I2C device list struct.
Definition: i3c.h:1177
This structure is common to all I3C drivers and is expected to be the first element in the driver's s...
Definition: i3c.h:1184
struct i3c_config_controller ctrl_config
Controller Configuration.
Definition: i3c.h:1186
struct i3c_dev_attached_list attached_dev
Attached I3C/I2C devices and addresses.
Definition: i3c.h:1189
Structure describing a I2C device on I3C bus.
Definition: i3c.h:1070
const struct device * bus
Used to attach this node onto a linked list.
Definition: i3c.h:1080
const uint16_t addr
Static address for this I2C device.
Definition: i3c.h:1083
const uint8_t lvr
Legacy Virtual Register (LVR)
Definition: i3c.h:1099
Struct for IBI request.
Definition: ibi.h:57
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
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:92