public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: i801: Call i2c_register_spd for muxed child segments
@ 2024-03-26 20:42 Heiner Kallweit
  2024-03-31  0:27 ` Andi Shyti
  0 siblings, 1 reply; 4+ messages in thread
From: Heiner Kallweit @ 2024-03-26 20:42 UTC (permalink / raw)
  To: Wolfram Sang, Andi Shyti, Jean Delvare; +Cc: linux-i2c@vger.kernel.org

Once the gpio mux driver binds to the "i2c-mux-gpio" platform device,
this creates the i2c adapters for the muxed child segments.
We can use the bus notifier mechanism to check for creation of the
child i2d adapters, and call i2c_register_spd() for them. This allows
to detect all DIMM's on systems with more than 8 memory slots.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
- Rebased version of a RFC patch
- Sent as RFT to lkml, but no feedback after 3 weeks.
  So give it enough time in linux-next before 6.10-rc1.
---
 drivers/i2c/busses/i2c-i801.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 79870dd7a..4294c0c63 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -105,6 +105,7 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/i2c-mux.h>
 #include <linux/i2c-smbus.h>
 #include <linux/acpi.h>
 #include <linux/io.h>
@@ -291,6 +292,7 @@ struct i801_priv {
 #if IS_ENABLED(CONFIG_I2C_MUX_GPIO) && defined CONFIG_DMI
 	struct platform_device *mux_pdev;
 	struct gpiod_lookup_table *lookup;
+	struct notifier_block mux_notifier_block;
 #endif
 	struct platform_device *tco_pdev;
 
@@ -1394,6 +1396,23 @@ static const struct dmi_system_id mux_dmi_table[] = {
 	{ }
 };
 
+static int i801_notifier_call(struct notifier_block *nb, unsigned long action,
+			      void *data)
+{
+	struct i801_priv *priv = container_of(nb, struct i801_priv, mux_notifier_block);
+	struct device *dev = data;
+
+	if (action != BUS_NOTIFY_ADD_DEVICE ||
+	    dev->type != &i2c_adapter_type ||
+	    i2c_root_adapter(dev) != &priv->adapter)
+		return NOTIFY_DONE;
+
+	/* Call i2c_register_spd for muxed child segments */
+	i2c_register_spd(to_i2c_adapter(dev));
+
+	return NOTIFY_OK;
+}
+
 /* Setup multiplexing if needed */
 static void i801_add_mux(struct i801_priv *priv)
 {
@@ -1430,6 +1449,9 @@ static void i801_add_mux(struct i801_priv *priv)
 					       mux_config->gpios[i], "mux", 0);
 	gpiod_add_lookup_table(lookup);
 
+	priv->mux_notifier_block.notifier_call = i801_notifier_call;
+	if (bus_register_notifier(&i2c_bus_type, &priv->mux_notifier_block))
+		return;
 	/*
 	 * Register the mux device, we use PLATFORM_DEVID_NONE here
 	 * because since we are referring to the GPIO chip by name we are
@@ -1451,6 +1473,7 @@ static void i801_add_mux(struct i801_priv *priv)
 
 static void i801_del_mux(struct i801_priv *priv)
 {
+	bus_unregister_notifier(&i2c_bus_type, &priv->mux_notifier_block);
 	platform_device_unregister(priv->mux_pdev);
 	gpiod_remove_lookup_table(priv->lookup);
 }
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: i801: Call i2c_register_spd for muxed child segments
  2024-03-26 20:42 [PATCH] i2c: i801: Call i2c_register_spd for muxed child segments Heiner Kallweit
@ 2024-03-31  0:27 ` Andi Shyti
  2024-04-03 19:18   ` Heiner Kallweit
  0 siblings, 1 reply; 4+ messages in thread
From: Andi Shyti @ 2024-03-31  0:27 UTC (permalink / raw)
  To: Wolfram Sang, Jean Delvare, Heiner Kallweit; +Cc: linux-i2c

Hi

On Tue, 26 Mar 2024 21:42:44 +0100, Heiner Kallweit wrote:
> Once the gpio mux driver binds to the "i2c-mux-gpio" platform device,
> this creates the i2c adapters for the muxed child segments.
> We can use the bus notifier mechanism to check for creation of the
> child i2d adapters, and call i2c_register_spd() for them. This allows
> to detect all DIMM's on systems with more than 8 memory slots.
> 
> 
> [...]

Applied to i2c/i2c-host on

git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Thank you,
Andi

Patches applied
===============
[1/1] i2c: i801: Call i2c_register_spd for muxed child segments
      commit: d33bd3b707f476efcb907a7fd3ba3352f49775ed


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: i801: Call i2c_register_spd for muxed child segments
  2024-03-31  0:27 ` Andi Shyti
@ 2024-04-03 19:18   ` Heiner Kallweit
  2024-04-03 23:24     ` Andi Shyti
  0 siblings, 1 reply; 4+ messages in thread
From: Heiner Kallweit @ 2024-04-03 19:18 UTC (permalink / raw)
  To: Andi Shyti, Wolfram Sang, Jean Delvare; +Cc: linux-i2c

On 31.03.2024 01:27, Andi Shyti wrote:
> Hi
> 
> On Tue, 26 Mar 2024 21:42:44 +0100, Heiner Kallweit wrote:
>> Once the gpio mux driver binds to the "i2c-mux-gpio" platform device,
>> this creates the i2c adapters for the muxed child segments.
>> We can use the bus notifier mechanism to check for creation of the
>> child i2d adapters, and call i2c_register_spd() for them. This allows
>> to detect all DIMM's on systems with more than 8 memory slots.
>>
>>
>> [...]
> 
> Applied to i2c/i2c-host on
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
> 
I don't see the patch in this repo. Technical problem or any other
reason I may be missing?

> Thank you,
> Andi
> 
Heiner

> Patches applied
> ===============
> [1/1] i2c: i801: Call i2c_register_spd for muxed child segments
>       commit: d33bd3b707f476efcb907a7fd3ba3352f49775ed
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: i801: Call i2c_register_spd for muxed child segments
  2024-04-03 19:18   ` Heiner Kallweit
@ 2024-04-03 23:24     ` Andi Shyti
  0 siblings, 0 replies; 4+ messages in thread
From: Andi Shyti @ 2024-04-03 23:24 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: Wolfram Sang, Jean Delvare, linux-i2c

Hi Heiner,

On Wed, Apr 03, 2024 at 09:18:04PM +0200, Heiner Kallweit wrote:
> On 31.03.2024 01:27, Andi Shyti wrote:
> > Hi
> > 
> > On Tue, 26 Mar 2024 21:42:44 +0100, Heiner Kallweit wrote:
> >> Once the gpio mux driver binds to the "i2c-mux-gpio" platform device,
> >> this creates the i2c adapters for the muxed child segments.
> >> We can use the bus notifier mechanism to check for creation of the
> >> child i2d adapters, and call i2c_register_spd() for them. This allows
> >> to detect all DIMM's on systems with more than 8 memory slots.
> >>
> >>
> >> [...]
> > 
> > Applied to i2c/i2c-host on
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
> > 
> I don't see the patch in this repo. Technical problem or any other
> reason I may be missing?

It's there, so that either I forgot to push it or you checked
something else. In any case, thanks for checking and please,
don't hesitate to ping when you see something unusual.

Andi

PS I'm setting up some new scripts for handling the whole thing,
so that it's likely that sometimes might I miss the order of
things :-)

> > Thank you,
> > Andi
> > 
> Heiner
> 
> > Patches applied
> > ===============
> > [1/1] i2c: i801: Call i2c_register_spd for muxed child segments
> >       commit: d33bd3b707f476efcb907a7fd3ba3352f49775ed
> > 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-03 23:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-26 20:42 [PATCH] i2c: i801: Call i2c_register_spd for muxed child segments Heiner Kallweit
2024-03-31  0:27 ` Andi Shyti
2024-04-03 19:18   ` Heiner Kallweit
2024-04-03 23:24     ` Andi Shyti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox