* [PATCH v3 0/9] Congatec Board Controller: Add storage devices support
@ 2026-09-11 18:48 Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 1/9] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH),
stable, Sashiko
For this v3, I deeply reworked the series.
I2C buses are now defined in the MFD driver, and all I2C bus parameters are
passed to the i2c-cgbc driver through platform data. The cell ID is no
longer used as the (BC) bus ID; the bus ID is now stored in platform data,
which allows switching the child devices to PLATFORM_DEVID_AUTO.
I also declared the I2C buses, as well as the devices attached to them, in
the MFD core. The MFD driver knows exactly which board it is running on.
This will be useful when adding support for other I2C buses, so they can be
limited based on the board. This also makes the i2c-cgbc driver more
generic.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
Changes in v3:
- rebased on v7.3-rc2
- use PLATFORM_DEVID_AUTO for child devices
- move I2C bus and I2C device definition in the MFD driver
- Link to v2: https://patch.msgid.link/20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com
Changes in v2:
- i2c: fix typo in CGBC BIOS EEPROM label.
- mfd: make cgbc_devs const
- Link to v1: https://patch.msgid.link/20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@bootlin.com
To: Thomas Richard <thomas.richard@bootlin.com>
To: Lee Jones <lee@kernel.org>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Werner Gartner <Werner.Gartner@congatec.com>
Cc: mfd@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
---
Thomas Richard (congatec GmbH) (9):
mfd: cgbc: Fix use of negative error code as valid session handle
mfd: cgbc: Add I2C platform data
i2c: cgbc: Use plateform data to get bus ID and adapter name
mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration
mfd: cgbc: Use real I2C bus names
i2c: cgbc: Add support for fixed frequency buses
mfd: cgbc: Add virtual I2C bus support
mfd: cgbc: Add virtual storage devices on the virtual I2C bus
i2c: cgbc: Register known I2C devices on the bus
MAINTAINERS | 1 +
drivers/i2c/busses/i2c-cgbc.c | 109 ++++++++++---------
drivers/mfd/cgbc-core.c | 187 ++++++++++++++++++++++++++++++---
include/linux/platform_data/i2c-cgbc.h | 28 +++++
4 files changed, 258 insertions(+), 67 deletions(-)
---
base-commit: df2908090cda368b01ff43709f51890076c56157
change-id: 20260717-cgbc-i2c-storage-devices-support-b3ee7cea3320
Best regards,
--
Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 1/9] mfd: cgbc: Fix use of negative error code as valid session handle
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 2/9] mfd: cgbc: Add I2C platform data Thomas Richard (congatec GmbH)
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH),
stable, Sashiko
The cgbc_session_command() return value was directly cast to u8 and used
as session handle without error checking. Casting a negative error to u8
produces a valid-looking session handle. So check if return value is
positive before to cast and use it.
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260713-cgbc-core-fix-cgbc-remove-v1-1-79274ad62b3a%40bootlin.com?part=1
Fixes: 6f1067cfbee7 ("mfd: Add Congatec Board Controller driver")
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/mfd/cgbc-core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index 2becaf797646..4a409234e66c 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -103,7 +103,11 @@ static int cgbc_session_request(struct cgbc_device_data *cgbc)
if (ret)
return dev_err_probe(cgbc->dev, ret, "device not found or not ready\n");
- cgbc->session = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
+ ret = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
+ if (ret < 0)
+ return dev_err_probe(cgbc->dev, ret, "session handle request timed out\n");
+
+ cgbc->session = ret;
/* The Board Controller sent us a wrong session handle, we cannot communicate with it */
if (cgbc->session < CGBC_SESSION_VALID_MIN || cgbc->session > CGBC_SESSION_VALID_MAX)
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 2/9] mfd: cgbc: Add I2C platform data
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 1/9] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
2026-09-23 15:02 ` Lee Jones
2026-09-11 18:48 ` [PATCH v3 3/9] i2c: cgbc: Use plateform data to get bus ID and adapter name Thomas Richard (congatec GmbH)
` (6 subsequent siblings)
8 siblings, 1 reply; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH)
Define I2C platform data for each I2C bus in the cgbc MFD driver. Platform
data passes per-bus parameters to the I2C driver, rather than being defined
inside the i2c-cgbc driver itself. This makes the i2c-cgbc driver more
generic.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
MAINTAINERS | 1 +
drivers/mfd/cgbc-core.c | 39 ++++++++++++++++++++++++++--------
include/linux/platform_data/i2c-cgbc.h | 22 +++++++++++++++++++
3 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 6215fcb07770..561f102c2541 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6621,6 +6621,7 @@ F: drivers/mfd/cgbc-core.c
F: drivers/video/backlight/cgbc_bl.c
F: drivers/watchdog/cgbc_wdt.c
F: include/linux/mfd/cgbc.h
+F: include/linux/platform_data/i2c-cgbc.h
CONSOLE SUBSYSTEM
M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index 4a409234e66c..321fa3fff2ac 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -16,6 +16,7 @@
#include <linux/mfd/cgbc.h>
#include <linux/mfd/core.h>
#include <linux/module.h>
+#include <linux/platform_data/i2c-cgbc.h>
#include <linux/platform_device.h>
#include <linux/sysfs.h>
@@ -55,6 +56,35 @@
static struct platform_device *cgbc_pdev;
+static const struct cgbc_i2c_platform_data cgbc_i2c_gp_pdata = {
+ .name = "Congatec General Purpose I2C adapter",
+ .cgbc_bus_id = 0,
+};
+
+static const struct cgbc_i2c_platform_data cgbc_i2c_pm_pdata = {
+ .name = "Congatec Power Management I2C adapter",
+ .cgbc_bus_id = 4,
+};
+
+static const struct mfd_cell cgbc_devs[] = {
+ { .name = "cgbc-backlight" },
+ { .name = "cgbc-gpio" },
+ { .name = "cgbc-hwmon" },
+ {
+ .name = "cgbc-i2c",
+ .id = 1,
+ .platform_data = &cgbc_i2c_gp_pdata,
+ .pdata_size = sizeof(cgbc_i2c_gp_pdata),
+ },
+ {
+ .name = "cgbc-i2c",
+ .id = 2,
+ .platform_data = &cgbc_i2c_pm_pdata,
+ .pdata_size = sizeof(cgbc_i2c_pm_pdata),
+ },
+ { .name = "cgbc-wdt" },
+};
+
/* Wait the Board Controller is ready to receive some session commands */
static int cgbc_wait_device(struct cgbc_device_data *cgbc)
{
@@ -235,15 +265,6 @@ int cgbc_command(struct cgbc_device_data *cgbc, void *cmd, unsigned int cmd_size
}
EXPORT_SYMBOL_GPL(cgbc_command);
-static struct mfd_cell cgbc_devs[] = {
- { .name = "cgbc-wdt" },
- { .name = "cgbc-gpio" },
- { .name = "cgbc-i2c", .id = 1 },
- { .name = "cgbc-i2c", .id = 2 },
- { .name = "cgbc-hwmon" },
- { .name = "cgbc-backlight" },
-};
-
static int cgbc_map(struct cgbc_device_data *cgbc)
{
struct device *dev = cgbc->dev;
diff --git a/include/linux/platform_data/i2c-cgbc.h b/include/linux/platform_data/i2c-cgbc.h
new file mode 100644
index 000000000000..4465e8a7b40e
--- /dev/null
+++ b/include/linux/platform_data/i2c-cgbc.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * i2c-cgbc interface to platform code
+ *
+ * Copyright (C) 2026 congatec GmbH
+ * Author: Thomas Richard <thomas.richard@bootlin.com>
+ */
+
+#ifndef _LINUX_I2C_CGBC_H
+#define _LINUX_I2C_CGBC_H
+
+/**
+ * struct cgbc_platform_data - Platform data of the CGBC I2C driver
+ * @name: I2C adapter name
+ * @cgbc_bus_id: I2C bus ID (from Board Controller point of view)
+ */
+struct cgbc_i2c_platform_data {
+ const char *name;
+ int cgbc_bus_id;
+};
+
+#endif /* _LINUX_I2C_CGBC_H */
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 3/9] i2c: cgbc: Use plateform data to get bus ID and adapter name
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 1/9] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 2/9] mfd: cgbc: Add I2C platform data Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 4/9] mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration Thomas Richard (congatec GmbH)
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH)
Obtain the bus ID (from the BC point of view) and adapter name from
platform data. This allows the specific definitions to be removed, leaving
only a generic adapter definition.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/i2c/busses/i2c-cgbc.c | 69 ++++++++++++++++---------------------------
1 file changed, 26 insertions(+), 43 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cgbc.c b/drivers/i2c/busses/i2c-cgbc.c
index 25a74fa51aa0..d388e07aad84 100644
--- a/drivers/i2c/busses/i2c-cgbc.c
+++ b/drivers/i2c/busses/i2c-cgbc.c
@@ -10,11 +10,9 @@
#include <linux/iopoll.h>
#include <linux/mfd/cgbc.h>
#include <linux/module.h>
+#include <linux/platform_data/i2c-cgbc.h>
#include <linux/platform_device.h>
-#define CGBC_I2C_PRIMARY_BUS_ID 0
-#define CGBC_I2C_PM_BUS_ID 4
-
#define CGBC_I2C_CMD_START 0x40
#define CGBC_I2C_CMD_STAT 0x48
#define CGBC_I2C_CMD_DATA 0x50
@@ -60,11 +58,6 @@ enum cgbc_i2c_state {
CGBC_I2C_STATE_ERROR,
};
-struct i2c_algo_cgbc_data {
- u8 bus_id;
- unsigned long read_maxtime_us;
-};
-
struct cgbc_i2c_data {
struct device *dev;
struct cgbc_device_data *cgbc;
@@ -73,6 +66,8 @@ struct cgbc_i2c_data {
int nmsgs;
int pos;
enum cgbc_i2c_state state;
+ u8 bus_id;
+ unsigned long read_maxtime_us;
};
struct cgbc_i2c_transfer {
@@ -115,10 +110,9 @@ static unsigned int cgbc_i2c_reg_to_freq(u8 reg)
static int cgbc_i2c_get_status(struct i2c_adapter *adap)
{
- struct i2c_algo_cgbc_data *algo_data = adap->algo_data;
struct cgbc_i2c_data *i2c = i2c_get_adapdata(adap);
struct cgbc_device_data *cgbc = i2c->cgbc;
- u8 cmd = CGBC_I2C_CMD_STAT | algo_data->bus_id;
+ u8 cmd = CGBC_I2C_CMD_STAT | i2c->bus_id;
u8 status;
int ret;
@@ -132,7 +126,6 @@ static int cgbc_i2c_get_status(struct i2c_adapter *adap)
static int cgbc_i2c_set_frequency(struct i2c_adapter *adap,
unsigned int bus_frequency)
{
- struct i2c_algo_cgbc_data *algo_data = adap->algo_data;
struct cgbc_i2c_data *i2c = i2c_get_adapdata(adap);
struct cgbc_device_data *cgbc = i2c->cgbc;
u8 cmd[2], data;
@@ -144,7 +137,7 @@ static int cgbc_i2c_set_frequency(struct i2c_adapter *adap,
bus_frequency = I2C_MAX_STANDARD_MODE_FREQ;
}
- cmd[0] = CGBC_I2C_CMD_SPEED | algo_data->bus_id;
+ cmd[0] = CGBC_I2C_CMD_SPEED | i2c->bus_id;
cmd[1] = cgbc_i2c_freq_to_reg(bus_frequency);
ret = cgbc_command(cgbc, &cmd, sizeof(cmd), &data, 1, NULL);
@@ -170,7 +163,7 @@ static int cgbc_i2c_set_frequency(struct i2c_adapter *adap,
* can be read by a command is CGBC_I2C_READ_MAX_LEN.
* Therefore, calculate the max time to properly size the timeout.
*/
- algo_data->read_maxtime_us = (BITS_PER_BYTE + 1) * CGBC_I2C_READ_MAX_LEN
+ i2c->read_maxtime_us = (BITS_PER_BYTE + 1) * CGBC_I2C_READ_MAX_LEN
* USEC_PER_SEC / bus_frequency;
return 0;
@@ -200,7 +193,6 @@ static unsigned int cgbc_i2c_xfer_to_cmd(struct cgbc_i2c_transfer xfer, u8 *cmd)
static int cgbc_i2c_xfer_msg(struct i2c_adapter *adap)
{
- struct i2c_algo_cgbc_data *algo_data = adap->algo_data;
struct cgbc_i2c_data *i2c = i2c_get_adapdata(adap);
struct cgbc_device_data *cgbc = i2c->cgbc;
struct i2c_msg *msg = i2c->msg;
@@ -210,7 +202,7 @@ static int cgbc_i2c_xfer_msg(struct i2c_adapter *adap)
u8 cmd_data;
struct cgbc_i2c_transfer xfer = {
- .bus_id = algo_data->bus_id,
+ .bus_id = i2c->bus_id,
.addr = i2c_8bit_addr_from_msg(msg),
};
@@ -268,11 +260,11 @@ static int cgbc_i2c_xfer_msg(struct i2c_adapter *adap)
ret = read_poll_timeout(cgbc_i2c_get_status, ret,
ret != CGBC_I2C_STAT_BUSY, 0,
- 2 * algo_data->read_maxtime_us, false, adap);
+ 2 * i2c->read_maxtime_us, false, adap);
if (ret < 0)
goto err;
- cmd_data = CGBC_I2C_CMD_DATA | algo_data->bus_id;
+ cmd_data = CGBC_I2C_CMD_DATA | i2c->bus_id;
ret = cgbc_command(cgbc, &cmd_data, sizeof(cmd_data),
msg->buf + i2c->pos, len, NULL);
if (ret)
@@ -335,44 +327,35 @@ static const struct i2c_algorithm cgbc_i2c_algorithm = {
.functionality = cgbc_i2c_func,
};
-static struct i2c_algo_cgbc_data cgbc_i2c_algo_data[] = {
- { .bus_id = CGBC_I2C_PRIMARY_BUS_ID },
- { .bus_id = CGBC_I2C_PM_BUS_ID },
-};
-
-static const struct i2c_adapter cgbc_i2c_adapter[] = {
- {
- .owner = THIS_MODULE,
- .name = "Congatec General Purpose I2C adapter",
- .class = I2C_CLASS_DEPRECATED,
- .algo = &cgbc_i2c_algorithm,
- .algo_data = &cgbc_i2c_algo_data[0],
- .nr = -1,
- },
- {
- .owner = THIS_MODULE,
- .name = "Congatec Power Management I2C adapter",
- .class = I2C_CLASS_DEPRECATED,
- .algo = &cgbc_i2c_algorithm,
- .algo_data = &cgbc_i2c_algo_data[1],
- .nr = -1,
- },
+static const struct i2c_adapter cgbc_i2c_adapter = {
+ .owner = THIS_MODULE,
+ .class = I2C_CLASS_DEPRECATED,
+ .algo = &cgbc_i2c_algorithm,
+ .nr = -1,
};
static int cgbc_i2c_probe(struct platform_device *pdev)
{
- struct cgbc_device_data *cgbc = dev_get_drvdata(pdev->dev.parent);
+ struct device *dev = &pdev->dev;
+ struct cgbc_device_data *cgbc = dev_get_drvdata(dev->parent);
+ struct cgbc_i2c_platform_data *pdata;
struct cgbc_i2c_data *i2c;
int ret;
- i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
+ i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
if (!i2c)
return -ENOMEM;
+ pdata = dev_get_platdata(dev);
+ if (!pdata)
+ return dev_err_probe(dev, -ENODEV, "missing platform_data\n");
+
i2c->cgbc = cgbc;
- i2c->dev = &pdev->dev;
- i2c->adap = cgbc_i2c_adapter[pdev->id];
+ i2c->dev = dev;
+ i2c->adap = cgbc_i2c_adapter;
i2c->adap.dev.parent = i2c->dev;
+ i2c->bus_id = pdata->cgbc_bus_id;
+ strscpy(i2c->adap.name, pdata->name, sizeof(i2c->adap.name));
i2c_set_adapdata(&i2c->adap, i2c);
platform_set_drvdata(pdev, i2c);
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 4/9] mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
` (2 preceding siblings ...)
2026-09-11 18:48 ` [PATCH v3 3/9] i2c: cgbc: Use plateform data to get bus ID and adapter name Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 5/9] mfd: cgbc: Use real I2C bus names Thomas Richard (congatec GmbH)
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH)
Since parameters are now passed to the i2c-cgbc driver via platform
data, the I2C driver no longer depends on the platform device ID to probe
the correct I2C buses. Drop the hardcoded cell ID in favor of
PLATFORM_DEVID_AUTO.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/mfd/cgbc-core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index 321fa3fff2ac..bb26b358da26 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -72,13 +72,11 @@ static const struct mfd_cell cgbc_devs[] = {
{ .name = "cgbc-hwmon" },
{
.name = "cgbc-i2c",
- .id = 1,
.platform_data = &cgbc_i2c_gp_pdata,
.pdata_size = sizeof(cgbc_i2c_gp_pdata),
},
{
.name = "cgbc-i2c",
- .id = 2,
.platform_data = &cgbc_i2c_pm_pdata,
.pdata_size = sizeof(cgbc_i2c_pm_pdata),
},
@@ -350,8 +348,8 @@ static int cgbc_init_device(struct cgbc_device_data *cgbc)
if (ret)
goto release_session;
- ret = mfd_add_devices(cgbc->dev, -1, cgbc_devs, ARRAY_SIZE(cgbc_devs),
- NULL, 0, NULL);
+ ret = mfd_add_devices(cgbc->dev, PLATFORM_DEVID_AUTO, cgbc_devs,
+ ARRAY_SIZE(cgbc_devs), NULL, 0, NULL);
if (ret)
goto release_session;
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 5/9] mfd: cgbc: Use real I2C bus names
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
` (3 preceding siblings ...)
2026-09-11 18:48 ` [PATCH v3 4/9] mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 6/9] i2c: cgbc: Add support for fixed frequency buses Thomas Richard (congatec GmbH)
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH)
The adapter names described the expected purpose of the buses ("General
Purpose I2C adapter", "Power Management I2C adapter") on conga-sa7 board
rather than their actual names on the Board Controller.
Rename them to the real bus names "cgbc-i2c0" and "cgbc-ddc0", matching
the naming used by Congatec, and update the variable names accordingly.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/mfd/cgbc-core.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index bb26b358da26..dff14cd98271 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -56,13 +56,13 @@
static struct platform_device *cgbc_pdev;
-static const struct cgbc_i2c_platform_data cgbc_i2c_gp_pdata = {
- .name = "Congatec General Purpose I2C adapter",
+static const struct cgbc_i2c_platform_data cgbc_i2c_i2c0_pdata = {
+ .name = "cgbc-i2c0",
.cgbc_bus_id = 0,
};
-static const struct cgbc_i2c_platform_data cgbc_i2c_pm_pdata = {
- .name = "Congatec Power Management I2C adapter",
+static const struct cgbc_i2c_platform_data cgbc_i2c_ddc0_pdata = {
+ .name = "cgbc-ddc0",
.cgbc_bus_id = 4,
};
@@ -72,13 +72,13 @@ static const struct mfd_cell cgbc_devs[] = {
{ .name = "cgbc-hwmon" },
{
.name = "cgbc-i2c",
- .platform_data = &cgbc_i2c_gp_pdata,
- .pdata_size = sizeof(cgbc_i2c_gp_pdata),
+ .platform_data = &cgbc_i2c_i2c0_pdata,
+ .pdata_size = sizeof(cgbc_i2c_i2c0_pdata),
},
{
.name = "cgbc-i2c",
- .platform_data = &cgbc_i2c_pm_pdata,
- .pdata_size = sizeof(cgbc_i2c_pm_pdata),
+ .platform_data = &cgbc_i2c_ddc0_pdata,
+ .pdata_size = sizeof(cgbc_i2c_ddc0_pdata),
},
{ .name = "cgbc-wdt" },
};
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 6/9] i2c: cgbc: Add support for fixed frequency buses
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
` (4 preceding siblings ...)
2026-09-11 18:48 ` [PATCH v3 5/9] mfd: cgbc: Use real I2C bus names Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 7/9] mfd: cgbc: Add virtual I2C bus support Thomas Richard (congatec GmbH)
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH)
Some I2C buses run at a fixed frequency. Add a fixed_freq flag to struct
cgbc_i2c_platform_data to identify them. But the frequency is still needed
to compute read_maxtime_us, so split cgbc_i2c_set_frequency() into two
functions:
- cgbc_i2c_set_frequency(): sets the bus frequency (skipped for
fixed-frequency busses).
- cgbc_i2c_get_frequency(): reads the bus frequency and computes
read_maxtime_us.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/i2c/busses/i2c-cgbc.c | 30 +++++++++++++++++++-----------
include/linux/platform_data/i2c-cgbc.h | 2 ++
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cgbc.c b/drivers/i2c/busses/i2c-cgbc.c
index d388e07aad84..cb0435b3cc5f 100644
--- a/drivers/i2c/busses/i2c-cgbc.c
+++ b/drivers/i2c/busses/i2c-cgbc.c
@@ -129,7 +129,6 @@ static int cgbc_i2c_set_frequency(struct i2c_adapter *adap,
struct cgbc_i2c_data *i2c = i2c_get_adapdata(adap);
struct cgbc_device_data *cgbc = i2c->cgbc;
u8 cmd[2], data;
- int ret;
if (bus_frequency > CGBC_I2C_FREQ_MAX_HZ ||
bus_frequency < CGBC_I2C_FREQ_MIN_HZ) {
@@ -140,18 +139,21 @@ static int cgbc_i2c_set_frequency(struct i2c_adapter *adap,
cmd[0] = CGBC_I2C_CMD_SPEED | i2c->bus_id;
cmd[1] = cgbc_i2c_freq_to_reg(bus_frequency);
- ret = cgbc_command(cgbc, &cmd, sizeof(cmd), &data, 1, NULL);
- if (ret)
- return dev_err_probe(i2c->dev, ret,
- "Failed to initialize I2C bus %s",
- adap->name);
+ return cgbc_command(cgbc, &cmd, sizeof(cmd), &data, 1, NULL);
+}
- cmd[1] = 0x00;
+static int cgbc_i2c_get_frequency(struct i2c_adapter *adap)
+{
+ struct cgbc_i2c_data *i2c = i2c_get_adapdata(adap);
+ struct cgbc_device_data *cgbc = i2c->cgbc;
+ u8 cmd[2] = { CGBC_I2C_CMD_SPEED | i2c->bus_id };
+ unsigned int bus_frequency;
+ u8 data;
+ int ret;
ret = cgbc_command(cgbc, &cmd, sizeof(cmd), &data, 1, NULL);
if (ret)
- return dev_err_probe(i2c->dev, ret,
- "Failed to get I2C bus frequency");
+ return ret;
bus_frequency = cgbc_i2c_reg_to_freq(data);
@@ -359,9 +361,15 @@ static int cgbc_i2c_probe(struct platform_device *pdev)
i2c_set_adapdata(&i2c->adap, i2c);
platform_set_drvdata(pdev, i2c);
- ret = cgbc_i2c_set_frequency(&i2c->adap, I2C_MAX_STANDARD_MODE_FREQ);
+ if (!pdata->fixed_freq) {
+ ret = cgbc_i2c_set_frequency(&i2c->adap, I2C_MAX_STANDARD_MODE_FREQ);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to set I2C bus frequency");
+ }
+
+ ret = cgbc_i2c_get_frequency(&i2c->adap);
if (ret)
- return ret;
+ return dev_err_probe(i2c->dev, ret, "Failed to get I2C bus frequency");
return i2c_add_numbered_adapter(&i2c->adap);
}
diff --git a/include/linux/platform_data/i2c-cgbc.h b/include/linux/platform_data/i2c-cgbc.h
index 4465e8a7b40e..224926c12070 100644
--- a/include/linux/platform_data/i2c-cgbc.h
+++ b/include/linux/platform_data/i2c-cgbc.h
@@ -13,10 +13,12 @@
* struct cgbc_platform_data - Platform data of the CGBC I2C driver
* @name: I2C adapter name
* @cgbc_bus_id: I2C bus ID (from Board Controller point of view)
+ * @fixed_freq: I2C bus has a fixed frequency
*/
struct cgbc_i2c_platform_data {
const char *name;
int cgbc_bus_id;
+ bool fixed_freq;
};
#endif /* _LINUX_I2C_CGBC_H */
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 7/9] mfd: cgbc: Add virtual I2C bus support
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
` (5 preceding siblings ...)
2026-09-11 18:48 ` [PATCH v3 6/9] i2c: cgbc: Add support for fixed frequency buses Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 8/9] mfd: cgbc: Add virtual storage devices on the virtual I2C bus Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 9/9] i2c: cgbc: Register known I2C devices on the bus Thomas Richard (congatec GmbH)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH)
Internally the Board Controller has a virtual I2C bus with some virtual
storage devices (EEPROM and RAM). So add a new I2C cell for this I2C
virtual bus.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/mfd/cgbc-core.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index dff14cd98271..90fa0e657385 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -66,6 +66,12 @@ static const struct cgbc_i2c_platform_data cgbc_i2c_ddc0_pdata = {
.cgbc_bus_id = 4,
};
+static const struct cgbc_i2c_platform_data cgbc_i2c_i2cv_pdata = {
+ .name = "cgbc-i2cv",
+ .cgbc_bus_id = 3,
+ .fixed_freq = true,
+};
+
static const struct mfd_cell cgbc_devs[] = {
{ .name = "cgbc-backlight" },
{ .name = "cgbc-gpio" },
@@ -80,6 +86,11 @@ static const struct mfd_cell cgbc_devs[] = {
.platform_data = &cgbc_i2c_ddc0_pdata,
.pdata_size = sizeof(cgbc_i2c_ddc0_pdata),
},
+ {
+ .name = "cgbc-i2c",
+ .platform_data = &cgbc_i2c_i2cv_pdata,
+ .pdata_size = sizeof(cgbc_i2c_i2cv_pdata),
+ },
{ .name = "cgbc-wdt" },
};
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 8/9] mfd: cgbc: Add virtual storage devices on the virtual I2C bus
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
` (6 preceding siblings ...)
2026-09-11 18:48 ` [PATCH v3 7/9] mfd: cgbc: Add virtual I2C bus support Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 9/9] i2c: cgbc: Register known I2C devices on the bus Thomas Richard (congatec GmbH)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH)
Add support for virtual storage devices exposed by the Board Controller
on its virtual I2C bus. There are two device types: EEPROM for persistent
storage and RAM for non-persistent storage:
- Secure Data EEPROM (64 bytes, RO): static and dynamic board info
- BIOS EEPROM (32 bytes, RW): reserved for BIOS applications
- BC EEPROM (32 bytes, RO): Board Controller operational params
- User EEPROM (32 bytes, RW): user applications
- BIOS RAM (32 bytes, RW): reserved for BIOS applications
- BC RAM (8 bytes, RO): Board Controller operational params
- User RAM (16 bytes, RW): user applications
Use the at24 driver with the 24c01 entry (the most generic one) for all
virtual storage devices, customizing parameters via software_node
properties (size, pagesize, read-only flag, label).
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/mfd/cgbc-core.c | 129 +++++++++++++++++++++++++++++++++
include/linux/platform_data/i2c-cgbc.h | 4 +
2 files changed, 133 insertions(+)
diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index 90fa0e657385..097b7309a400 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -13,11 +13,13 @@
#include <linux/dmi.h>
#include <linux/iopoll.h>
+#include <linux/i2c.h>
#include <linux/mfd/cgbc.h>
#include <linux/mfd/core.h>
#include <linux/module.h>
#include <linux/platform_data/i2c-cgbc.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/sysfs.h>
#define CGBC_IO_SESSION_BASE 0x0E20
@@ -56,6 +58,131 @@
static struct platform_device *cgbc_pdev;
+static const struct property_entry cgbc_secure_data_eeprom_props[] = {
+ PROPERTY_ENTRY_U32("size", 64),
+ PROPERTY_ENTRY_U32("pagesize", 1),
+ PROPERTY_ENTRY_BOOL("read-only"),
+ PROPERTY_ENTRY_STRING("label", "cgbc-secure-data-eeprom"),
+ { }
+};
+
+static const struct software_node cgbc_secure_data_eeprom_node = {
+ .properties = cgbc_secure_data_eeprom_props,
+};
+
+static const struct property_entry cgbc_bc_eeprom_props[] = {
+ PROPERTY_ENTRY_U32("size", 32),
+ PROPERTY_ENTRY_U32("pagesize", 1),
+ PROPERTY_ENTRY_BOOL("read-only"),
+ PROPERTY_ENTRY_STRING("label", "cgbc-bc-eeprom"),
+ { }
+};
+
+static const struct software_node cgbc_bc_eeprom_node = {
+ .properties = cgbc_bc_eeprom_props,
+};
+
+static const struct property_entry cgbc_user_eeprom_props[] = {
+ PROPERTY_ENTRY_U32("size", 32),
+ PROPERTY_ENTRY_U32("pagesize", 1),
+ PROPERTY_ENTRY_STRING("label", "cgbc-user-eeprom"),
+ { }
+};
+
+static const struct software_node cgbc_user_eeprom_node = {
+ .properties = cgbc_user_eeprom_props,
+};
+
+static const struct property_entry cgbc_bios_eeprom_props[] = {
+ PROPERTY_ENTRY_U32("size", 32),
+ PROPERTY_ENTRY_U32("pagesize", 1),
+ PROPERTY_ENTRY_STRING("label", "cgbc-bios-eeprom"),
+ { }
+};
+
+static const struct software_node cgbc_bios_eeprom_node = {
+ .properties = cgbc_bios_eeprom_props,
+};
+
+static const struct property_entry cgbc_bc_ram_props[] = {
+ PROPERTY_ENTRY_U32("size", 8),
+ PROPERTY_ENTRY_U32("pagesize", 1),
+ PROPERTY_ENTRY_BOOL("read-only"),
+ PROPERTY_ENTRY_STRING("label", "cgbc-bc-ram"),
+ { }
+};
+
+static const struct software_node cgbc_bc_ram_node = {
+ .properties = cgbc_bc_ram_props,
+};
+
+static const struct property_entry cgbc_user_ram_props[] = {
+ PROPERTY_ENTRY_U32("size", 16),
+ PROPERTY_ENTRY_U32("pagesize", 1),
+ PROPERTY_ENTRY_STRING("label", "cgbc-user-ram"),
+ { }
+};
+
+static const struct software_node cgbc_user_ram_node = {
+ .properties = cgbc_user_ram_props,
+};
+
+static const struct property_entry cgbc_bios_ram_props[] = {
+ PROPERTY_ENTRY_U32("size", 32),
+ PROPERTY_ENTRY_U32("pagesize", 1),
+ PROPERTY_ENTRY_STRING("label", "cgbc-bios-ram"),
+ { }
+};
+
+static const struct software_node cgbc_bios_ram_node = {
+ .properties = cgbc_bios_ram_props,
+};
+
+static const struct i2c_board_info cgbc_i2c_i2cv_board_info[] = {
+ {
+ .type = "24c01",
+ .addr = 0x40,
+ .dev_name = "cgbc-secure-data-eeprom",
+ .swnode = &cgbc_secure_data_eeprom_node,
+ },
+ {
+ .type = "24c01",
+ .addr = 0x48,
+ .dev_name = "cgbc-bc-eeprom",
+ .swnode = &cgbc_bc_eeprom_node,
+ },
+ {
+ .type = "24c01",
+ .addr = 0x50,
+ .dev_name = "cgbc-user-eeprom",
+ .swnode = &cgbc_user_eeprom_node,
+ },
+ {
+ .type = "24c01",
+ .addr = 0x58,
+ .dev_name = "cgbc-bios-eeprom",
+ .swnode = &cgbc_bios_eeprom_node,
+ },
+ {
+ .type = "24c01",
+ .addr = 0x60,
+ .dev_name = "cgbc-bc-ram",
+ .swnode = &cgbc_bc_ram_node,
+ },
+ {
+ .type = "24c01",
+ .addr = 0x68,
+ .dev_name = "cgbc-user-ram",
+ .swnode = &cgbc_user_ram_node,
+ },
+ {
+ .type = "24c01",
+ .addr = 0x70,
+ .dev_name = "cgbc-bios-ram",
+ .swnode = &cgbc_bios_ram_node,
+ }
+};
+
static const struct cgbc_i2c_platform_data cgbc_i2c_i2c0_pdata = {
.name = "cgbc-i2c0",
.cgbc_bus_id = 0,
@@ -70,6 +197,8 @@ static const struct cgbc_i2c_platform_data cgbc_i2c_i2cv_pdata = {
.name = "cgbc-i2cv",
.cgbc_bus_id = 3,
.fixed_freq = true,
+ .devices = cgbc_i2c_i2cv_board_info,
+ .nb_devices = ARRAY_SIZE(cgbc_i2c_i2cv_board_info),
};
static const struct mfd_cell cgbc_devs[] = {
diff --git a/include/linux/platform_data/i2c-cgbc.h b/include/linux/platform_data/i2c-cgbc.h
index 224926c12070..5f20503ce858 100644
--- a/include/linux/platform_data/i2c-cgbc.h
+++ b/include/linux/platform_data/i2c-cgbc.h
@@ -14,11 +14,15 @@
* @name: I2C adapter name
* @cgbc_bus_id: I2C bus ID (from Board Controller point of view)
* @fixed_freq: I2C bus has a fixed frequency
+ * @nb_devices: number of devices to add when the driver is probed
+ * @devices: devices to add
*/
struct cgbc_i2c_platform_data {
const char *name;
int cgbc_bus_id;
bool fixed_freq;
+ int nb_devices;
+ struct i2c_board_info const *devices;
};
#endif /* _LINUX_I2C_CGBC_H */
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 9/9] i2c: cgbc: Register known I2C devices on the bus
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
` (7 preceding siblings ...)
2026-09-11 18:48 ` [PATCH v3 8/9] mfd: cgbc: Add virtual storage devices on the virtual I2C bus Thomas Richard (congatec GmbH)
@ 2026-09-11 18:48 ` Thomas Richard (congatec GmbH)
8 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-09-11 18:48 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH)
Register any I2C devices defined for the bus at probe time.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/i2c/busses/i2c-cgbc.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cgbc.c b/drivers/i2c/busses/i2c-cgbc.c
index cb0435b3cc5f..f20f401f81cb 100644
--- a/drivers/i2c/busses/i2c-cgbc.c
+++ b/drivers/i2c/busses/i2c-cgbc.c
@@ -342,7 +342,7 @@ static int cgbc_i2c_probe(struct platform_device *pdev)
struct cgbc_device_data *cgbc = dev_get_drvdata(dev->parent);
struct cgbc_i2c_platform_data *pdata;
struct cgbc_i2c_data *i2c;
- int ret;
+ int ret, i;
i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
if (!i2c)
@@ -371,7 +371,15 @@ static int cgbc_i2c_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(i2c->dev, ret, "Failed to get I2C bus frequency");
- return i2c_add_numbered_adapter(&i2c->adap);
+ ret = i2c_add_numbered_adapter(&i2c->adap);
+ if (ret)
+ return ret;
+
+ /* Add known devices to the bus */
+ for (i = 0; i < pdata->nb_devices; i++)
+ i2c_new_client_device(&i2c->adap, pdata->devices + i);
+
+ return 0;
}
static void cgbc_i2c_remove(struct platform_device *pdev)
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/9] mfd: cgbc: Add I2C platform data
2026-09-11 18:48 ` [PATCH v3 2/9] mfd: cgbc: Add I2C platform data Thomas Richard (congatec GmbH)
@ 2026-09-23 15:02 ` Lee Jones
2026-09-23 15:42 ` Thomas Richard
0 siblings, 1 reply; 12+ messages in thread
From: Lee Jones @ 2026-09-23 15:02 UTC (permalink / raw)
To: Thomas Richard (congatec GmbH)
Cc: Andi Shyti, Thomas Petazzoni, Werner Gartner, mfd, linux-kernel,
linux-i2c
On Fri, 11 Sep 2026, Thomas Richard (congatec GmbH) wrote:
> Define I2C platform data for each I2C bus in the cgbc MFD driver. Platform
> data passes per-bus parameters to the I2C driver, rather than being defined
> inside the i2c-cgbc driver itself. This makes the i2c-cgbc driver more
> generic.
>
> Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
> ---
> MAINTAINERS | 1 +
> drivers/mfd/cgbc-core.c | 39 ++++++++++++++++++++++++++--------
> include/linux/platform_data/i2c-cgbc.h | 22 +++++++++++++++++++
> 3 files changed, 53 insertions(+), 9 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6215fcb07770..561f102c2541 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6621,6 +6621,7 @@ F: drivers/mfd/cgbc-core.c
> F: drivers/video/backlight/cgbc_bl.c
> F: drivers/watchdog/cgbc_wdt.c
> F: include/linux/mfd/cgbc.h
> +F: include/linux/platform_data/i2c-cgbc.h
>
> CONSOLE SUBSYSTEM
> M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
> index 4a409234e66c..321fa3fff2ac 100644
> --- a/drivers/mfd/cgbc-core.c
> +++ b/drivers/mfd/cgbc-core.c
> @@ -16,6 +16,7 @@
> #include <linux/mfd/cgbc.h>
> #include <linux/mfd/core.h>
> #include <linux/module.h>
> +#include <linux/platform_data/i2c-cgbc.h>
> #include <linux/platform_device.h>
> #include <linux/sysfs.h>
>
> @@ -55,6 +56,35 @@
>
> static struct platform_device *cgbc_pdev;
>
> +static const struct cgbc_i2c_platform_data cgbc_i2c_gp_pdata = {
> + .name = "Congatec General Purpose I2C adapter",
> + .cgbc_bus_id = 0,
> +};
> +
> +static const struct cgbc_i2c_platform_data cgbc_i2c_pm_pdata = {
> + .name = "Congatec Power Management I2C adapter",
> + .cgbc_bus_id = 4,
> +};
> +
> +static const struct mfd_cell cgbc_devs[] = {
> + { .name = "cgbc-backlight" },
MFD_CELL_*
> + { .name = "cgbc-gpio" },
> + { .name = "cgbc-hwmon" },
> + {
> + .name = "cgbc-i2c",
> + .id = 1,
Why does PLATFORM_DEVID_AUTO not work for you?
> + .platform_data = &cgbc_i2c_gp_pdata,
> + .pdata_size = sizeof(cgbc_i2c_gp_pdata),
> + },
> + {
> + .name = "cgbc-i2c",
> + .id = 2,
> + .platform_data = &cgbc_i2c_pm_pdata,
> + .pdata_size = sizeof(cgbc_i2c_pm_pdata),
> + },
> + { .name = "cgbc-wdt" },
> +};
> +
> /* Wait the Board Controller is ready to receive some session commands */
> static int cgbc_wait_device(struct cgbc_device_data *cgbc)
> {
> @@ -235,15 +265,6 @@ int cgbc_command(struct cgbc_device_data *cgbc, void *cmd, unsigned int cmd_size
> }
> EXPORT_SYMBOL_GPL(cgbc_command);
>
> -static struct mfd_cell cgbc_devs[] = {
> - { .name = "cgbc-wdt" },
> - { .name = "cgbc-gpio" },
> - { .name = "cgbc-i2c", .id = 1 },
> - { .name = "cgbc-i2c", .id = 2 },
> - { .name = "cgbc-hwmon" },
> - { .name = "cgbc-backlight" },
> -};
> -
> static int cgbc_map(struct cgbc_device_data *cgbc)
> {
> struct device *dev = cgbc->dev;
> diff --git a/include/linux/platform_data/i2c-cgbc.h b/include/linux/platform_data/i2c-cgbc.h
> new file mode 100644
> index 000000000000..4465e8a7b40e
> --- /dev/null
> +++ b/include/linux/platform_data/i2c-cgbc.h
I think this area is mainly used to share data with OF.
Did you consider include/linux/mfd?
> @@ -0,0 +1,22 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * i2c-cgbc interface to platform code
> + *
> + * Copyright (C) 2026 congatec GmbH
> + * Author: Thomas Richard <thomas.richard@bootlin.com>
> + */
> +
> +#ifndef _LINUX_I2C_CGBC_H
> +#define _LINUX_I2C_CGBC_H
> +
> +/**
> + * struct cgbc_platform_data - Platform data of the CGBC I2C driver
> + * @name: I2C adapter name
> + * @cgbc_bus_id: I2C bus ID (from Board Controller point of view)
> + */
> +struct cgbc_i2c_platform_data {
> + const char *name;
> + int cgbc_bus_id;
> +};
> +
> +#endif /* _LINUX_I2C_CGBC_H */
>
> --
> 2.53.0
>
--
Lee Jones
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/9] mfd: cgbc: Add I2C platform data
2026-09-23 15:02 ` Lee Jones
@ 2026-09-23 15:42 ` Thomas Richard
0 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard @ 2026-09-23 15:42 UTC (permalink / raw)
To: Lee Jones
Cc: Andi Shyti, Thomas Petazzoni, Werner Gartner, mfd, linux-kernel,
linux-i2c
On 9/23/26 5:02 PM, Lee Jones wrote:
> On Fri, 11 Sep 2026, Thomas Richard (congatec GmbH) wrote:
>
>> Define I2C platform data for each I2C bus in the cgbc MFD driver. Platform
>> data passes per-bus parameters to the I2C driver, rather than being defined
>> inside the i2c-cgbc driver itself. This makes the i2c-cgbc driver more
>> generic.
>>
>> Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
>> ---
>> MAINTAINERS | 1 +
>> drivers/mfd/cgbc-core.c | 39 ++++++++++++++++++++++++++--------
>> include/linux/platform_data/i2c-cgbc.h | 22 +++++++++++++++++++
>> 3 files changed, 53 insertions(+), 9 deletions(-)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 6215fcb07770..561f102c2541 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -6621,6 +6621,7 @@ F: drivers/mfd/cgbc-core.c
>> F: drivers/video/backlight/cgbc_bl.c
>> F: drivers/watchdog/cgbc_wdt.c
>> F: include/linux/mfd/cgbc.h
>> +F: include/linux/platform_data/i2c-cgbc.h
>>
>> CONSOLE SUBSYSTEM
>> M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
>> index 4a409234e66c..321fa3fff2ac 100644
>> --- a/drivers/mfd/cgbc-core.c
>> +++ b/drivers/mfd/cgbc-core.c
>> @@ -16,6 +16,7 @@
>> #include <linux/mfd/cgbc.h>
>> #include <linux/mfd/core.h>
>> #include <linux/module.h>
>> +#include <linux/platform_data/i2c-cgbc.h>
>> #include <linux/platform_device.h>
>> #include <linux/sysfs.h>
>>
>> @@ -55,6 +56,35 @@
>>
>> static struct platform_device *cgbc_pdev;
>>
>> +static const struct cgbc_i2c_platform_data cgbc_i2c_gp_pdata = {
>> + .name = "Congatec General Purpose I2C adapter",
>> + .cgbc_bus_id = 0,
>> +};
>> +
>> +static const struct cgbc_i2c_platform_data cgbc_i2c_pm_pdata = {
>> + .name = "Congatec Power Management I2C adapter",
>> + .cgbc_bus_id = 4,
>> +};
>> +
>> +static const struct mfd_cell cgbc_devs[] = {
>> + { .name = "cgbc-backlight" },
>
> MFD_CELL_*
>
>> + { .name = "cgbc-gpio" },
>> + { .name = "cgbc-hwmon" },
>> + {
>> + .name = "cgbc-i2c",
>> + .id = 1,
>
> Why does PLATFORM_DEVID_AUTO not work for you?
Path 2, 3 and 4 do the transition to PLATFORM_DEVID_AUTO.
But at this point I2C driver uses cell id to identify the bus.
Patch 2: adds cgbc_bus_id (in cgbc_i2c_platform_data) to identify the bus.
Patch 3: modifies I2C driver to use cgbc_i2c_platform_data.
Patch 4: now I2C driver doesn't rely on cell id, so switch to
PLATFORM_DEVID_AUTO
>
>> + .platform_data = &cgbc_i2c_gp_pdata,
>> + .pdata_size = sizeof(cgbc_i2c_gp_pdata),
>> + },
>> + {
>> + .name = "cgbc-i2c",
>> + .id = 2,
>> + .platform_data = &cgbc_i2c_pm_pdata,
>> + .pdata_size = sizeof(cgbc_i2c_pm_pdata),
>> + },
>> + { .name = "cgbc-wdt" },
>> +};
>> +
>> /* Wait the Board Controller is ready to receive some session commands */
>> static int cgbc_wait_device(struct cgbc_device_data *cgbc)
>> {
>> @@ -235,15 +265,6 @@ int cgbc_command(struct cgbc_device_data *cgbc, void *cmd, unsigned int cmd_size
>> }
>> EXPORT_SYMBOL_GPL(cgbc_command);
>>
>> -static struct mfd_cell cgbc_devs[] = {
>> - { .name = "cgbc-wdt" },
>> - { .name = "cgbc-gpio" },
>> - { .name = "cgbc-i2c", .id = 1 },
>> - { .name = "cgbc-i2c", .id = 2 },
>> - { .name = "cgbc-hwmon" },
>> - { .name = "cgbc-backlight" },
>> -};
>> -
>> static int cgbc_map(struct cgbc_device_data *cgbc)
>> {
>> struct device *dev = cgbc->dev;
>> diff --git a/include/linux/platform_data/i2c-cgbc.h b/include/linux/platform_data/i2c-cgbc.h
>> new file mode 100644
>> index 000000000000..4465e8a7b40e
>> --- /dev/null
>> +++ b/include/linux/platform_data/i2c-cgbc.h
>
> I think this area is mainly used to share data with OF.
>
> Did you consider include/linux/mfd?
I thought it was the right place. But I can move the struct to
include/linux/mfd/cgbc.h if you prefer.
Best Regards,
Thomas
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-09-23 15:42 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 18:48 [PATCH v3 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 1/9] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 2/9] mfd: cgbc: Add I2C platform data Thomas Richard (congatec GmbH)
2026-09-23 15:02 ` Lee Jones
2026-09-23 15:42 ` Thomas Richard
2026-09-11 18:48 ` [PATCH v3 3/9] i2c: cgbc: Use plateform data to get bus ID and adapter name Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 4/9] mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 5/9] mfd: cgbc: Use real I2C bus names Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 6/9] i2c: cgbc: Add support for fixed frequency buses Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 7/9] mfd: cgbc: Add virtual I2C bus support Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 8/9] mfd: cgbc: Add virtual storage devices on the virtual I2C bus Thomas Richard (congatec GmbH)
2026-09-11 18:48 ` [PATCH v3 9/9] i2c: cgbc: Register known I2C devices on the bus Thomas Richard (congatec GmbH)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®