Skip to content

Commit f19cc49

Browse files
committed
i2c: i801: Call i2c_register_spd for muxed child segments
JIRA: https://issues.redhat.com/browse/RHEL-47426 commit 893fef0 Author: Heiner Kallweit <hkallweit1@gmail.com> Date: Tue Mar 26 21:42:44 2024 +0100 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> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 931dc97 commit f19cc49

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
@@ -106,6 +106,7 @@
106106
#include <linux/ioport.h>
107107
#include <linux/init.h>
108108
#include <linux/i2c.h>
109+
#include <linux/i2c-mux.h>
109110
#include <linux/i2c-smbus.h>
110111
#include <linux/acpi.h>
111112
#include <linux/io.h>
@@ -293,6 +294,7 @@ struct i801_priv {
293294
#if IS_ENABLED(CONFIG_I2C_MUX_GPIO) && defined CONFIG_DMI
294295
struct platform_device *mux_pdev;
295296
struct gpiod_lookup_table *lookup;
297+
struct notifier_block mux_notifier_block;
296298
#endif
297299
struct platform_device *tco_pdev;
298300

@@ -1398,6 +1400,23 @@ static const struct dmi_system_id mux_dmi_table[] = {
13981400
{ }
13991401
};
14001402

1403+
static int i801_notifier_call(struct notifier_block *nb, unsigned long action,
1404+
void *data)
1405+
{
1406+
struct i801_priv *priv = container_of(nb, struct i801_priv, mux_notifier_block);
1407+
struct device *dev = data;
1408+
1409+
if (action != BUS_NOTIFY_ADD_DEVICE ||
1410+
dev->type != &i2c_adapter_type ||
1411+
i2c_root_adapter(dev) != &priv->adapter)
1412+
return NOTIFY_DONE;
1413+
1414+
/* Call i2c_register_spd for muxed child segments */
1415+
i2c_register_spd(to_i2c_adapter(dev));
1416+
1417+
return NOTIFY_OK;
1418+
}
1419+
14011420
/* Setup multiplexing if needed */
14021421
static void i801_add_mux(struct i801_priv *priv)
14031422
{
@@ -1434,6 +1453,9 @@ static void i801_add_mux(struct i801_priv *priv)
14341453
mux_config->gpios[i], "mux", 0);
14351454
gpiod_add_lookup_table(lookup);
14361455

1456+
priv->mux_notifier_block.notifier_call = i801_notifier_call;
1457+
if (bus_register_notifier(&i2c_bus_type, &priv->mux_notifier_block))
1458+
return;
14371459
/*
14381460
* Register the mux device, we use PLATFORM_DEVID_NONE here
14391461
* because since we are referring to the GPIO chip by name we are
@@ -1455,6 +1477,7 @@ static void i801_add_mux(struct i801_priv *priv)
14551477

14561478
static void i801_del_mux(struct i801_priv *priv)
14571479
{
1480+
bus_unregister_notifier(&i2c_bus_type, &priv->mux_notifier_block);
14581481
platform_device_unregister(priv->mux_pdev);
14591482
gpiod_remove_lookup_table(priv->lookup);
14601483
}

0 commit comments

Comments
 (0)