Zephyr Project API  3.2.0
A Scalable Open Source RTOS
i3c.h File Reference

Go to the source code of this file.

Data Structures

struct  i3c_msg
 One I3C Message. More...
 
struct  i3c_config_controller
 Configuration parameters for I3C hardware to act as controller. More...
 
struct  i3c_config_custom
 Custom I3C configuration parameters. More...
 
struct  i3c_device_id
 Structure used for matching I3C devices. More...
 
struct  i3c_device_desc
 Structure describing a I3C target device. More...
 
struct  i3c_i2c_device_desc
 Structure describing a I2C device on I3C bus. More...
 
struct  i3c_dev_list
 Structure for describing attached devices for a controller. More...
 

Macros

#define I3C_BCR_MAX_DATA_SPEED_LIMIT   BIT(0)
 
#define I3C_BCR_IBI_REQUEST_CAPABLE   BIT(1)
 
#define I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE   BIT(2)
 
#define I3C_BCR_OFFLINE_CAPABLE   BIT(3)
 
#define I3C_BCR_VIRTUAL_TARGET   BIT(4)
 
#define I3C_BCR_ADV_CAPABILITIES   BIT(5)
 
#define I3C_BCR_DEVICE_ROLE_I3C_TARGET   0U
 
#define I3C_BCR_DEVICE_ROLE_I3C_CONTROLLER_CAPABLE   1U
 
#define I3C_BCR_DEVICE_ROLE_SHIFT   6U
 
#define I3C_BCR_DEVICE_ROLE_MASK   (0x03U << I3C_BCR_DEVICE_ROLE_SHIFT)
 
#define I3C_BCR_DEVICE_ROLE(bcr)    (((bcr) & I3C_BCR_DEVICE_ROLE_MASK) >> I3C_BCR_DEVICE_ROLE_SHIFT)
 
#define I3C_DCR_I2C_FM_PLUS_MODE   0
 
#define I3C_DCR_I2C_FM_MODE   1
 
#define I3C_DCR_I2C_MODE_SHIFT   4
 
#define I3C_DCR_I2C_MODE_MASK   BIT(4)
 
#define I3C_DCR_I2C_MODE(dcr)    (((mode) & I3C_DCR_I2C_MODE_MASK) >> I3C_DCR_I2C_MODE_SHIFT)
 
#define I3C_DCR_I2C_DEV_IDX_0   0
 
#define I3C_DCR_I2C_DEV_IDX_1   1
 
#define I3C_DCR_I2C_DEV_IDX_2   2
 
#define I3C_DCR_I2C_DEV_IDX_SHIFT   5
 
#define I3C_DCR_I2C_DEV_IDX_MASK   (0x07U << I3C_DCR_I2C_DEV_IDX_SHIFT)
 
#define I3C_DCR_I2C_DEV_IDX(dcr)    (((dcr) & I3C_DCR_I2C_DEV_IDX_MASK) >> I3C_DCR_I2C_DEV_IDX_SHIFT)
 
#define I3C_MSG_WRITE   (0U << 0U)
 
#define I3C_MSG_READ   BIT(0)
 
#define I3C_MSG_STOP   BIT(1)
 
#define I3C_MSG_RESTART   BIT(2)
 
#define I3C_MSG_HDR   BIT(3)
 
#define I3C_MSG_HDR_MODE0   BIT(0)
 
#define I3C_MSG_HDR_MODE1   BIT(1)
 
#define I3C_MSG_HDR_MODE2   BIT(2)
 
#define I3C_MSG_HDR_MODE3   BIT(3)
 
#define I3C_MSG_HDR_MODE4   BIT(4)
 
#define I3C_MSG_HDR_MODE5   BIT(5)
 
#define I3C_MSG_HDR_MODE6   BIT(6)
 
#define I3C_MSG_HDR_MODE7   BIT(7)
 
#define I3C_MSG_HDR_DDR   I3C_MSG_HDR_MODE0
 
#define I3C_MSG_HDR_TSP   I3C_MSG_HDR_MODE1
 
#define I3C_MSG_HDR_TSL   I3C_MSG_HDR_MODE2
 
#define I3C_MSG_HDR_BT   I3C_MSG_HDR_MODE3
 
#define I3C_DEVICE_ID(pid)
 Structure initializer for i3c_device_id from PID. More...
 

Enumerations

enum  i3c_bus_mode {
  I3C_BUS_MODE_PURE , I3C_BUS_MODE_MIXED_FAST , I3C_BUS_MODE_MIXED_LIMITED , I3C_BUS_MODE_MIXED_SLOW ,
  I3C_BUS_MODE_MAX = I3C_BUS_MODE_MIXED_SLOW , I3C_BUS_MODE_INVALID
}
 I3C bus mode. More...
 
enum  i3c_i2c_speed_type { I3C_I2C_SPEED_FM , I3C_I2C_SPEED_FMPLUS , I3C_I2C_SPEED_MAX = I3C_I2C_SPEED_FMPLUS , I3C_I2C_SPEED_INVALID }
 I2C bus speed under I3C bus. More...
 
enum  i3c_data_rate {
  I3C_DATA_RATE_SDR , I3C_DATA_RATE_HDR_DDR , I3C_DATA_RATE_HDR_TSL , I3C_DATA_RATE_HDR_TSP ,
  I3C_DATA_RATE_HDR_BT , I3C_DATA_RATE_MAX = I3C_DATA_RATE_HDR_BT , I3C_DATA_RATE_INVALID
}
 I3C data rate. More...
 
enum  i3c_sdr_controller_error_codes {
  I3C_ERROR_CE0 , I3C_ERROR_CE1 , I3C_ERROR_CE2 , I3C_ERROR_CE3 ,
  I3C_ERROR_CE_UNKNOWN , I3C_ERROR_CE_NONE , I3C_ERROR_CE_MAX = I3C_ERROR_CE_UNKNOWN , I3C_ERROR_CE_INVALID
}
 I3C SDR Controller Error Codes. More...
 
enum  i3c_sdr_target_error_codes {
  I3C_ERROR_TE0 , I3C_ERROR_TE1 , I3C_ERROR_TE2 , I3C_ERROR_TE3 ,
  I3C_ERROR_TE4 , I3C_ERROR_TE5 , I3C_ERROR_TE6 , I3C_ERROR_DBR ,
  I3C_ERROR_TE_UNKNOWN , I3C_ERROR_TE_NONE , I3C_ERROR_TE_MAX = I3C_ERROR_TE_UNKNOWN , I3C_ERROR_TE_INVALID
}
 I3C SDR Target Error Codes. More...
 
enum  i3c_config_type { I3C_CONFIG_CONTROLLER , I3C_CONFIG_TARGET , I3C_CONFIG_CUSTOM }
 Type of configuration being passed to configure function. More...
 

Functions

struct i3c_device_desci3c_dev_list_find (const struct i3c_dev_list *dev_list, const struct i3c_device_id *id)
 Find a I3C target device descriptor by ID. More...
 
struct i3c_device_desci3c_dev_list_i3c_addr_find (const struct i3c_dev_list *dev_list, uint8_t addr)
 Find a I3C target device descriptor by dynamic address. More...
 
struct i3c_i2c_device_desci3c_dev_list_i2c_addr_find (const struct i3c_dev_list *dev_list, uint16_t addr)
 Find a I2C target device descriptor by address. More...
 
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. More...
 
static int i3c_configure (const struct device *dev, enum i3c_config_type type, void *config)
 Configure the I3C hardware. More...
 
static int i3c_config_get (const struct device *dev, enum i3c_config_type type, void *config)
 Get configuration of the I3C hardware. More...
 
static int i3c_recover_bus (const struct device *dev)
 Attempt bus recovery on the I3C bus. More...
 
static int i3c_do_daa (const struct device *dev)
 Perform Dynamic Address Assignment on the I3C bus. More...
 
int i3c_do_ccc (const struct device *dev, struct i3c_ccc_payload *payload)
 Send CCC to the bus. More...
 
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. More...
 
static struct i3c_device_desci3c_device_find (const struct device *dev, const struct i3c_device_id *id)
 
static int i3c_ibi_raise (const struct device *dev, struct i3c_ibi *request)
 Raise an In-Band Interrupt (IBI). More...
 
static int i3c_ibi_enable (struct i3c_device_desc *target)
 Enable IBI of a target device. More...
 
static int i3c_ibi_disable (struct i3c_device_desc *target)
 Disable IBI of a target device. More...
 
static int i3c_ibi_has_payload (struct i3c_device_desc *target)
 Check if target's IBI has payload. More...
 
static int i3c_device_is_ibi_capable (struct i3c_device_desc *target)
 Check if device is IBI capable. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int i3c_bus_init (const struct device *dev, const struct i3c_dev_list *i3c_dev_list)
 Generic helper function to perform bus initialization. More...
 
int i3c_device_basic_info_get (struct i3c_device_desc *target)
 Get basic information from device and update device descriptor. More...