Professional Documents
Culture Documents
I3C in Tomorrow's Designs: Miqu' El Raynal
I3C in Tomorrow's Designs: Miqu' El Raynal
I3C in Tomorrow's Designs: Miqu' El Raynal
I3C in tomorrow’s
designs
Miquèl Raynal
miquel@bootlin.com
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 1/1
Miquèl Raynal
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 2/1
Embedded Linux Conference, Fall 2021
Miquèl Raynal
miquel@bootlin.com
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 3/1
Electrical engineering 101
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 4/1
Electrical engineering 101
I Pick one:
I OneWire? Too simple/slow?
I RS232? Really?
I USB? Really suitable for embedded systems?
I I2C? Why not?
I SPI? Yeah, still trendy?
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 5/1
Electrical engineering 101
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 6/1
State of the art
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 8/1
Backward compatibility with I2C
I Main goal:
I Ease acceptance
I Improve the re-usability of existing devices
I Designed with I2C in mind
I At physical level:
I Compatible Voltage levels
I A clock and a data line
I Adaptable clock frequencies
I Support for open-drain output
I At logical level:
I 7-bits addressing
I Comparable S/Sr/P/ACK/NACK behavior
I Use tricks to talk to I2C and I3C devices on the same bus
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 9/1
Embedded Linux Conference, Fall 2021
Miquèl Raynal
miquel@bootlin.com
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 10/1
Achieving higher frequencies
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 12/1
Pure I3C frequencies
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 13/1
Bandwidth: mixed modes
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 15/1
Common Command Codes (CCC)
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 16/1
Dynamic Address Assignment (DAA)
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 17/1
Device unique identification
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 19/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 20/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 21/1
DAA
The target with the highest PID looses the arbitration (thanks to
the open-drain nature of the SDA line during this exchange).
The winning device sends its PID followed by its BCR and DCR.
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 22/1
DAA
The controller sends a 7-bit address to the winning device that will
become its own dynamic address.
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 23/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 24/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 25/1
DAA
All devices that have not yet received a dynamic address should
ACK it again.
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 26/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 27/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 28/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 29/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 30/1
DAA
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 31/1
IBIs
I Device driven In-Band Interrupts
I The device can raise an interrupt in the following conditions:
I The controller initiate a start condition: SDA low then SCL low
I The bus is idle, the device asserts SDA low and waits for the
controller to acknowledge the interrupt by pulling SCL low to
end the start condition
I Device sends its address with a RnW bit to 1
I Priority arbitration depends on the dynamic address
I Address exchange in open drain mode
I 0 has a higher “priority” than 1
I Lowest address ⇒ highest priority
I Controller ACKs or NACKs the interrupt
I Some devices may also provide a mandatory byte that the
controller must read
I The controller decides to emit a Sr and continue talking on
the bus or emits a P
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 32/1
Hot-join
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 33/1
Controller handover
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 34/1
Time synchronization (I3C v1.1)
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 35/1
Reset (I3C v1.1)
I Global reset:
I Upon error showing that the bus is currently stuck, the I3C
controller is capable of sending a global reset over the bus
I Only supposed to reset the bus controller of each device
I Implies restarting the DAA procedure
I Targeted reset:
I A target might request to be reset
I Saves an extra line on the final design
I Involves asking all the devices but the one requesting the reset
to discard the comming “reset pattern”
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 36/1
Reset (I3C v1.1)
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 37/1
Bulk Transport (I3C v1.1)
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 38/1
Multi-Lane (I3C v1.1)
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 39/1
Embedded Linux Conference, Fall 2021
Linux API
Miquèl Raynal
miquel@bootlin.com
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 40/1
The I3C framework
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 41/1
Design choices
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 42/1
The I3C bus infrastructure
include/linux/i3c/master.h
struct i3c_bus {
struct i3c_dev_desc *cur_master;
int id;
unsigned long addrslots[((I2C_MAX_ADDR+1) * 2) / BITS_PER_LONG];
enum i3c_bus_mode mode;
struct {
unsigned long i3c;
unsigned long i2c;
} scl_rate;
struct {
struct list_head i3c;
struct list_head i2c;
} devs;
struct rw_semaphore lock;
};
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 43/1
The I3C controller structure
include/linux/i3c/master.h
struct i3c_master_controller {
struct device dev;
struct i3c_dev_desc *this;
struct i2c_adapter i2c;
const struct i3c_master_controller_ops *ops;
unsigned int secondary : 1;
unsigned int init_done : 1;
struct {
struct list_head i3c;
struct list_head i2c;
} boardinfo;
struct i3c_bus bus;
struct workqueue_struct *wq;
};
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 44/1
The I3C controller interface
include/linux/i3c/master.h
struct i3c_master_controller_ops {
/* Bus management */
int (*bus_init)(struct i3c_master_controller *master);
void (*bus_cleanup)(struct i3c_master_controller *master);
int (*do_daa)(struct i3c_master_controller *master);
/* I3C devices management */
int (*attach_i3c_dev)(struct i3c_dev_desc *dev);
int (*reattach_i3c_dev)(struct i3c_dev_desc *dev, u8 old_dyn_addr);
void (*detach_i3c_dev)(struct i3c_dev_desc *dev);
/* CCCs transactions */
bool (*supports_ccc_cmd)(struct i3c_master_controller *master,
const struct i3c_ccc_cmd *cmd);
int (*send_ccc_cmd)(struct i3c_master_controller *master, struct i3c_ccc_cmd *cmd);
/* Private SDR transfers */
int (*priv_xfers)(struct i3c_dev_desc *dev, struct i3c_priv_xfer *xfers, int nxfers);
/* I2C devices management */
int (*attach_i2c_dev)(struct i2c_dev_desc *dev);
void (*detach_i2c_dev)(struct i2c_dev_desc *dev);
int (*i2c_xfers)(struct i2c_dev_desc *dev, const struct i2c_msg *xfers, int nxfers);
/* IBI management */
int (*request_ibi)(struct i3c_dev_desc *dev, const struct i3c_ibi_setup *req);
void (*free_ibi)(struct i3c_dev_desc *dev);
int (*enable_ibi)(struct i3c_dev_desc *dev);
int (*disable_ibi)(struct i3c_dev_desc *dev);
void (*recycle_ibi_slot)(struct i3c_dev_desc *dev, struct i3c_ibi_slot *slot);
};
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 45/1
Additional information about bus initialization
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 46/1
The device interface
include/linux/i3c/device.h
struct i3c_device {
// Generic 'device-model' device structure
struct device dev;
// Internal representation of an I3C device
struct i3c_dev_desc *desc;
// Representation of the I3C bus, not tight to a specific
// controller due to controller handover possibilities
struct i3c_bus *bus;
};
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 47/1
An I3C device driver
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 48/1
Interacting with the I3C device
SDR transfers
u8 reg = 0x5, values[2];
struct i3c_priv_xfer xfers[2] = {
{
.flags = 0,
.len = 1,
.data.out = ®,
},
{
.flags = I3C_PRIV_XFER_READ,
.len = 2,
.data.in = values,
},
};
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 49/1
Using IBIs
...
ret = i3c_device_request_ibi(dev, &ibireq);
if (ret)
return ret;
ret = i3c_device_enable_ibi(dev);
if (ret)
return ret;
...
}
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 51/1
Thanks!
Questions? Suggestions?
Comments?
Miquèl Raynal
miquel@bootlin.com
- Kernel, drivers and embedded Linux - Development, consulting, training and support - https://bootlin.com 52/1