Re: [PATCH v3 2/9] mfd: cgbc: Add I2C platform data

From: Thomas Richard

Date: Wed Sep 23 2026 - 13:43:34 EST


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@xxxxxxxxxxx>
>> ---
>> 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@xxxxxxxxxxxxxxxxxxx>
>> 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