diff mbox series

[RFC,2/3] i2c: mux: gpio: Allow to call i2c_register_spd on a muxed segment

Message ID 6cf1d639-1b5c-4f8a-9ed3-6ff8187329b3@gmail.com
State New
Headers show
Series i2c: Enable calling i2c_register_spd() on muxed bus segments | expand

Commit Message

Heiner Kallweit Dec. 22, 2023, 3:54 p.m. UTC
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.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/i2c/muxes/i2c-mux-gpio.c           | 6 ++++++
 include/linux/platform_data/i2c-mux-gpio.h | 2 ++
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index 6b979a0a6..eafbc4abd 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -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:
diff --git a/include/linux/platform_data/i2c-mux-gpio.h b/include/linux/platform_data/i2c-mux-gpio.h
index 5e4c2c272..cbeb74f92 100644
--- a/include/linux/platform_data/i2c-mux-gpio.h
+++ b/include/linux/platform_data/i2c-mux-gpio.h
@@ -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 */