Skip to content

Commit 893fef0

Browse files
hkallweitAndi Shyti
authored andcommitted
i2c: i801: Call i2c_register_spd for muxed child segments
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 i2c 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> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 5bffbda commit 893fef0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drivers/i2c/busses/i2c-i801.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
#include <linux/ioport.h>
106106
#include <linux/init.h>
107107
#include <linux/i2c.h>
108+
#include <linux/i2c-mux.h>
108109
#include <linux/i2c-smbus.h>
109110
#include <linux/acpi.h>
110111
#include <linux/io.h>
@@ -291,6 +292,7 @@ struct i801_priv {
291292
#if IS_ENABLED(CONFIG_I2C_MUX_GPIO) && defined CONFIG_DMI
292293
struct platform_device *mux_pdev;
293294
struct gpiod_lookup_table *lookup;
295+
struct notifier_block mux_notifier_block;
294296
#endif
295297
struct platform_device *tco_pdev;
296298

@@ -1394,6 +1396,23 @@ static const struct dmi_system_id mux_dmi_table[] = {
13941396
{ }
13951397
};
13961398

1399+
static int i801_notifier_call(struct notifier_block *nb, unsigned long action,
1400+
void *data)
1401+
{
1402+
struct i801_priv *priv = container_of(nb, struct i801_priv, mux_notifier_block);
1403+
struct device *dev = data;
1404+
1405+
if (action != BUS_NOTIFY_ADD_DEVICE ||
1406+
dev->type != &i2c_adapter_type ||
1407+
i2c_root_adapter(dev) != &priv->adapter)
1408+
return NOTIFY_DONE;
1409+
1410+
/* Call i2c_register_spd for muxed child segments */
1411+
i2c_register_spd(to_i2c_adapter(dev));
1412+
1413+
return NOTIFY_OK;
1414+
}
1415+
13971416
/* Setup multiplexing if needed */
13981417
static void i801_add_mux(struct i801_priv *priv)
13991418
{
@@ -1430,6 +1449,9 @@ static void i801_add_mux(struct i801_priv *priv)
14301449
mux_config->gpios[i], "mux", 0);
14311450
gpiod_add_lookup_table(lookup);
14321451

1452+
priv->mux_notifier_block.notifier_call = i801_notifier_call;
1453+
if (bus_register_notifier(&i2c_bus_type, &priv->mux_notifier_block))
1454+
return;
14331455
/*
14341456
* Register the mux device, we use PLATFORM_DEVID_NONE here
14351457
* 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)
14511473

14521474
static void i801_del_mux(struct i801_priv *priv)
14531475
{
1476+
bus_unregister_notifier(&i2c_bus_type, &priv->mux_notifier_block);
14541477
platform_device_unregister(priv->mux_pdev);
14551478
gpiod_remove_lookup_table(priv->lookup);
14561479
}

0 commit comments

Comments
 (0)