i2c: Enable calling i2c_register_spd() on muxed bus segments
Subsystems (5)
cover i2c: Enable calling i2c_register_spd() on muxed bus segments
This series is based on a discussion with Jean on how to get rid of class-based device probing on muxed segments of a i801-controlled smbus. i2c_register_spd() could be further optimized for the case that it's called on a muxed segment, for now go with the minimum of needed changes.
I don't have such a system with a muxed smbus, therefore the series is compile-tested only.
Heiner Kallweit (3):
i2c: smbus: Prepare i2c_register_spd for use on muxed segments
i2c: mux: gpio: Allow to call i2c_register_spd on a muxed segment
i2c: i801: Call i2c_register_spd() on muxed bus segments
drivers/i2c/busses/i2c-i801.c | 1 + drivers/i2c/i2c-smbus.c | 18 +++++++++++------- drivers/i2c/muxes/i2c-mux-gpio.c | 6 ++++++ include/linux/platform_data/i2c-mux-gpio.h | 2 ++ 4 files changed, 20 insertions(+), 7 deletions(-)
Signature · 1 line
2.43.0
RFC PATCH 1/3 i2c: smbus: Prepare i2c_register_spd for use on muxed segments
If this is an adapter on a muxed bus segment, assume that each segment is connected to a subset of the (> 8) overall memory slots. In this case let's probe the maximum of 8 slots, however stop if the number of overall populated slots is reached.
If we're not on a muxed segment and the total number of slots is > 8, report an error, because then not all SPD eeproms can be addressed. Presumably the bus is muxed, but the mux config is missing.
--- drivers/i2c/i2c-smbus.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/i2c/i2c-smbus.c +11 -7
@@ -351,13 +351,17 @@ void i2c_register_spd(struct i2c_adapter *adap)if (!dimm_count)return ; -dev_info (&adap->dev,"%d/%d memory slots populated (from DMI)\n" , - dimm_count, slot_count); - -if (slot_count >8 ) { -dev_warn (&adap->dev, -"Systems with more than 8 memory slots not supported yet, not instantiating SPD\n" ); -return ; +/* Check whether we're a child adapter on a muxed segment */ +if (i2c_parent_is_i2c_adapter (adap)) { + slot_count =8 ; + }else { +if (slot_count >8 ) { +dev_err (&adap->dev, +"More than 8 memory slots on a single bus, mux config missing?\n" ); +return ; + } +dev_info (&adap->dev,"%d/%d memory slots populated (from DMI)\n" , + dimm_count, slot_count); }/*
Signature · 1 line
2.43.0
RFC PATCH 2/3 i2c: mux: gpio: Allow to call i2c_register_spd on a muxed segment
Now that i2c_register_spd() has been extended for use on muxed segments, provide the parent with an option to instruct the child adapters to call i2c_register_spd() for each segment.
--- drivers/i2c/muxes/i2c-mux-gpio.c | 6 ++++++ include/linux/platform_data/i2c-mux-gpio.h | 2 ++ 2 files changed, 8 insertions(+)
drivers/i2c/muxes/i2c-mux-gpio.c +6 -0
@@ -7,6 +7,7 @@#include <linux/i2c.h> #include <linux/i2c-mux.h> +#include <linux/i2c-smbus.h> #include <linux/overflow.h> #include <linux/platform_data/i2c-mux-gpio.h> #include <linux/platform_device.h>
@@ -216,6 +217,11 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev)dev_info (&pdev->dev,"%d port mux on %s adapter\n" , mux->data.n_values, parent->name); +if (mux->data.register_spd) { +for (i =0 ; i < muxc->num_adapters; i++) +i2c_register_spd (muxc->adapter[i]); + } +return 0 ; add_adapter_failed:
include/linux/platform_data/i2c-mux-gpio.h +2 -0
@@ -20,6 +20,7 @@* @n_values: Number of multiplexer positions (busses to instantiate) * @classes: Optional I2C auto-detection classes * @idle: Bitmask to write to MUX when idle or GPIO_I2CMUX_NO_IDLE if not used +* @register_spd: call i2c_register_spd for the child adapters on muxed segments */ struct i2c_mux_gpio_platform_data {int parent;
@@ -28,6 +29,7 @@ struct i2c_mux_gpio_platform_data {int n_values;const unsigned *classes;unsigned idle; + unsigned int register_spd:1; };#endif /* _LINUX_I2C_MUX_GPIO_H */
Signature · 1 line
2.43.0
RFC PATCH 3/3 i2c: i801: Call i2c_register_spd() on muxed bus segments
In reply to Heiner KallweitInstruct child adapters to call i2c_register_spd() for each muxed bus segment.
--- drivers/i2c/busses/i2c-i801.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-i801.c +1 -0
@@ -1402,6 +1402,7 @@ static void i801_add_mux(struct i801_priv *priv) gpio_data.n_values = mux_config->n_values; gpio_data.classes = mux_config->classes; gpio_data.idle =I2C_MUX_GPIO_NO_IDLE ; + gpio_data.register_spd =1 ;/* Register GPIO descriptor lookup table */ lookup = devm_kzalloc(dev,
Signature · 1 line
2.43.0