1 /* 2 * Copyright 2020, 2022 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef _I3C_COMPONENT_H_ 9 #define _I3C_COMPONENT_H_ 10 11 #include "fsl_component_generic_list.h" 12 13 /*! 14 * @addtogroup I3C_Bus_Component 15 * @{ 16 */ 17 18 /******************************************************************************* 19 * Definitions 20 ******************************************************************************/ 21 22 /*! @name I3C BUS management definitions*/ 23 /*@{*/ 24 #define I3C_BUS_MAX_DEVS 11U /*!< Bus maximum device count. */ 25 #define I3C_BUS_HOT_JOIN_ADDR 0x2U /*!< Hot join event device address. */ 26 #define I3C_BOARDCAST_SINGLE_BIT_ERR_DETECT_ADDR1 0x3EU /*!< Broadcast address single bit error detect address. */ 27 #define I3C_BOARDCAST_SINGLE_BIT_ERR_DETECT_ADDR2 0x5EU /*!< Broadcast address single bit error detect address. */ 28 #define I3C_BOARDCAST_SINGLE_BIT_ERR_DETECT_ADDR3 0x6EU /*!< Broadcast address single bit error detect address. */ 29 #define I3C_BOARDCAST_SINGLE_BIT_ERR_DETECT_ADDR4 0x76U /*!< Broadcast address single bit error detect address. */ 30 #define I3C_BOARDCAST_SINGLE_BIT_ERR_DETECT_ADDR5 0x7AU /*!< Broadcast address single bit error detect address. */ 31 #define I3C_BOARDCAST_SINGLE_BIT_ERR_DETECT_ADDR6 0x7CU /*!< Broadcast address single bit error detect address. */ 32 #define I3C_BOARDCAST_SINGLE_BIT_ERR_DETECT_ADDR7 0x7FU /*!< Broadcast address single bit error detect address. */ 33 #define I3C_BUS_BROADCAST_ADDR 0x7EU /*!< Broad cast address. */ 34 #define I3C_BUS_MAX_ADDR 0x7FU /*!< Maximum address allowed for address assignment. */ 35 #define I3C_BUS_ADDR_SLOTWIDTH 2U /*!< Address slot width used in address management in bus pool. */ 36 #define I3C_BUS_ADDR_SLOTDEPTH 32U /*!< Address slot depth used in address management in bus pool. */ 37 #define I3C_BUS_ADDR_SLOTMASK 3U /*!< Address slot mask used in address management in bus pool. */ 38 39 /*@}*/ 40 41 /*! @name I3C BUS CCC (Common Command Codes) definitions*/ 42 /*@{*/ 43 #define I3C_BUS_CCC_DIRECT_PREFIX 0x80U /*!< Prefix used for direct access CCC. */ 44 45 #define I3C_BUS_CCC(cmdID, isDirect) \ 46 ((cmdID) | ((isDirect) ? I3C_BUS_CCC_DIRECT_PREFIX : 0U)) /*!< CCC ID calculation. */ 47 48 /* CCC available for both broadcast and direct access */ 49 #define I3C_BUS_CCC_ENEC(isDirect) I3C_BUS_CCC(0x0U, isDirect) /*!< Enable Slave Events Command. */ 50 #define I3C_BUS_CCC_DISEC(isDirect) I3C_BUS_CCC(0x1U, isDirect) /*!< Disable Slave Events Command. */ 51 #define I3C_BUS_CCC_ENTAS(as, isDirect) I3C_BUS_CCC(0x2U + (as), isDirect) /*!< Enter Activity State 0–3 Command. */ 52 #define I3C_BUS_CCC_RSTDAA(isDirect) I3C_BUS_CCC(0x6U, isDirect) /*!< Reset Dynamic Address Assignment Command. */ 53 #define I3C_BUS_CCC_SETMWL(isDirect) I3C_BUS_CCC(0x9U, isDirect) /*!< Set Max Write Length Command. */ 54 #define I3C_BUS_CCC_SETMRL(isDirect) I3C_BUS_CCC(0xaU, isDirect) /*!< Set Max Read Length Command. */ 55 #define I3C_BUS_CCC_SETXTIME(isDirect) (isDirect) ? 0x98U : 0x28U /*!< Set Exchange Timing Information Command. */ 56 #define I3C_BUS_CCC_VENDOR_EXT(cmdID, isDirect) \ 57 ((cmdID) + ((isDirect) ? 0xe0U : 0x61U)) /*!< Vendor Extension Command. */ 58 59 /* CCC available only for broadcast access */ 60 #define I3C_BUS_CCC_ENTDAA 0x7U /*!< Enter Dynamic Address Assignment Command. */ 61 #define I3C_BUS_CCC_DEFSLVS 0x8U /*!< Send Define List of Slaves Command. */ 62 #define I3C_BUS_CCC_ENTTM 0xbU /*!< Enter Test Mode Command. */ 63 #define I3C_BUS_CCC_ENTHDR(x) 0x20U + (x) /*!< Enter HDR Command. */ 64 65 /* CCC available only for direct access */ 66 #define I3C_BUS_CCC_SETDASA 0x87U /*!< Set Dynamic Address from Static Address Command. */ 67 #define I3C_BUS_CCC_SETNEWDA 0x88U /*!< Set New Dynamic Address Command. */ 68 #define I3C_BUS_CCC_GETMWL 0x8bU /*!< Get Max Write Length Command. */ 69 #define I3C_BUS_CCC_GETMRL 0x8cU /*!< Get Max Read Length Command. */ 70 #define I3C_BUS_CCC_GETPID 0x8dU /*!< Get Provisional ID Command. */ 71 #define I3C_BUS_CCC_GETBCR 0x8eU /*!< Get BCR Command. */ 72 #define I3C_BUS_CCC_GETDCR 0x8fU /*!< Get DCR Command. */ 73 #define I3C_BUS_CCC_GETSTATUS 0x90U /*!< Get Device Status Command. */ 74 #define I3C_BUS_CCC_GETACCMST 0x91U /*!< Get Accept Mastership Command. */ 75 #define I3C_BUS_CCC_SETBRGTGT 0x93U /*!< Set Bridge Targets Command. */ 76 #define I3C_BUS_CCC_GETMXDS 0x94U /*!< Get Max Data Speed Command. */ 77 #define I3C_BUS_CCC_GETHDRCAP 0x95U /*!< Get HDR Capability Command. */ 78 #define I3C_BUS_CCC_GETXTIME 0x99U /*!< Get Exchange Timing Support Command. */ 79 80 /*@}*/ 81 82 /*! @name I3C device BCR register bit masks*/ 83 /*@{*/ 84 85 /* @brief I3C device bus characteristics */ 86 #define I3C_BUS_DEV_BCR_DEV_MASTER 0x01U 87 #define I3C_BUS_DEV_BCR_DEV_ROLE_SHIFT 6U 88 #define I3C_BUS_DEV_BCR_DEV_ROLE_MASK 0xC0U 89 #define I3C_BUS_DEV_BCR_DEV_ROLE(x) (((x) << I3C_BUS_DEV_BCR_DEV_ROLE_SHIFT) & I3C_BUS_DEV_BCR_DEV_ROLE_MASK) 90 91 #define I3C_BUS_DEV_BCR_MODE_SHIFT 5U 92 #define I3C_BUS_DEV_BCR_MODE_MASK 0x20U 93 #define I3C_BUS_DEV_BCR_MODE(x) (((x) << I3C_BUS_DEV_BCR_MODE_SHIFT) & I3C_BUS_DEV_BCR_MODE_MASK) 94 95 #define I3C_BUS_DEV_BCR_IBI_PAYLOAD_SHIFT 2U 96 #define I3C_BUS_DEV_BCR_IBI_PAYLOAD_MASK 0x04U 97 #define I3C_BUS_DEV_BCR_IBI_PAYLOAD(x) (((x) << I3C_BUS_DEV_BCR_IBI_PAYLOAD_SHIFT) & I3C_BUS_DEV_BCR_IBI_PAYLOAD_MASK) 98 99 #define I3C_BUS_DEV_BCR_IBI_REQUEST_SHIFT 1U 100 #define I3C_BUS_DEV_BCR_IBI_REQUEST_MASK 0x02U 101 #define I3C_BUS_DEV_BCR_IBI_REQUEST(x) (((x) << I3C_BUS_DEV_BCR_IBI_REQUEST_SHIFT) & I3C_BUS_DEV_BCR_IBI_REQUEST_MASK) 102 103 #define I3C_BUS_DEV_BCR_SPEED_LIMIT_SHIFT 0U 104 #define I3C_BUS_DEV_BCR_SPEED_LIMIT_MASK 0x01U 105 #define I3C_BUS_DEV_BCR_SPEED_LIMIT(x) (((x) << I3C_BUS_DEV_BCR_SPEED_LIMIT_SHIFT) & I3C_BUS_DEV_BCR_SPEED_LIMIT_MASK) 106 107 /*@}*/ 108 109 /*! @brief I3C Bus status. */ 110 enum 111 { 112 kStatus_I3CBus_Success = kStatus_Success, /*!< I3C Bus operation succeed*/ 113 kStatus_I3CBus_AddrSlotInvalid = MAKE_STATUS(kStatusGroup_I3CBUS, 0U), /*!< I3C Bus address slot invalid */ 114 kStatus_I3CBus_MasterOpsUnsupport = 115 MAKE_STATUS(kStatusGroup_I3CBUS, 1U), /*!< I3C Bus master operation unsupported */ 116 kStatus_I3CBus_NotCurrentMaster = MAKE_STATUS( 117 kStatusGroup_I3CBUS, 2U), /*!< The Bus operation should be made on master but current device is not master */ 118 kStatus_I3CBus_MasterOpsFailure = MAKE_STATUS(kStatusGroup_I3CBUS, 3U), /*!< Bus operation failure */ 119 kStatus_I3CBus_InvalidOps = MAKE_STATUS(kStatusGroup_I3CBUS, 4U), /*!< Master transfer timeout on bus */ 120 kStatus_I3CBus_MasterTransTimeout = MAKE_STATUS(kStatusGroup_I3CBUS, 5U), /*!< Master transfer timeout on bus */ 121 kStatus_I3CBus_SlaveOpsNotSupported = 122 MAKE_STATUS(kStatusGroup_I3CBUS, 6U), /*!< I3C Bus slave operation unsupported */ 123 kStatus_I3CBus_MasterOpsMissing = 124 MAKE_STATUS(kStatusGroup_I3CBUS, 7U), /*!< I3C Bus master mandatory operation missing */ 125 }; 126 127 /*! @brief I3C bus events. */ 128 enum _i3c_bus_events 129 { 130 kI3C_EventIBI = 1U, /*!< I3C Bus event IBI */ 131 kI3C_EventMR = 2U, /*!< I3C Bus event Mastership Request */ 132 kI3C_EventHJ = 8U, /*!< I3C Bus event Hot Join */ 133 }; 134 135 /*! @brief I3C device information. */ 136 typedef struct _i3c_device_information 137 { 138 uint8_t dynamicAddr; /*!< Device dynamic address. */ 139 uint8_t staticAddr; /*!< Static address. */ 140 uint8_t dcr; /*!< Device characteristics register information. */ 141 uint8_t bcr; /*!< Bus characteristics register information. */ 142 uint16_t vendorID; /*!< Device vendor ID(manufacture ID). */ 143 uint32_t partNumber; /*!< Device part number info */ 144 uint16_t maxReadLength; /*!< Maximum read length. */ 145 uint16_t maxWriteLength; /*!< Maximum write length. */ 146 uint8_t maxIBILength; /*!< Maximum ibi payload length. */ 147 uint8_t hdrMode; /*!< Support hdr mode, could be OR logic in i3c_hdr_mode. */ 148 } i3c_device_information_t; 149 150 /* Forward declaration of the i3c_bus_t typedef. */ 151 typedef struct _i3c_bus i3c_bus_t; 152 153 /* Forward declaration of the i3c_device_control_info_t typedef. */ 154 typedef struct _i3c_device_control_info i3c_device_control_info_t; 155 156 /* Forward declaration of the i3c_device_ibi_info_t typedef. */ 157 typedef struct _i3c_device_ibi_info i3c_device_ibi_info_t; 158 159 /*! @brief I3C device definition. */ 160 typedef struct _i3c_device 161 { 162 list_element_t listNode; /*!< list node to link i3c devices in i3c bus. */ 163 i3c_bus_t *bus; /*!< I3C bus pointer, points to current bus the device is attached. */ 164 i3c_device_control_info_t *devControlInfo; /*!< Pointer to control information structure of the device. */ 165 i3c_device_information_t info; /*!< Pointer to device information structure of the device. */ 166 uint8_t initDynamicAddr; /*!< Initial dynamic address for the device. */ 167 i3c_device_ibi_info_t *ibiInfo; /*!< Pointer to IBI request information structure of the device. */ 168 } i3c_device_t; 169 170 /* Forward declaration of the i2c_device_control_info_t typedef. */ 171 typedef struct _i2c_device_control_info i2c_device_control_info_t; 172 173 /*! @brief I2C device definition. */ 174 typedef struct _i2c_device 175 { 176 list_element_t listNode; /*!< list node to link i2c devices in i3c bus. */ 177 i3c_bus_t *bus; /*!< I3C bus pointer, points to current bus the device is attached. */ 178 i2c_device_control_info_t *devControlInfo; /*!< Pointer to device information structure of the device. */ 179 uint8_t staticAddr; /*!< static address for I2C device. */ 180 uint8_t lvr; /*!< LVR for I2C device. */ 181 } i2c_device_t; 182 183 /*! @brief CCC command structure for CCC frame */ 184 typedef struct _i3c_ccc_cmd 185 { 186 uint8_t cmdId; /*!< Command ID. */ 187 bool isRead; /*!< Read command or write command. */ 188 uint8_t destAddr; /*!< Destination address for the command, broadcast uses 0x7E, direct access uses dest device 189 dynamic address. */ 190 void *data; /*!< Pointer to data to be transmitted or received. */ 191 uint16_t dataSize; /*!< Data size of data to be transmitted or received. */ 192 } i3c_ccc_cmd_t; 193 194 /*! @brief I3C bus transfer structure for general data transfer. */ 195 typedef struct _i3c_bus_transfer 196 { 197 uint32_t regAddr; /*!< Operate register address of the target device.*/ 198 uint32_t regAddrSize; /*!< Size of Register address. */ 199 bool isRead; /*!< Read transfer or write transfer. */ 200 void *data; /*!< Pointer to data to be transmitted or received. */ 201 uint32_t dataSize; /*!< Data size of data to be transmitted or received. */ 202 } i3c_bus_transfer_t; 203 204 /*! @brief I3C device hardware operation API set. */ 205 typedef struct i3c_device_hw_ops 206 { 207 status_t (*Init)(i3c_device_t *dev); /*!< Init function to initialize I3C device.*/ 208 void (*Deinit)(i3c_device_t *dev); /*!< Deinit function to de-initialize I3C device.*/ 209 status_t (*ProceedDAA)(i3c_device_t *master); /*!< ProceedDAA function, only required for I3C master device.*/ 210 bool (*CheckSupportCCC)(i3c_device_t *master, i3c_ccc_cmd_t *cmd); /*!< CheckSupportCCC function, optional for I3C 211 master device, not require for slave device.*/ 212 status_t (*TransmitCCC)(i3c_device_t *master, 213 i3c_ccc_cmd_t *cmd); /*!< TransmitCCC function, only require for I3C master device.*/ 214 status_t (*DoI3CTransfer)( 215 i3c_device_t *dev, i3c_bus_transfer_t *xfer); /*!< DoI3CTransfer function, only require for I3C master device.*/ 216 status_t (*DoI2CTransfer)( 217 i2c_device_t *dev, i3c_bus_transfer_t *xfer); /*!< DoI2CTransfer function, only require for I3C slave device.*/ 218 void (*HotJoin)(i3c_device_t *master); /*!< HotJoin function.*/ 219 void (*RequestMastership)( 220 i3c_device_t *master); /*!< RequestMastership function, only require for I3C master device.*/ 221 void (*RegisterIBI)(i3c_device_t *master, uint8_t ibiAddress); /*!< Register IBI address with mandatory byte.*/ 222 void (*RequestIBI)(i3c_device_t *device, void *data, size_t dataSize); /*!< RequestIBI function.*/ 223 } i3c_device_hw_ops_t; 224 225 /*! @brief I3C device information. */ 226 struct _i3c_device_control_info 227 { 228 i3c_device_hw_ops_t *funcs; /*!< Pointer to I3C device hardware operation API sets.*/ 229 void *resource; /*!< Pointer to keep I3C device specific resource.*/ 230 bool isSecondary; /*!< Specify if the device is secondary device.*/ 231 void *privateData; /*!< Pointer to keep I3C device private data.*/ 232 }; 233 234 /*! @brief I2C device information. */ 235 typedef struct i2c_device_hw_ops 236 { 237 int (*Init)(i2c_device_t *dev); /*!< I2C device initialize function.*/ 238 void (*Deinit)(i2c_device_t *dev); /*!< I2C device de-initialize function.*/ 239 } i2c_device_hw_ops_t; 240 241 /*! @brief I3C master information. */ 242 struct _i2c_device_control_info 243 { 244 i2c_device_hw_ops_t *funcs; /*!< Pointer to I2C device hardware operation API sets.*/ 245 void *resource; /*!< Pointer to keep I2C device specific resource.*/ 246 void *privateData; /*!< Pointer to keep I2C device private data.*/ 247 }; 248 249 /*! @brief I3C device IBI information. */ 250 typedef void (*i3c_dev_ibi_handler_t)(i3c_device_t *dev, const void *ibiData, uint32_t ibiLen); 251 struct _i3c_device_ibi_info 252 { 253 uint32_t maxPayloadLength; /*!< Maximum IBI payload length. */ 254 bool enabled; /*!< Is IBI enabled. */ 255 i3c_dev_ibi_handler_t ibiHandler; /*!< IBI handler when device registers IBI. */ 256 }; 257 258 /*! @brief I3C bus mode definition. */ 259 typedef enum _i3c_bus_mode 260 { 261 kI3C_Bus_PureMode, /*!< Only I3C devices are connected to the bus */ 262 kI3C_Bus_MixedMode_Fast, /*!< I2C devices with 50ns spike filter are present on bus */ 263 kI3C_Bus_MixedMode_Slow, /*!< I2C devices without 50ns spike filter are present on bus */ 264 } i3c_bus_mode_t; 265 266 /*! @brief I3C address slot status in address pool. */ 267 typedef enum _i3c_addr_slot_status 268 { 269 kI3C_Bus_AddrSlot_Free = 0, /*!< Address slot is free. */ 270 kI3C_Bus_AddrSlot_Reserved, /*!< Address slot is reserved. */ 271 kI3C_Bus_AddrSlot_I2CDev, /*!< Address slot is I2C device. */ 272 kI3C_Bus_AddrSlot_I3CDev, /*!< Address slot is I3C device. */ 273 } i3c_addr_slot_status_t; 274 275 /*! @brief I3C initial bus configuration, user input to configure. */ 276 typedef struct _i3c_bus_config 277 { 278 i3c_bus_mode_t busMode; /*!< Bus mode. */ 279 uint32_t i2cBaudRate; /*!< I2C baud rate. */ 280 uint32_t i3cOpenDrainBaudRate; /*!< I3C open drain baudrate. */ 281 uint32_t i3cPushPullBaudRate; /*!< I3C push-pull baudrate. */ 282 } i3c_bus_config_t; 283 284 /*! @brief I3C bus structure, contains bus mandatory informations.*/ 285 struct _i3c_bus 286 { 287 i3c_device_t *volatile currentMaster; /*!< Pointer to current I3C master on bus. */ 288 uint32_t addrSlots[((I3C_BUS_MAX_ADDR + 1U) * I3C_BUS_ADDR_SLOTWIDTH) / 289 I3C_BUS_ADDR_SLOTDEPTH]; /*!< I3C bus address pool. */ 290 i3c_bus_mode_t busMode; /*!< I3C bus mode. */ 291 uint32_t i2cBaudRate; /*!< I2C baud rate. */ 292 uint32_t i3cOpenDrainBaudRate; /*!< I3C open drain baudrate. */ 293 uint32_t i3cPushPullBaudRate; /*!< I3C push-pull baudrate. */ 294 list_label_t i2cDevList; /*!< I2C device list. */ 295 list_label_t i3cDevList; /*!< I3C device list. */ 296 }; 297 298 /*! @brief Device description structure in I3C DEFSLVS device list .*/ 299 typedef struct _i3c_ccc_dev 300 { 301 uint8_t dynamicAddr; /*!< Dynamic address for I3C device. */ 302 union 303 { 304 uint8_t dcr; /*!< Device Characteristics register value for I3C device. */ 305 uint8_t lvr; /*!< Legacy Virtual Register value for I2C device */ 306 }; 307 uint8_t bcr; /*!< Bus characteristics register value. */ 308 uint8_t staticAddr; /*!< Static address for I3C/I2C device. */ 309 } i3c_ccc_dev_t; 310 311 /******************************************************************************* 312 * API 313 ******************************************************************************/ 314 315 #if defined(__cplusplus) 316 extern "C" { 317 #endif /* _cplusplus */ 318 319 /*! 320 * @name I3C bus operation 321 * @{ 322 */ 323 324 /*! 325 * @brief Gets the default configuration structure. 326 * 327 * This function initializes the bus configuration structure to a default value. The default 328 * values are: 329 * busConfig->busMode = kI3C_Bus_PureMode; 330 * busConfig->i2cBaudRate = 400000U; 331 * busConfig->i3cOpenDrainBaudRate = 1500000U; 332 * busConfig->i3cPushPullBaudRate = 4000000U; 333 * 334 * @param config Pointer to a configuration structure. 335 */ 336 void I3C_BusGetDefaultBusConfig(i3c_bus_config_t *busConfig); 337 338 /*! 339 * @brief Creates I3C bus structure. 340 * 341 * This function creates the bus structure with input bus configuration. Address pool set up and device 342 * list initialize process will be also done in this function call. 343 * 344 * @param bus Pointer to bus structure. 345 * @param busConfig Pointer to the bus configuration structure. 346 */ 347 void I3C_BusCreate(i3c_bus_t *bus, const i3c_bus_config_t *busConfig); 348 349 /*! 350 * @brief Get valid address slot in the I3C bus. 351 * 352 * This function will search for available address lot in the I3C bus address pool, the search starts from 353 * the startAddr specified by user input, to end address defined in @ref I3C_BUS_MAX_ADDR. Will return the 354 * available address if the related address slot is valid. 355 * 356 * @param bus Pointer to bus structure. 357 * @param startAddr Start address for address slot searching, end address is defined in @ref I3C_BUS_MAX_ADDR. 358 * @return Available address in the bus address pool. 359 */ 360 uint8_t I3C_BusGetValidAddrSlot(i3c_bus_t *bus, uint8_t startAddr); 361 362 /*! 363 * @brief Set address slot status. 364 * 365 * This function will set an specified address to address slot and set the status. 366 * 367 * @param bus Pointer to bus structure. 368 * @param addr address to be used. 369 * @return status the address status of @ref i3c_addr_slot_status_t. 370 */ 371 void I3C_BusSetAddrSlot(i3c_bus_t *bus, uint8_t addr, i3c_addr_slot_status_t status); 372 373 /*! 374 * @brief Add exist I3C device in bus to the bus device list. 375 * 376 * This function will simply add the device to the bus device list and set the related address slot. 377 * 378 * @param bus Pointer to bus structure. 379 * @param dev Pointer to I3C device. 380 */ 381 void I3C_BusAddI3CDev(i3c_bus_t *bus, i3c_device_t *dev); 382 383 /*! 384 * @brief Add exist I2C device in bus to the bus device list. 385 * 386 * This function will simply add the device to the bus device list and set the related address slot. 387 * 388 * @param bus Pointer to bus structure. 389 * @param dev Pointer to I2C device. 390 */ 391 void I3C_BusAddI2CDev(i3c_bus_t *bus, i2c_device_t *dev); 392 393 /* @} */ 394 395 /*! 396 * @name I3C bus master operation 397 * @{ 398 */ 399 400 /*! 401 * @brief Create I3C master structure on bus. 402 * 403 * This function will create I3C master bus structure, initialize the master according to bus characteristics, install 404 * device information and device control information. 405 * 406 * @param masterDev Pointer to device structure creating as master. 407 * @param bus Pointer to bus structure. 408 * @param devInfo Pointer to device information structure. 409 * @param masterControlInfo Pointer to master control information structure. 410 */ 411 status_t I3C_BusMasterCreate(i3c_device_t *masterDev, 412 i3c_bus_t *bus, 413 i3c_device_information_t *devInfo, 414 i3c_device_control_info_t *masterControlInfo); 415 416 /*! 417 * @brief Register slave IBI information to bus master. 418 * 419 * This function will register the slave IBI information to bus master so that bus master know how 420 * to handle slave IBI event. 421 * 422 * @param masterDev Pointer to device structure creating as master. 423 * @param i3cDev Pointer to the I3C device master want to register. 424 * @param devIbiInfo Pointer to device IBI information structure. 425 */ 426 status_t I3C_BusMasterRegisterDevIBI(i3c_device_t *masterDev, i3c_device_t *i3cDev, i3c_device_ibi_info_t *devIbiInfo); 427 428 /*! 429 * @brief Bus master transfer CCC frame. 430 * 431 * Bus master call this function to transfer CCC frame, CCC frame command and data is prepared in @ref i3c_ccc_cmd_t 432 * structure. 433 * 434 * @param masterDev Pointer to I3C master device. 435 * @param command Pointer to ccc frame. 436 */ 437 status_t I3C_BusMasterSendCCC(i3c_device_t *masterDev, i3c_ccc_cmd_t *command); 438 439 /*! 440 * @brief Bus master reset dynamic assigned address. 441 * 442 * Bus master call this function to reset dynamic assigned address, the operation could be done to all connected I3C 443 * devices by using slave address I3C_BUS_BROADCAST_ADDR or to a specific connected device by using the device's dynamic 444 * address. 445 * 446 * @param masterDev Pointer to I3C master device. 447 * @param slaveAddr Slave address, use I3C_BUS_BROADCAST_ADDR as broadcast address. 448 */ 449 status_t I3C_BusMasterResetDAA(i3c_device_t *masterDev, uint8_t slaveAddr); 450 451 /*! 452 * @brief Bus master do dynamic address assignment. 453 * 454 * Bus master call this function to do dynamic address assignment to the I3C devices connected on bus. 455 * 456 * @param masterDev Pointer to I3C master device. 457 */ 458 status_t I3C_BusMasterDoDAA(i3c_device_t *masterDev); 459 460 /*! 461 * @brief Bus master set device dynamic address from static address. 462 * 463 * Bus master call this function to execute SETDASA CCC command to set device dynamic address from static address. 464 * 465 * @param masterDev Pointer to I3C master device. 466 * @param staticAddr Device static address. 467 * @param initDynamicAddr Device initialized dynamic address. 468 */ 469 status_t I3C_BusMasterSetDynamicAddrFromStaticAddr(i3c_device_t *master, uint8_t staticAddr, uint8_t initDynamicAddr); 470 471 /*! 472 * @brief Bus master send slave list on bus. 473 * 474 * Bus master call this function to send slave list on bus to notify the secondary master. 475 * 476 * @param masterDev Pointer to I3C master device. 477 */ 478 status_t I3C_BusMasterSendSlavesList(i3c_device_t *masterDev); 479 480 /*! 481 * @brief Bus master handle in-band-interrupt event. 482 * 483 * Bus master call this function to handle in-band-interrupt event. 484 * 485 * @param masterDev Pointer to I3C master device. 486 * @param ibiAddress slave address which requests the IBI. 487 * @param ibiData Pointer to the ibi data buffer. 488 * @param payloadSize ibi data buffer size. 489 */ 490 status_t I3C_BusMasterHandleIBI(i3c_device_t *masterDev, uint8_t ibiAddress, void *ibiData, uint32_t payloadSize); 491 492 /*! 493 * @brief Bus master do data transfer to I2C device. 494 * 495 * Bus master call this function to transfer data to connected I2C device. 496 * 497 * @param masterDev Pointer to I3C master device. 498 * @param i2cDev Pointer to the I2C device master do transfer. 499 * @param xfer Pointer to bus transfer. 500 */ 501 status_t I3C_BusMasterDoTransferToI2CDev(i3c_device_t *masterDev, i2c_device_t *i2cDev, i3c_bus_transfer_t *xfer); 502 503 /*! 504 * @brief Bus master do data transfer to I3C device. 505 * 506 * Bus master call this function to transfer data to connected I3C device. 507 * 508 * @param masterDev Pointer to I3C master device. 509 * @param i3cDev Pointer to the I3C device master do transfer. 510 * @param xfer Pointer to bus transfer. 511 */ 512 status_t I3C_BusMasterDoTransferToI3CDev(i3c_device_t *masterDev, i3c_device_t *i3cDev, i3c_bus_transfer_t *xfer); 513 514 /*! 515 * @brief Bus master enable events. 516 * 517 * Bus master call this function to enable events on bus. 518 * 519 * @param masterDev Pointer to I3C master device. 520 * @param slaveAddr Slave address, use I3C_BUS_BROADCAST_ADDR as broadcast address. 521 * @param busEvents Logic OR or member in @ref _i3c_bus_events. 522 */ 523 status_t I3C_BusMasterEnableEvents(i3c_device_t *masterDev, uint8_t slaveAddr, uint8_t busEvents); 524 525 /*! 526 * @brief Bus master disable events. 527 * 528 * Bus master call this function to disable events on bus. 529 * 530 * @param masterDev Pointer to I3C master device. 531 * @param slaveAddr Slave address, use I3C_BUS_BROADCAST_ADDR as broadcast address. 532 * @param busEvents Logic OR or member in @ref _i3c_bus_events. 533 */ 534 status_t I3C_BusMasterDisableEvents(i3c_device_t *masterDev, uint8_t slaveAddr, uint8_t busEvents); 535 536 /*! 537 * @brief Bus master get device information for a specific I3C device. 538 * 539 * Bus master call this function to get device information for a specific I3C device. 540 * 541 * @param masterDev Pointer to I3C master device. 542 * @param slaveAddr Slave address, dynamic assigned address for a device. 543 * @param devInfo Input pointer to structure i3c_device_information_t to store the read out device information. 544 */ 545 status_t I3C_BusMasterGetDeviceInfo(i3c_device_t *masterDev, uint8_t slaveAddr, i3c_device_information_t *devInfo); 546 547 /* @} */ 548 549 /*! 550 * @name I3C bus slave operation 551 * @{ 552 */ 553 554 /*! 555 * @brief Create I2C slave structure on bus. 556 * 557 * This function will create I2C device bus structure, initialize the slave according to bus characteristics, install 558 * device information including static address, lvr and device control information. 559 * 560 * @param i2cDev Pointer to device structure creating as I2C device. 561 * @param bus Pointer to bus structure. 562 * @param staticAddr Static address of the I2C device 563 * @param lvr legacy virtual register value of the device. 564 * @param devControlInfo Pointer to device control information structure. 565 */ 566 status_t I3C_BusI2CSlaveCreate( 567 i2c_device_t *i2cDev, i3c_bus_t *bus, uint8_t staticAddr, uint8_t lvr, i2c_device_control_info_t *devControlInfo); 568 569 /*! 570 * @brief Create I3C slave structure on bus. 571 * 572 * This function will create I3C device bus structure, initialize the slave according to bus characteristics, install 573 * device information and device control information. 574 * 575 * @param i3cDev Pointer to device structure creating as I3C device. 576 * @param bus Pointer to bus structure. 577 * @param devInfo Pointer to device information structure 578 * @param devControlInfo Pointer to device control information structure. 579 */ 580 status_t I3C_BusI3CSlaveCreate(i3c_device_t *i3cDev, 581 i3c_bus_t *bus, 582 i3c_device_information_t *devInfo, 583 i3c_device_ibi_info_t *ibiInfo, 584 i3c_device_control_info_t *devControlInfo); 585 586 /*! 587 * @brief I3C slave device request Hot Join on bus. 588 * 589 * @param i3cDev Pointer to device structure creating as I3C device. 590 */ 591 status_t I3C_BusSlaveRequestHotJoin(i3c_device_t *i3cDev); 592 593 /*! 594 * @brief I3C slave device request mastership on bus. 595 * 596 * @param i3cDev Pointer to device structure creating as I3C device. 597 */ 598 status_t I3C_BusSlaveRequestMasterShip(i3c_device_t *i3cDev); 599 600 /*! 601 * @brief I3C slave request IBI events. 602 * 603 * @param i3cDev Pointer to device structure creating as I3C device. 604 * @param data Pointer to data buffer to be sent in IBI event. 605 * @param dataSize data size of IBI data. 606 */ 607 status_t I3C_BusSlaveRequestIBI(i3c_device_t *i3cDev, void *data, size_t dataSize); 608 609 /* @} */ 610 611 #if defined(__cplusplus) 612 } 613 #endif 614 615 /*! @}*/ 616 #endif 617