i3c: backport mctp-i3c driver
Subsystems (3)
cover i3c: backport mctp-i3c driver
Backport mctp-i3c driver from torvalds/linux.
Also need to backport the commit to support for bus enumeration & notification for mctp-i3c driver.
Jeremy Kerr (1):
i3c: Add support for bus enumeration & notification
Matt Johnston (1):
mctp i3c: MCTP I3C driver
drivers/i3c/master.c | 35 ++ drivers/net/mctp/Kconfig | 9 + drivers/net/mctp/Makefile | 1 + drivers/net/mctp/mctp-i3c.c | 755 ++++++++++++++++++++++++++++++++++++ include/linux/i3c/master.h | 11 + 5 files changed, 811 insertions(+) create mode 100644 drivers/net/mctp/mctp-i3c.c
Signature · 1 line
2.25.1
PATCH 1/2 i3c: Add support for bus enumeration & notification
From: Jeremy Kerr <[email protected]>
This allows other drivers to be notified when new i3c busses are attached, referring to a whole i3c bus as opposed to individual devices.
--- drivers/i3c/master.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/i3c/master.h | 11 +++++++++++ 2 files changed, 46 insertions(+)
drivers/i3c/master.c +35 -0
@@ -22,6 +22,7 @@static DEFINE_IDR (i3c_bus_idr);static DEFINE_MUTEX (i3c_core_lock);static int __i3c_first_dynamic_bus_num; +static BLOCKING_NOTIFIER_HEAD (i3c_bus_notifier);/** * i3c_bus_maintenance_lock - Lock the bus for a maintenance operation
@@ -453,6 +454,36 @@ static int i3c_bus_init(struct i3c_bus *i3cbus, struct device_node *np)return 0 ; } +void i3c_for_each_bus_locked (int (*fn)(struct i3c_bus *bus,void *data), +void *data) +{ +struct i3c_bus *bus; +int id; + +mutex_lock (&i3c_core_lock); +idr_for_each_entry (&i3c_bus_idr, bus, id) +fn (bus, data); +mutex_unlock (&i3c_core_lock); +} +EXPORT_SYMBOL_GPL (i3c_for_each_bus_locked); + +int i3c_register_notifier (struct notifier_block *nb) +{ +return blocking_notifier_chain_register (&i3c_bus_notifier, nb); +} +EXPORT_SYMBOL_GPL (i3c_register_notifier); + +int i3c_unregister_notifier (struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister (&i3c_bus_notifier, nb); +} +EXPORT_SYMBOL_GPL (i3c_unregister_notifier); + +static void i3c_bus_notify (struct i3c_bus *bus,unsigned int action) +{ +blocking_notifier_call_chain (&i3c_bus_notifier, action, bus); +} +static const char *const i3c_bus_mode_strings[] = { [I3C_BUS_MODE_PURE ] ="pure" , [I3C_BUS_MODE_MIXED_FAST ] ="mixed-fast" ,
@@ -2684,6 +2715,8 @@ int i3c_master_register(struct i3c_master_controller *master,if (ret) goto err_del_dev; +i3c_bus_notify (i3cbus,I3C_NOTIFY_BUS_ADD ); +/* * We're done initializing the bus and the controller, we can now * register I3C devices discovered during the initial DAA.
@@ -2716,6 +2749,8 @@ EXPORT_SYMBOL_GPL(i3c_master_register);*/ void i3c_master_unregister (struct i3c_master_controller *master) { +i3c_bus_notify (&master->bus,I3C_NOTIFY_BUS_REMOVE ); +i3c_master_i2c_adapter_cleanup (master);i3c_master_unregister_i3c_devs (master);i3c_master_bus_cleanup (master);
include/linux/i3c/master.h +11 -0
@@ -24,6 +24,12 @@struct i2c_client ; +/* notifier actions. notifier call data is the struct i3c_bus */ +enum { +I3C_NOTIFY_BUS_ADD , +I3C_NOTIFY_BUS_REMOVE , +}; +struct i3c_master_controller ;struct i3c_bus ;struct i3c_device ;
@@ -652,4 +658,9 @@ void i3c_master_queue_ibi(struct i3c_dev_desc *dev, struct i3c_ibi_slot *slot);struct i3c_ibi_slot *i3c_master_get_free_ibi_slot (struct i3c_dev_desc *dev); +void i3c_for_each_bus_locked (int (*fn)(struct i3c_bus *bus,void *data), +void *data); +int i3c_register_notifier (struct notifier_block *nb); +int i3c_unregister_notifier (struct notifier_block *nb); +#endif /* I3C_MASTER_H */
Signature · 1 line
2.25.1
PATCH 2/2 mctp i3c: MCTP I3C driver
In reply to Delphine CC ChiuFrom: Matt Johnston <[email protected]>
Provides MCTP network transport over an I3C bus, as specified in DMTF DSP0233.
Each I3C bus (with "mctp-controller" devicetree property) gets an "mctpi3cX" net device created. I3C devices are reachable as remote endpoints through that net device. Link layer addressing uses the I3C PID as a fixed hardware address for neighbour table entries.
The driver matches I3C devices that have the MIPI assigned DCR 0xCC for MCTP.
--- drivers/net/mctp/Kconfig | 9 + drivers/net/mctp/Makefile | 1 + drivers/net/mctp/mctp-i3c.c | 755 ++++++++++++++++++++++++++++++++++++ 3 files changed, 765 insertions(+) create mode 100644 drivers/net/mctp/mctp-i3c.c
drivers/net/mctp/Kconfig +9 -0
@@ -33,6 +33,15 @@ config MCTP_TRANSPORT_I2C from DMTF specification DSP0237. A MCTP protocol network device is created for each I2C bus that has been assigned a mctp-i2c device. +config MCTP_TRANSPORT_I3C + tristate "MCTP I3C transport" + depends on I3C + help + Provides a driver to access MCTP devices over I3C transport, + from DMTF specification DSP0233. + A MCTP protocol network device is created for each I3C bus + having a "mctp-controller" devicetree property. + endmenu endif
drivers/net/mctp/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_MCTP_SERIAL) += mctp-serial.o obj-$(CONFIG_MCTP_TRANSPORT_I2C) += mctp-i2c.o +obj-$(CONFIG_MCTP_TRANSPORT_I3C) += mctp-i3c.o
drivers/net/mctp/mctp-i3c.c new file +755 -0
755 lines not on this page · raw message
Signature · 1 line
2.25.1
Hi Delphine,
Quoted 3 lines
Backport mctp-i3c driver from torvalds/linux.
Also need to backport the commit to support for bus enumeration & notification for mctp-i3c driver.
All looks good to me. I have the same set in a backport branch if it helps:
https://github.com/CodeConstruct/linux/tree/backports/mctp/openbmc-v6.6
Cheers,
Jeremy