mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5 0/9] Congatec Board Controller: Add storage devices support
@ 2026-11-03 16:49 Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 1/9] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 UTC (permalink / raw)
  To: Lee Jones, Andi Shyti
  Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
	Thomas Richard (congatec GmbH),
	stable, Sashiko

In this v5, I re-ordered a bit the patches to fix I2C bus names first.
I also made an error message more user friendly.

Lee, this series conflicts with some other ongoing patches series:
- mfd: Assorted resource lifetime, teardown, and error-handling fixes [1]
- mfd: Constify mfd_cell arrays [2]

To make your life easier I rebased this series on top of them. Please let
me know if you want to proceed in an other way. 

[1] https://lore.kernel.org/all/20261027093306.2812695-1-lee@kernel.org/
[2] https://lore.kernel.org/all/20261030071137.100954-3-krzysztof.kozlowski@oss.qualcomm.com/

Best Regards,
Thomas

Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
Changes in v5:
- mfd: fix error message in case we fail to get session handle.
- fix I2C bus names earlier in the series.
- Link to v4: https://patch.msgid.link/20261002-cgbc-i2c-storage-devices-support-v4-0-eb42e0f1df59@bootlin.com

Changes in v4:
- Fix struct cgbc_i2c_platform_data comment (kernel-doc warning)
- Move struct cgbc_i2c_platform_data from linux/platform_data/i2c-cgbc.h to
  linux/mfd/cgbc.h
- Use MFD_CELL_NAME macros.
- Link to v3: https://patch.msgid.link/20260911-cgbc-i2c-storage-devices-support-v3-0-594b53fbc5ea@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
      i2c: cgbc: Use real I2C bus names
      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
      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

 drivers/i2c/busses/i2c-cgbc.c | 108 ++++++++++++------------
 drivers/mfd/cgbc-core.c       | 187 +++++++++++++++++++++++++++++++++++++++---
 include/linux/mfd/cgbc.h      |  16 ++++
 3 files changed, 244 insertions(+), 67 deletions(-)
---
base-commit: d3dfdb6b429a5b99bfd47176bf07cad0956f14ed
change-id: 20260717-cgbc-i2c-storage-devices-support-b3ee7cea3320
prerequisite-message-id: 20261027093306.2812695-1-lee@kernel.org
prerequisite-patch-id: 7d50ed21b2d5d1bb25290d19c46b4668073feddf
prerequisite-patch-id: 45cdf12f5527ab86a560ba98c02cc447bf6eee4e
prerequisite-patch-id: 6148da531ee7713f8afb7bec90fb3f548b562d28
prerequisite-patch-id: fb0c30c409ef451192973c417a0585f989f8917b
prerequisite-patch-id: 8403fcd8efcd44138f139767624773fa654a5a2f
prerequisite-patch-id: 434546741519ecd3032e19f3acf2c5370e9a454c
prerequisite-patch-id: 29540ca5739d6f6f3e2d3fe5b87893ad31f6c3ee
prerequisite-patch-id: a33adadb2e2efe82d2a14417c1c35c579bf212d0
prerequisite-patch-id: dd53f1e6db35d71b51061dad45de28dde9ebc70f
prerequisite-patch-id: 85a1da1285d64ce3fc78c8ae7969fbb0dc7c3cd7
prerequisite-patch-id: e9b952ebc380d058ac2144771c780a0b08c3b7c3
prerequisite-patch-id: 1f0dcc7a8c5df7ae1c8bfb5a1c8f62b441704286
prerequisite-patch-id: 077a4ef70d74321711e2efd4e016e01a1d41c818
prerequisite-patch-id: 4dcd6cc156bb6ba43684605972fb179557a3891e
prerequisite-patch-id: 62e87491674feaae09327a99a5ff1b4ed368f221
prerequisite-patch-id: ab1eac435fd40cdb3d9a8d453a12852a105f57c4
prerequisite-patch-id: 1cbcc3b666db27cbe9f3fa6c6ead2f49a0d459da
prerequisite-patch-id: ecb566a7bea44600e9d7e9617e280c994773e3dd
prerequisite-patch-id: 20e295db85a31587d342471a3c341615c8eb0fd7
prerequisite-patch-id: 06118bf6e5affc234e7edbdb5c0aae9b05412b33
prerequisite-patch-id: 17afeb13c5012348feee8eb739ff058e84ed2df8
prerequisite-patch-id: 27693bdeffbc7a0a295c165912b89af5ca3264aa
prerequisite-patch-id: 8313fe2293eaf0e69ffd2f0017e18fde64ca68f7
prerequisite-patch-id: fc53af34353efecb4490087ed066ccb256a74695
prerequisite-patch-id: 02ad8a3b1fddb4f4e806939d36ae642c01004c36
prerequisite-patch-id: 7b9b8460613f4240492ffe11ee7ee0e6c0b6ded8
prerequisite-patch-id: 699c068a32ac9d3171e7a494fb2ca5522045779a
prerequisite-message-id: 20261030140240.211786-3-krzysztof.kozlowski@oss.qualcomm.com
prerequisite-patch-id: f6cf975bf90acb029fa985ecd659b59076fdc0cd
prerequisite-patch-id: 4f16ad80662de796ae1454904c938e7e85115fbd

Best regards,
--  
Best Regards,
Thomas Richard


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

* [PATCH v5 1/9] mfd: cgbc: Fix use of negative error code as valid session handle
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 2/9] i2c: cgbc: Use real I2C bus names Thomas Richard (congatec GmbH)
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index 3460c50047ea..02a8c0078287 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -103,7 +103,12 @@ 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,
+				     "failed to start a session with the Board Controller\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 v5 2/9] i2c: cgbc: Use real I2C bus names
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 1/9] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 3/9] mfd: cgbc: Add I2C platform data Thomas Richard (congatec GmbH)
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 UTC (permalink / raw)
  To: Lee Jones, Andi Shyti
  Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
	Thomas Richard (congatec GmbH),
	stable

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.

Cc: stable@vger.kernel.org
Fixes: 6894f640b8f3 ("i2c: Congatec Board Controller i2c bus driver")
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
 drivers/i2c/busses/i2c-cgbc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cgbc.c b/drivers/i2c/busses/i2c-cgbc.c
index 9909c25f0b18..ac23435b731b 100644
--- a/drivers/i2c/busses/i2c-cgbc.c
+++ b/drivers/i2c/busses/i2c-cgbc.c
@@ -358,7 +358,7 @@ static struct i2c_algo_cgbc_data cgbc_i2c_algo_data[] = {
 static const struct i2c_adapter cgbc_i2c_adapter[] = {
 	{
 		.owner		= THIS_MODULE,
-		.name		= "Congatec General Purpose I2C adapter",
+		.name		= "cgbc-i2c0",
 		.class		= I2C_CLASS_DEPRECATED,
 		.algo		= &cgbc_i2c_algorithm,
 		.algo_data	= &cgbc_i2c_algo_data[0],
@@ -366,7 +366,7 @@ static const struct i2c_adapter cgbc_i2c_adapter[] = {
 	},
 	{
 		.owner		= THIS_MODULE,
-		.name		= "Congatec Power Management I2C adapter",
+		.name		= "cgbc-ddc0",
 		.class		= I2C_CLASS_DEPRECATED,
 		.algo		= &cgbc_i2c_algorithm,
 		.algo_data	= &cgbc_i2c_algo_data[1],

-- 
2.53.0


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

* [PATCH v5 3/9] mfd: cgbc: Add I2C platform data
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 1/9] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 2/9] i2c: cgbc: Use real I2C bus names Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 4/9] i2c: cgbc: Use plateform data to get bus ID and adapter name Thomas Richard (congatec GmbH)
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 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>
---
 drivers/mfd/cgbc-core.c  | 38 +++++++++++++++++++++++++++++---------
 include/linux/mfd/cgbc.h | 10 ++++++++++
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index 02a8c0078287..777930d1169e 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -55,6 +55,35 @@
 
 static struct platform_device *cgbc_pdev;
 
+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_ddc0_pdata = {
+	.name  = "cgbc-ddc0",
+	.cgbc_bus_id = 4,
+};
+
+static const struct mfd_cell cgbc_devs[] = {
+	MFD_CELL_NAME("cgbc-backlight"),
+	MFD_CELL_NAME("cgbc-gpio"),
+	MFD_CELL_NAME("cgbc-hwmon"),
+	{
+		.name = "cgbc-i2c",
+		.id = 1,
+		.platform_data = &cgbc_i2c_i2c0_pdata,
+		.pdata_size = sizeof(cgbc_i2c_i2c0_pdata),
+	},
+	{
+		.name = "cgbc-i2c",
+		.id = 2,
+		.platform_data = &cgbc_i2c_ddc0_pdata,
+		.pdata_size = sizeof(cgbc_i2c_ddc0_pdata),
+	},
+	MFD_CELL_NAME("cgbc-wdt"),
+};
+
 /* Wait the Board Controller is ready to receive some session commands */
 static int cgbc_wait_device(struct cgbc_device_data *cgbc)
 {
@@ -236,15 +265,6 @@ int cgbc_command(struct cgbc_device_data *cgbc, void *cmd, unsigned int cmd_size
 }
 EXPORT_SYMBOL_GPL(cgbc_command);
 
-static const 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/mfd/cgbc.h b/include/linux/mfd/cgbc.h
index 91f501e76c8f..4b6e41b9ca4a 100644
--- a/include/linux/mfd/cgbc.h
+++ b/include/linux/mfd/cgbc.h
@@ -41,4 +41,14 @@ struct cgbc_device_data {
 int cgbc_command(struct cgbc_device_data *cgbc, void *cmd, unsigned int cmd_size,
 		 void *data, unsigned int data_size, u8 *status);
 
+/**
+ * struct cgbc_i2c_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_MFD_CGBC_H_*/

-- 
2.53.0


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

* [PATCH v5 4/9] i2c: cgbc: Use plateform data to get bus ID and adapter name
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
                   ` (2 preceding siblings ...)
  2026-11-03 16:49 ` [PATCH v5 3/9] mfd: cgbc: Add I2C platform data Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 5/9] mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration Thomas Richard (congatec GmbH)
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 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 | 68 ++++++++++++++++---------------------------
 1 file changed, 25 insertions(+), 43 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cgbc.c b/drivers/i2c/busses/i2c-cgbc.c
index ac23435b731b..40ffab4fd0bc 100644
--- a/drivers/i2c/busses/i2c-cgbc.c
+++ b/drivers/i2c/busses/i2c-cgbc.c
@@ -12,9 +12,6 @@
 #include <linux/module.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 +57,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 +65,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 +109,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 +125,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 +136,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 +162,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 +192,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 +201,7 @@ static int cgbc_i2c_xfer_msg(struct i2c_adapter *adap)
 	u8 cmd_data, data_len;
 
 	struct cgbc_i2c_transfer xfer = {
-		.bus_id = algo_data->bus_id,
+		.bus_id = i2c->bus_id,
 		.addr = i2c_8bit_addr_from_msg(msg),
 	};
 
@@ -268,7 +259,7 @@ static int cgbc_i2c_xfer_msg(struct i2c_adapter *adap)
 
 		ret = read_poll_timeout(cgbc_i2c_get_status, status,
 					status != CGBC_I2C_STAT_BUSY, 0,
-					2 * algo_data->read_maxtime_us, false, adap);
+					2 * i2c->read_maxtime_us, false, adap);
 		if (ret)
 			goto err;
 
@@ -282,7 +273,7 @@ static int cgbc_i2c_xfer_msg(struct i2c_adapter *adap)
 			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, &data_len);
 		if (ret)
@@ -350,44 +341,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		= "cgbc-i2c0",
-		.class		= I2C_CLASS_DEPRECATED,
-		.algo		= &cgbc_i2c_algorithm,
-		.algo_data	= &cgbc_i2c_algo_data[0],
-		.nr		= -1,
-	},
-	{
-		.owner		= THIS_MODULE,
-		.name		= "cgbc-ddc0",
-		.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 v5 5/9] mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
                   ` (3 preceding siblings ...)
  2026-11-03 16:49 ` [PATCH v5 4/9] i2c: cgbc: Use plateform data to get bus ID and adapter name Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 6/9] i2c: cgbc: Add support for fixed frequency buses Thomas Richard (congatec GmbH)
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 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 777930d1169e..7f512b4f07f7 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -71,13 +71,11 @@ static const struct mfd_cell cgbc_devs[] = {
 	MFD_CELL_NAME("cgbc-hwmon"),
 	{
 		.name = "cgbc-i2c",
-		.id = 1,
 		.platform_data = &cgbc_i2c_i2c0_pdata,
 		.pdata_size = sizeof(cgbc_i2c_i2c0_pdata),
 	},
 	{
 		.name = "cgbc-i2c",
-		.id = 2,
 		.platform_data = &cgbc_i2c_ddc0_pdata,
 		.pdata_size = sizeof(cgbc_i2c_ddc0_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 v5 6/9] i2c: cgbc: Add support for fixed frequency buses
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
                   ` (4 preceding siblings ...)
  2026-11-03 16:49 ` [PATCH v5 5/9] mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 7/9] mfd: cgbc: Add virtual I2C bus support Thomas Richard (congatec GmbH)
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 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 buses).
- 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/mfd/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 40ffab4fd0bc..8623a5d03636 100644
--- a/drivers/i2c/busses/i2c-cgbc.c
+++ b/drivers/i2c/busses/i2c-cgbc.c
@@ -128,7 +128,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) {
@@ -139,18 +138,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);
 
@@ -373,9 +375,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/mfd/cgbc.h b/include/linux/mfd/cgbc.h
index 4b6e41b9ca4a..63fdf16fec95 100644
--- a/include/linux/mfd/cgbc.h
+++ b/include/linux/mfd/cgbc.h
@@ -45,10 +45,12 @@ int cgbc_command(struct cgbc_device_data *cgbc, void *cmd, unsigned int cmd_size
  * struct cgbc_i2c_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_MFD_CGBC_H_*/

-- 
2.53.0


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

* [PATCH v5 7/9] mfd: cgbc: Add virtual I2C bus support
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
                   ` (5 preceding siblings ...)
  2026-11-03 16:49 ` [PATCH v5 6/9] i2c: cgbc: Add support for fixed frequency buses Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 8/9] mfd: cgbc: Add virtual storage devices on the virtual I2C bus Thomas Richard (congatec GmbH)
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 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 7f512b4f07f7..e0d9939d8c0d 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -65,6 +65,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[] = {
 	MFD_CELL_NAME("cgbc-backlight"),
 	MFD_CELL_NAME("cgbc-gpio"),
@@ -79,6 +85,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),
+	},
 	MFD_CELL_NAME("cgbc-wdt"),
 };
 

-- 
2.53.0


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

* [PATCH v5 8/9] mfd: cgbc: Add virtual storage devices on the virtual I2C bus
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
                   ` (6 preceding siblings ...)
  2026-11-03 16:49 ` [PATCH v5 7/9] mfd: cgbc: Add virtual I2C bus support Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-03 16:49 ` [PATCH v5 9/9] i2c: cgbc: Register known I2C devices on the bus Thomas Richard (congatec GmbH)
  2026-11-13 19:44 ` [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Lee Jones
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 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/mfd/cgbc.h |   4 ++
 2 files changed, 133 insertions(+)

diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index e0d9939d8c0d..1be437bb4775 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -13,10 +13,12 @@
 
 #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_device.h>
+#include <linux/property.h>
 #include <linux/sysfs.h>
 
 #define CGBC_IO_SESSION_BASE	0x0E20
@@ -55,6 +57,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,
@@ -69,6 +196,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/mfd/cgbc.h b/include/linux/mfd/cgbc.h
index 63fdf16fec95..46e8b583bdb8 100644
--- a/include/linux/mfd/cgbc.h
+++ b/include/linux/mfd/cgbc.h
@@ -46,11 +46,15 @@ int cgbc_command(struct cgbc_device_data *cgbc, void *cmd, unsigned int cmd_size
  * @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_MFD_CGBC_H_*/

-- 
2.53.0


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

* [PATCH v5 9/9] i2c: cgbc: Register known I2C devices on the bus
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
                   ` (7 preceding siblings ...)
  2026-11-03 16:49 ` [PATCH v5 8/9] mfd: cgbc: Add virtual storage devices on the virtual I2C bus Thomas Richard (congatec GmbH)
@ 2026-11-03 16:49 ` Thomas Richard (congatec GmbH)
  2026-11-13 19:44 ` [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Lee Jones
  9 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-11-03 16:49 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 8623a5d03636..3226838cca46 100644
--- a/drivers/i2c/busses/i2c-cgbc.c
+++ b/drivers/i2c/busses/i2c-cgbc.c
@@ -356,7 +356,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)
@@ -385,7 +385,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 v5 0/9] Congatec Board Controller: Add storage devices support
  2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
                   ` (8 preceding siblings ...)
  2026-11-03 16:49 ` [PATCH v5 9/9] i2c: cgbc: Register known I2C devices on the bus Thomas Richard (congatec GmbH)
@ 2026-11-13 19:44 ` Lee Jones
  2026-11-13 19:51   ` Thomas Richard
  9 siblings, 1 reply; 12+ messages in thread
From: Lee Jones @ 2026-11-13 19:44 UTC (permalink / raw)
  To: Thomas Richard (congatec GmbH)
  Cc: Andi Shyti, Thomas Petazzoni, Werner Gartner, mfd, linux-kernel,
	linux-i2c, stable, Sashiko

On Tue, 03 Nov 2026, Thomas Richard (congatec GmbH) wrote:

> In this v5, I re-ordered a bit the patches to fix I2C bus names first.
> I also made an error message more user friendly.
> 
> Lee, this series conflicts with some other ongoing patches series:
> - mfd: Assorted resource lifetime, teardown, and error-handling fixes [1]
> - mfd: Constify mfd_cell arrays [2]
> 
> To make your life easier I rebased this series on top of them. Please let
> me know if you want to proceed in an other way. 

I think these are all applied now - less my I2C patch, which you are
free to collect.

I'm ready to apply this set.

Does this have to go in as a set or are the MFD patches orthogonal?

> [1] https://lore.kernel.org/all/20261027093306.2812695-1-lee@kernel.org/
> [2] https://lore.kernel.org/all/20261030071137.100954-3-krzysztof.kozlowski@oss.qualcomm.com/
> 
> Best Regards,
> Thomas
> 
> Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
> ---
> Changes in v5:
> - mfd: fix error message in case we fail to get session handle.
> - fix I2C bus names earlier in the series.
> - Link to v4: https://patch.msgid.link/20261002-cgbc-i2c-storage-devices-support-v4-0-eb42e0f1df59@bootlin.com
> 
> Changes in v4:
> - Fix struct cgbc_i2c_platform_data comment (kernel-doc warning)
> - Move struct cgbc_i2c_platform_data from linux/platform_data/i2c-cgbc.h to
>   linux/mfd/cgbc.h
> - Use MFD_CELL_NAME macros.
> - Link to v3: https://patch.msgid.link/20260911-cgbc-i2c-storage-devices-support-v3-0-594b53fbc5ea@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
>       i2c: cgbc: Use real I2C bus names
>       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
>       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
> 
>  drivers/i2c/busses/i2c-cgbc.c | 108 ++++++++++++------------
>  drivers/mfd/cgbc-core.c       | 187 +++++++++++++++++++++++++++++++++++++++---
>  include/linux/mfd/cgbc.h      |  16 ++++
>  3 files changed, 244 insertions(+), 67 deletions(-)
> ---
> base-commit: d3dfdb6b429a5b99bfd47176bf07cad0956f14ed
> change-id: 20260717-cgbc-i2c-storage-devices-support-b3ee7cea3320
> prerequisite-message-id: 20261027093306.2812695-1-lee@kernel.org
> prerequisite-patch-id: 7d50ed21b2d5d1bb25290d19c46b4668073feddf
> prerequisite-patch-id: 45cdf12f5527ab86a560ba98c02cc447bf6eee4e
> prerequisite-patch-id: 6148da531ee7713f8afb7bec90fb3f548b562d28
> prerequisite-patch-id: fb0c30c409ef451192973c417a0585f989f8917b
> prerequisite-patch-id: 8403fcd8efcd44138f139767624773fa654a5a2f
> prerequisite-patch-id: 434546741519ecd3032e19f3acf2c5370e9a454c
> prerequisite-patch-id: 29540ca5739d6f6f3e2d3fe5b87893ad31f6c3ee
> prerequisite-patch-id: a33adadb2e2efe82d2a14417c1c35c579bf212d0
> prerequisite-patch-id: dd53f1e6db35d71b51061dad45de28dde9ebc70f
> prerequisite-patch-id: 85a1da1285d64ce3fc78c8ae7969fbb0dc7c3cd7
> prerequisite-patch-id: e9b952ebc380d058ac2144771c780a0b08c3b7c3
> prerequisite-patch-id: 1f0dcc7a8c5df7ae1c8bfb5a1c8f62b441704286
> prerequisite-patch-id: 077a4ef70d74321711e2efd4e016e01a1d41c818
> prerequisite-patch-id: 4dcd6cc156bb6ba43684605972fb179557a3891e
> prerequisite-patch-id: 62e87491674feaae09327a99a5ff1b4ed368f221
> prerequisite-patch-id: ab1eac435fd40cdb3d9a8d453a12852a105f57c4
> prerequisite-patch-id: 1cbcc3b666db27cbe9f3fa6c6ead2f49a0d459da
> prerequisite-patch-id: ecb566a7bea44600e9d7e9617e280c994773e3dd
> prerequisite-patch-id: 20e295db85a31587d342471a3c341615c8eb0fd7
> prerequisite-patch-id: 06118bf6e5affc234e7edbdb5c0aae9b05412b33
> prerequisite-patch-id: 17afeb13c5012348feee8eb739ff058e84ed2df8
> prerequisite-patch-id: 27693bdeffbc7a0a295c165912b89af5ca3264aa
> prerequisite-patch-id: 8313fe2293eaf0e69ffd2f0017e18fde64ca68f7
> prerequisite-patch-id: fc53af34353efecb4490087ed066ccb256a74695
> prerequisite-patch-id: 02ad8a3b1fddb4f4e806939d36ae642c01004c36
> prerequisite-patch-id: 7b9b8460613f4240492ffe11ee7ee0e6c0b6ded8
> prerequisite-patch-id: 699c068a32ac9d3171e7a494fb2ca5522045779a
> prerequisite-message-id: 20261030140240.211786-3-krzysztof.kozlowski@oss.qualcomm.com
> prerequisite-patch-id: f6cf975bf90acb029fa985ecd659b59076fdc0cd
> prerequisite-patch-id: 4f16ad80662de796ae1454904c938e7e85115fbd
> 
> Best regards,
> --  
> Best Regards,
> Thomas Richard
> 

-- 
Lee Jones

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

* Re: [PATCH v5 0/9] Congatec Board Controller: Add storage devices support
  2026-11-13 19:44 ` [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Lee Jones
@ 2026-11-13 19:51   ` Thomas Richard
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Richard @ 2026-11-13 19:51 UTC (permalink / raw)
  To: Lee Jones
  Cc: Andi Shyti, Thomas Petazzoni, Werner Gartner, mfd, linux-kernel,
	linux-i2c, stable, Sashiko

On 11/13/26 8:44 PM, Lee Jones wrote:
> On Tue, 03 Nov 2026, Thomas Richard (congatec GmbH) wrote:
> 
>> In this v5, I re-ordered a bit the patches to fix I2C bus names first.
>> I also made an error message more user friendly.
>>
>> Lee, this series conflicts with some other ongoing patches series:
>> - mfd: Assorted resource lifetime, teardown, and error-handling fixes [1]
>> - mfd: Constify mfd_cell arrays [2]
>>
>> To make your life easier I rebased this series on top of them. Please let
>> me know if you want to proceed in an other way. 
> 
> I think these are all applied now - less my I2C patch, which you are
> free to collect.
> 
> I'm ready to apply this set.
> 
> Does this have to go in as a set or are the MFD patches orthogonal?

They have to go in a set because of the switch to PLATFORM_DEVID_AUTO
and plateform data usage.

Best Regards,
Thomas

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

end of thread, other threads:[~2026-11-13 19:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 16:49 [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 1/9] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 2/9] i2c: cgbc: Use real I2C bus names Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 3/9] mfd: cgbc: Add I2C platform data Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 4/9] i2c: cgbc: Use plateform data to get bus ID and adapter name Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 5/9] mfd: cgbc: Use PLATFORM_DEVID_AUTO for child device registration Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 6/9] i2c: cgbc: Add support for fixed frequency buses Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 7/9] mfd: cgbc: Add virtual I2C bus support Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 8/9] mfd: cgbc: Add virtual storage devices on the virtual I2C bus Thomas Richard (congatec GmbH)
2026-11-03 16:49 ` [PATCH v5 9/9] i2c: cgbc: Register known I2C devices on the bus Thomas Richard (congatec GmbH)
2026-11-13 19:44 ` [PATCH v5 0/9] Congatec Board Controller: Add storage devices support Lee Jones
2026-11-13 19:51   ` Thomas Richard

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®