Go to the documentation of this file.
54 #define NO_OS_I3C_MAX_BUS_NUMBER 3
55 #define NO_OS_I3C_MAX_DEV_NUMBER 15
57 #define NO_OS_I3C_I2C_MAX_ADDR 0x7F
58 #define NO_OS_I3C_MAX_ADDR NO_OS_I3C_I2C_MAX_ADDR
59 #define NO_OS_I3C_BCAST_ADDR 0x7E
61 #define NO_OS_I3C_ADDR_FLAG_SIZE 2
62 #define NO_OS_I3C_ADDR_PER_SLOT ((unsigned int)(sizeof(unsigned int)*8 / NO_OS_I3C_ADDR_FLAG_SIZE))
63 #define NO_OS_I3C_ADDR_GET_SLOT(x) ((x) / NO_OS_I3C_ADDR_PER_SLOT)
64 #define NO_OS_I3C_ADDR_GET_POS(x) (((x) % NO_OS_I3C_ADDR_PER_SLOT) * NO_OS_I3C_ADDR_FLAG_SIZE)
65 #define NO_OS_I3C_ADDRSLOTS_SIZE \
66 (NO_OS_I3C_I2C_MAX_ADDR / NO_OS_I3C_ADDR_PER_SLOT) + !!(NO_OS_I3C_I2C_MAX_ADDR % NO_OS_I3C_ADDR_PER_SLOT)
69 #define NO_OS_I3C_CCC_BCAST 0
70 #define NO_OS_I3C_CCC_DIRECT NO_OS_BIT(7)
72 #define NO_OS_I3C_CCC_ID(id, type) ((id) | (type))
74 #define NO_OS_I3C_CCC_ADDR(x) ((x) & 0xFF)
75 #define NO_OS_I3C_CCC_GET_LEN(x) (((x) >> 8) & 0x0000FF)
76 #define NO_OS_I3C_CCC_SET_LEN(x) (((x) << 8) & 0x00FF00)
77 #define NO_OS_I3C_CCC_GET_DEF(x) (((x) >> 17) & NO_OS_BIT(0))
78 #define NO_OS_I3C_CCC_SET_DEF NO_OS_BIT(17)
79 #define NO_OS_I3C_CCC_GET_RNW(x) (((x) >> 16) & NO_OS_BIT(0))
80 #define NO_OS_I3C_CCC_SET_RNW(x) (((x) << 16) & NO_OS_BIT(16))
86 #define NO_OS_I3C_CCC_ENEC_DIRECT 0x80 | NO_OS_I3C_CCC_SET_LEN(1)
87 #define NO_OS_I3C_CCC_DISEC_DIRECT 0x81 | NO_OS_I3C_CCC_SET_LEN(1)
88 #define NO_OS_I3C_CCC_ENEC_BCAST 0x00 | NO_OS_I3C_CCC_SET_DEF
89 #define NO_OS_I3C_CCC_DISEC_BCAST 0x01 | NO_OS_I3C_CCC_SET_DEF
90 #define NO_OS_I3C_CCC_ENTAS(as, type) NO_OS_I3C_CCC_ID((0x2 + (as)), (type))
91 #define NO_OS_I3C_CCC_RSTDAA(type) NO_OS_I3C_CCC_ID(0x6, (type))
92 #define NO_OS_I3C_CCC_SETMWL(type) NO_OS_I3C_CCC_ID(0x9, (type)) | NO_OS_I3C_CCC_SET_LEN(2)
93 #define NO_OS_I3C_CCC_SETMRL(type) NO_OS_I3C_CCC_ID(0xa, (type)) | NO_OS_I3C_CCC_SET_LEN(2)
94 #define NO_OS_I3C_CCC_SETXTIME_BCAST 0x28 | NO_OS_I3C_CCC_SET_DEF
95 #define NO_OS_I3C_CCC_SETXTIME_DIRECT 0x98 | NO_OS_I3C_CCC_SET_DEF
96 #define NO_OS_I3C_CCC_RSTACT_BCAST 0x2a | NO_OS_I3C_CCC_SET_DEF
97 #define NO_OS_I3C_CCC_RSTACT_DIRECT 0x9a | NO_OS_I3C_CCC_SET_DEF
98 #define NO_OS_I3C_CCC_RSTACT_I3C_ONLY 0x1
99 #define NO_OS_I3C_CCC_RSTACT_WHOLE_TARGET 0x2
102 #define NO_OS_I3C_CCC_ENTDAA NO_OS_I3C_CCC_ID(0x7, NO_OS_I3C_CCC_BCAST)
103 #define NO_OS_I3C_CCC_DEFSLVS NO_OS_I3C_CCC_ID(0x8, NO_OS_I3C_CCC_BCAST)
104 #define NO_OS_I3C_CCC_ENTTM NO_OS_I3C_CCC_ID(0xb, NO_OS_I3C_CCC_BCAST)
105 #define NO_OS_I3C_CCC_ENTHDR(x) NO_OS_I3C_CCC_ID((0x20 + (x)), NO_OS_I3C_CCC_BCAST)
106 #define NO_OS_I3C_CCC_SETAASA NO_OS_I3C_CCC_ID(0x29, NO_OS_I3C_CCC_BCAST)
109 #define NO_OS_I3C_CCC_SETDASA NO_OS_I3C_CCC_ID(0x7, NO_OS_I3C_CCC_DIRECT)
110 #define NO_OS_I3C_CCC_SETNEWDA NO_OS_I3C_CCC_ID(0x8, NO_OS_I3C_CCC_DIRECT)
111 #define NO_OS_I3C_CCC_GETMWL NO_OS_I3C_CCC_ID(0xb, NO_OS_I3C_CCC_DIRECT)
112 #define NO_OS_I3C_CCC_GETMRL NO_OS_I3C_CCC_ID(0xc, NO_OS_I3C_CCC_DIRECT)
113 #define NO_OS_I3C_CCC_GETPID (NO_OS_I3C_CCC_ID(0xd, NO_OS_I3C_CCC_DIRECT) | NO_OS_I3C_CCC_SET_LEN(6) | NO_OS_I3C_CCC_SET_RNW(1))
114 #define NO_OS_I3C_CCC_GETBCR (NO_OS_I3C_CCC_ID(0xe, NO_OS_I3C_CCC_DIRECT) | NO_OS_I3C_CCC_SET_LEN(1) | NO_OS_I3C_CCC_SET_RNW(1))
115 #define NO_OS_I3C_CCC_GETDCR (NO_OS_I3C_CCC_ID(0xf, NO_OS_I3C_CCC_DIRECT) | NO_OS_I3C_CCC_SET_LEN(1) | NO_OS_I3C_CCC_SET_RNW(1))
116 #define NO_OS_I3C_CCC_GETSTATUS (NO_OS_I3C_CCC_ID(0x10, NO_OS_I3C_CCC_DIRECT) | NO_OS_I3C_CCC_SET_LEN(2) | NO_OS_I3C_CCC_SET_RNW(1))
117 #define NO_OS_I3C_CCC_GETACCMST NO_OS_I3C_CCC_ID(0x11, NO_OS_I3C_CCC_DIRECT)
118 #define NO_OS_I3C_CCC_SETBRGTGT NO_OS_I3C_CCC_ID(0x13, NO_OS_I3C_CCC_DIRECT)
119 #define NO_OS_I3C_CCC_GETMXDS NO_OS_I3C_CCC_ID(0x14, NO_OS_I3C_CCC_DIRECT)
120 #define NO_OS_I3C_CCC_GETHDRCAP NO_OS_I3C_CCC_ID(0x15, NO_OS_I3C_CCC_DIRECT)
121 #define NO_OS_I3C_CCC_GETXTIME NO_OS_I3C_CCC_ID(0x19, NO_OS_I3C_CCC_DIRECT)
123 #define NO_OS_I3C_CCC_EVENT_SIR NO_OS_BIT(0)
124 #define NO_OS_I3C_CCC_EVENT_MR NO_OS_BIT(1)
125 #define NO_OS_I3C_CCC_EVENT_HJ NO_OS_BIT(3)
129 #define NO_OS_I3C_IRQ_IBI 0x1
130 #define NO_OS_I3C_IRQ_HJ 0x2
131 #define NO_OS_I3C_IRQ_CR 0x4
135 #define NO_OS_I3C_BCR_IBI_REQUEST_CAPABLE(bcr) !!((bcr) & (1 << 1))
136 #define NO_OS_I3C_BCR_IBI_PAYLOAD(bcr) !!((bcr) & (1 << 2))
137 #define NO_OS_I3C_BCR_DEVICE_ROLE(bcr) (((bcr) && NO_OS_GENMASK(7,6)) >> 6)
359 uint8_t addr, uint32_t ccc, uint8_t *data);
363 uint32_t ccc, uint8_t *data);
380 uint8_t rx_data_len);
384 uint8_t irq,
bool en);
411 #endif // _NO_OS_I3C_H_
const struct no_os_i3c_platform_ops * platform_ops
Definition: no_os_i3c.h:228
uint32_t ibi_payload
Definition: no_os_i3c.h:170
uint64_t pid
Definition: no_os_i3c.h:265
int no_os_i3c_wait_irq(struct no_os_i3c_bus_desc *desc, uint8_t irq)
Wait I3C interrupt. Set async_irq on call to false to ensure single entry point.
Definition: no_os_i3c.c:526
no_os_i3c_slot_status
On an I3C bus, addresses are assigned dynamically, and we need to know which addresses are free to us...
Definition: no_os_i3c.h:148
@ NO_OS_I3C_ADDR_SLOT_I2C_DEV
Definition: no_os_i3c.h:154
uint8_t irq_events
Definition: no_os_i3c.h:222
void(* event_callback)(struct no_os_i3c_desc *, uint32_t, uint32_t)
Definition: no_os_i3c.h:292
struct no_os_i3c_ccc_info ccc_info
Definition: no_os_i3c.h:224
struct no_os_i3c_bus_desc * bus
Definition: no_os_i3c.h:296
Structure holding I3C device descriptor.
Definition: no_os_i3c.h:278
void no_os_i3c_addr_set_status(struct no_os_i3c_bus_desc *desc, uint8_t addr, enum no_os_i3c_slot_status status)
Set status of an address.
Definition: no_os_i3c.c:600
const struct no_os_i3c_init_param ** devs
Definition: no_os_i3c.h:245
Structure holding I3C bus descriptor.
Definition: no_os_i3c.h:200
void * extra
Definition: no_os_i3c.h:290
int no_os_i3c_do_daa(struct no_os_i3c_bus_desc *desc, bool rstdaa)
Do DAA to assign the dynamic addresses.
Definition: no_os_i3c.c:335
bool
Definition: common.h:48
void * extra
Definition: no_os_i3c.h:230
uint32_t ibi_payload_len
Definition: no_os_i3c.h:168
bool is_static
Definition: no_os_i3c.h:269
@ NO_OS_I3C_ADDR_SLOT_STATUS_MASK
Definition: no_os_i3c.h:158
bool is_attached
Definition: no_os_i3c.h:286
const struct no_os_i3c_platform_ops * platform_ops
Definition: no_os_i3c.h:241
@ NO_OS_I3C_ADDR_SLOT_RSVD
Definition: no_os_i3c.h:152
#define NO_OS_I3C_ADDRSLOTS_SIZE
Definition: no_os_i3c.h:65
Structure holding the parameters for I3C initialization.
Definition: no_os_i3c.h:237
const uint32_t device_id
Definition: no_os_i3c.h:239
int no_os_i3c_write_and_read(struct no_os_i3c_desc *desc, uint8_t *tx_data, uint8_t tx_data_len, uint8_t *rx_data, uint8_t rx_data_len)
Read and write the device.
Definition: no_os_i3c.c:463
int no_os_i3c_init_bus(struct no_os_i3c_bus_desc **desc, const struct no_os_i3c_bus_init_param *param)
Initialize the I3C bus.
Definition: no_os_i3c.c:161
bool async_irq
Definition: no_os_i3c.h:226
@ NO_OS_I3C_ADDR_SLOT_FREE
Definition: no_os_i3c.h:150
int no_os_i3c_init(struct no_os_i3c_desc **desc, const struct no_os_i3c_init_param *param)
Initialize the I3C device. If the bus of the I3C device is not initialized, it will call to init it.
Definition: no_os_i3c.c:66
void no_os_i3c_detach_callback(struct no_os_i3c_desc *desc)
Detach event callback.
Definition: no_os_i3c.c:695
uint8_t addr
Definition: no_os_i3c.h:267
int no_os_i3c_remove(struct no_os_i3c_desc *desc)
Free the resources allocated by no_os_i3c_init().
Definition: no_os_i3c.c:270
void * mutex
Definition: no_os_i3c.h:202
struct no_os_i3c_desc * devs[NO_OS_I3C_MAX_DEV_NUMBER]
Definition: no_os_i3c.h:220
struct no_os_i3c_daa_lut daa_candidates[NO_OS_I3C_MAX_DEV_NUMBER]
Definition: no_os_i3c.h:216
uint8_t num_devs
Definition: no_os_i3c.h:208
int no_os_i3c_send_direct_ccc(struct no_os_i3c_desc *desc, uint32_t ccc, uint8_t *data)
Send CCC to device device.
Definition: no_os_i3c.c:388
unsigned int addrslots[NO_OS_I3C_ADDRSLOTS_SIZE]
Definition: no_os_i3c.h:214
int no_os_i3c_async_irq(struct no_os_i3c_bus_desc *desc, bool en)
Enable I3C non-blocking interrupts.
Definition: no_os_i3c.c:510
const uint8_t num_devs
Definition: no_os_i3c.h:243
uint8_t addr
Definition: no_os_i3c.h:181
uint8_t addr
Definition: no_os_i3c.h:282
uint8_t no_os_i3c_addr_get_free(struct no_os_i3c_bus_desc *desc, uint8_t start_addr)
Get a free address.
Definition: no_os_i3c.c:579
int no_os_i3c_conf_irq(struct no_os_i3c_bus_desc *desc, uint8_t irq, bool en)
Configure I3C interrupts.
Definition: no_os_i3c.c:492
bool is_i3c
Definition: no_os_i3c.h:271
uint8_t device_id
Definition: no_os_i3c.h:204
int no_os_i3c_send_ccc(struct no_os_i3c_bus_desc *desc, uint8_t addr, uint32_t ccc, uint8_t *data)
Send CCC, either to a device device or broadcast to all.
Definition: no_os_i3c.c:354
Structure holding the parameters for I3C initialization. Works like a device tree,...
Definition: no_os_i3c.h:261
uint32_t ibi_cr_addr
Definition: no_os_i3c.h:166
Stores the PID + DA information to look-up during the DAA. Should be used only for device initializat...
Definition: no_os_i3c.h:179
uint64_t pid
Definition: no_os_i3c.h:280
bool is_static
Definition: no_os_i3c.h:288
struct no_os_i3c_bus_init_param * bus
Definition: no_os_i3c.h:263
const struct no_os_i3c_platform_ops * platform_ops
Definition: no_os_i3c.h:294
Definition: no_os_i3c.h:164
int no_os_i3c_write(struct no_os_i3c_desc *desc, uint8_t *data, uint8_t size)
Write data to device device.
Definition: no_os_i3c.c:407
uint64_t pid
Definition: no_os_i3c.h:182
bool is_attached
Definition: no_os_i3c.h:180
bool is_i3c
Definition: no_os_i3c.h:284
Header file of utility functions.
struct no_os_i3c_daa_lut daa_unknown[NO_OS_I3C_MAX_DEV_NUMBER]
Definition: no_os_i3c.h:218
int no_os_i3c_call_irq(struct no_os_i3c_bus_desc *desc)
Non-blocking I3C interrupt. Since a payload is always retrieved with it, also update the no_os_i3c_cc...
Definition: no_os_i3c.c:543
int no_os_i3c_read(struct no_os_i3c_desc *desc, uint8_t *data, uint8_t size)
Read data from device device.
Definition: no_os_i3c.c:434
@ NO_OS_I3C_ADDR_SLOT_I3C_DEV
Definition: no_os_i3c.h:156
int no_os_i3c_remove_bus(struct no_os_i3c_bus_desc *desc)
Free the resources allocated by no_os_i3c_init_bus. Must remove all devices first,...
Definition: no_os_i3c.c:302
uint8_t num_devs_unknown
Definition: no_os_i3c.h:206
#define NO_OS_I3C_MAX_DEV_NUMBER
Definition: no_os_i3c.h:55
void no_os_i3c_attach_callback(struct no_os_i3c_desc *desc, void(*callback)(struct no_os_i3c_desc *, uint32_t, uint32_t))
Attach event callback.
Definition: no_os_i3c.c:685
void * extra
Definition: no_os_i3c.h:247