I3C device driver API
enum i3c_error_code #
I3C error codes
Constants
I3C_ERROR_UNKNOWN: unknown error, usually means the error is not I3C relatedI3C_ERROR_M0: M0 errorI3C_ERROR_M1: M1 errorI3C_ERROR_M2: M2 error
Description
These are the standard error codes as defined by the I3C specification.
When -EIO is returned by the i3c_device_do_i3c_xfers() or
i3c_device_send_hdr_cmds() one can check the error code in
struct_i3c_xfer.err or struct i3c_hdr_cmd.err to get a better idea of
what went wrong.
enum i3c_xfer_mode #
I3C xfer mode ids
Constants
I3C_HDR_DDR: DDR modeI3C_HDR_TSP: TSP modeI3C_HDR_TSL: TSL modeI3C_SDR: SDR mode (NOT HDR mode)
struct i3c_xfer #
I3C data transfer
Definition
;
Members
{unnamed_union}: anonymousrnw: encodes the transfer direction. true for a read, false for a writecmd: Read/Write command in HDR mode, read: 0x80 - 0xff, write: 0x00 - 0x7flen: transfer length in bytes of the transferactual_len: actual length in bytes are transferred by the controllerdata: input/output bufferdata.in: input buffer. Must point to a DMA-able bufferdata.out: output buffer. Must point to a DMA-able buffererr: I3C error code
enum i3c_dcr #
I3C DCR values
Constants
I3C_DCR_GENERIC_DEVICE: generic I3C device
struct i3c_device_info #
I3C device information
Definition
;
Members
pid: Provisioned IDbcr: Bus Characteristic Registerdcr: Device Characteristic Registerstatic_addr: static/I2C addressdyn_addr: dynamic addresshdr_cap: supported HDR modesmax_read_ds: max read speed informationmax_write_ds: max write speed informationmax_ibi_len: max IBI payload lengthmax_read_turnaround: max read turn-around time in micro-secondsmax_read_len: max private SDR read length in bytesmax_write_len: max private SDR write length in bytes
Description
These are all basic information that should be advertised by an I3C device.
Some of them are optional depending on the device type and device
capabilities.
For each I3C slave attached to a master with
i3c_master_add_i3c_dev_locked(), the core will send the relevant CCC command
to retrieve these data.
struct i3c_driver #
I3C device driver
Definition
;
Members
driver: inherit from device_driverprobe: I3C device probe methodremove: I3C device remove methodid_table: I3C device match table. Will be used by the framework to decide which device to bind to this driver
dev_to_i3cdev() #
Returns the I3C device containing dev
Parameters
__dev: device object
Return
a pointer to an I3C device object.
module_i3c_driver() #
Register a module providing an I3C driver
Parameters
__drv: the I3C driver to register
Description
Provide generic init/exit functions that simply register/unregister an I3C driver. Should be used by any driver that does not require extra init/cleanup steps.
i3c_i2c_driver_register() #
int Register an i2c and an i3c driver
Parameters
struct i3c_driver *i3cdrv: the I3C driver to registerstruct i2c_driver *i2cdrv: the I2C driver to register
Description
This function registers both i2cdev and i3cdev, and fails if one of these registrations fails. This is mainly useful for devices that support both I2C and I3C modes. Note that when CONFIG_I3C is not enabled, this function only registers the I2C driver.
Return
0 if both registrations succeeds, a negative error code otherwise.
i3c_i2c_driver_unregister() #
void Unregister an i2c and an i3c driver
Parameters
struct i3c_driver *i3cdrv: the I3C driver to registerstruct i2c_driver *i2cdrv: the I2C driver to register
Description
This function unregisters both i3cdrv and i2cdrv. Note that when CONFIG_I3C is not enabled, this function only unregisters the i2cdrv.
module_i3c_i2c_driver() #
Register a module providing an I3C and an I2C driver
Parameters
__i3cdrv: the I3C driver to register__i2cdrv: the I2C driver to register
Description
Provide generic init/exit functions that simply register/unregister an I3C and an I2C driver. This macro can be used even if CONFIG_I3C is disabled, in this case, only the I2C driver will be registered. Should be used by any driver that does not require extra init/cleanup steps.
struct i3c_ibi_setup #
IBI setup object
Definition
;
Members
max_payload_len: maximum length of the payload associated to an IBI. If one IBI appears to have a payload that is bigger than this number, the IBI will be rejected.num_slots: number of pre-allocated IBI slots. This should be chosen so that the system never runs out of IBI slots, otherwise you'll lose IBIs.handler: IBI handler, every time an IBI is received. This handler is called in a workqueue context. It is allowed to sleep and send new messages on the bus, though it's recommended to keep the processing done there as fast as possible to avoid delaying processing of other queued on the same workqueue.
Description
Temporary structure used to pass information to i3c_device_request_ibi().
This object can be allocated on the stack since i3c_device_request_ibi()
copies every bit of information and do not use it after
i3c_device_request_ibi() has returned.
i3c_device_do_xfers() #
int do I3C transfers directed to a specific device
Parameters
struct i3c_device *dev: device with which the transfers should be donestruct i3c_xfer *xfers: array of transfersint nxfers: number of transfersenum i3c_xfer_mode mode: transfer mode
Description
Initiate one or several private SDR transfers with dev.
This function can sleep and thus cannot be called in atomic context.
Return
- 0 in case of success, a negative error core otherwise.
- -EAGAIN: controller lost address arbitration. Target (IBI, HJ or controller role request) win the bus. Client driver needs to resend the 'xfers' some time later. See I3C spec ver 1.1.1 09-Jun-2021. Section: 5.1.2.2.3.
i3c_device_do_setdasa() #
int do I3C dynamic address assignement with static address
Parameters
struct i3c_device *dev: device with which the DAA should be done
Return
0 in case of success, a negative error core otherwise.
i3c_device_get_info() #
void get I3C device information
Parameters
const struct i3c_device *dev: device we want information onstruct i3c_device_info *info: the information object to fill in
Description
Retrieve I3C dev info.
i3c_device_disable_ibi() #
int Disable IBIs coming from a specific device
Parameters
struct i3c_device *dev: device on which IBIs should be disabled
Description
This function disable IBIs coming from a specific device and wait for all pending IBIs to be processed.
Return
0 in case of success, a negative error core otherwise.
i3c_device_enable_ibi() #
int Enable IBIs coming from a specific device
Parameters
struct i3c_device *dev: device on which IBIs should be enabled
Description
This function enable IBIs coming from a specific device and wait for
all pending IBIs to be processed. This should be called on a device
where i3c_device_request_ibi() has succeeded.
Note that IBIs from this device might be received before this function returns to its caller.
Return
0 in case of success, a negative error core otherwise.
i3c_device_request_ibi() #
int Request an IBI
Parameters
struct i3c_device *dev: device for which we should enable IBIsconst struct i3c_ibi_setup *req: setup requested for this IBI
Description
This function is responsible for pre-allocating all resources needed to
process IBIs coming from dev. When this function returns, the IBI is not
enabled until i3c_device_enable_ibi() is called.
Return
0 in case of success, a negative error core otherwise.
i3c_device_free_ibi() #
void Free all resources needed for IBI handling
Parameters
struct i3c_device *dev: device on which you want to release IBI resources
Description
This function is responsible for de-allocating resources previously
allocated by i3c_device_request_ibi(). It should be called after disabling
IBIs with i3c_device_disable_ibi().
i3cdev_to_dev() #
struct device * Returns the device embedded in i3cdev
Parameters
struct i3c_device *i3cdev: I3C device
Return
a pointer to a device object.
i3c_device_match_id() #
const struct i3c_device_id * Returns the i3c_device_id entry matching i3cdev
Parameters
struct i3c_device *i3cdev: I3C deviceconst struct i3c_device_id *id_table: I3C device match table
Return
a pointer to an i3c_device_id object or NULL if there's no match.
i3c_device_get_supported_xfer_mode() #
u32 Returns the supported transfer mode by connected master controller.
Parameters
struct i3c_device *dev: I3C device
Return
a bit mask, which supported transfer mode, bit position is defined at enum i3c_hdr_mode
i3c_driver_register_with_owner() #
int register an I3C device driver
Parameters
struct i3c_driver *drv: driver to registerstruct module *owner: module that owns this driver
Description
Register drv to the core.
Return
0 in case of success, a negative error core otherwise.
i3c_driver_unregister() #
void unregister an I3C device driver
Parameters
struct i3c_driver *drv: driver to unregister
Description
Unregister drv.