From nobody Tue Sep 29 06:11:02 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12B2E3BCD15; Tue, 11 Aug 2026 16:15:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464933; cv=none; b=mobyNMelTv8bLp6OsyUqocehbWAUBWgfNQtbGsaKA3FnqAzQ8L2mg5VVDQjkt3Q/c9x/V24AD9KBaPN9UkoVAxHYztcffDVw/5zZtxh9gCDKoigJxHwGaK1uLhs4SqXtHcYclmGkNOy/79KiETvifWmMboarCQgnnc8QAe3mUXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464933; c=relaxed/simple; bh=gb+fwROmnOkLdeNycb9l18F0EWuU7KY89ynmb/WqDF4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iQL+VEenNq7wnRI+QO4HgvlNl/8g0jRJCwHqt/pOcVcvJTWv2uO7WUJfJKYuyNg7iWgGkB7l8cMkD8tXUbaUnw7QxKcgJgmsJJseYIeupTn+gQ/FEfmhsJg6dqpNUgq2CAPO8PiaoOH5/1JTyNupAsI8PTEekUSX/O8qYA3iUfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=pCNlLA79; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="pCNlLA79" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 9A5AD1A1570; Tue, 11 Aug 2026 16:15:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 68C206033C; Tue, 11 Aug 2026 16:15:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6D2CA11C48FA8; Tue, 11 Aug 2026 18:15:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786464925; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=HAyABBQS0V8BnfnIm9rFYNSgw2zlmJq/eAOs916odWA=; b=pCNlLA798FKrWL8fUi9p3sK5BlMSIFQF3uUQSugJ1Sm+wCSUnrAMCKU2K6MYYPecOlaQ40 jxYcF0DvNX+1F+vmWxzaWfVCytG0Bw9n4tjGvNbLV4xx2wX2/+EGj/fZo9n+qwFxZC4VQX LFUoIyCwyAGDtJ+z991Z6LwxzzPIi6yGs9U7fbwKe+dBftWGMxO0RYoGfghohOyJ+m4n/u KC7uofdDLrbKQNrHg2B7NwjDc4LsaZx7QEu/AGMrTH5FrRir98Jhx8uV3z9K716vIrXNBn ByBsxgMCpY7rFMm5xW0OOgXuWb9tVXIpU9SRAaLfRxOAGscIfKuuUcdv82hDPA== From: "Thomas Richard (congatec GmbH)" Date: Tue, 11 Aug 2026 18:15:02 +0200 Subject: [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260811-cgbc-i2c-storage-devices-support-v2-1-3efa998e0ef5@bootlin.com> References: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> In-Reply-To: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> To: Lee Jones , Andi Shyti Cc: Thomas Petazzoni , Werner Gartner , mfd@lists.linux.dev, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, "Thomas Richard (congatec GmbH)" , stable@vger.kernel.org, Sashiko X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 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 Closes: https://sashiko.dev/#/patchset/20260713-cgbc-core-fix-cgbc-remove-v= 1-1-79274ad62b3a%40bootlin.com?part=3D1 Fixes: 6f1067cfbee7 ("mfd: Add Congatec Board Controller driver") Signed-off-by: Thomas Richard (congatec GmbH) --- 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_dat= a *cgbc) if (ret) return dev_err_probe(cgbc->dev, ret, "device not found or not ready\n"); =20 - cgbc->session =3D cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST); + ret =3D 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 =3D ret; =20 /* The Board Controller sent us a wrong session handle, we cannot communi= cate with it */ if (cgbc->session < CGBC_SESSION_VALID_MIN || cgbc->session > CGBC_SESSIO= N_VALID_MAX) --=20 2.53.0 From nobody Tue Sep 29 06:11:02 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E48393BCD15 for ; Tue, 11 Aug 2026 16:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464938; cv=none; b=ZZUzwYcBCI0hBjpOUV621/8InERMwHXZNpsr/5R8kigNWNmBAtF/XDyRKV49e20CCjSj+r/Z9Z+vGGH0qiPdVtmDogvd+Xoysq+AZ6GL3zf9UCOp6HWstRMSbpIxS+Zval1zxNd26OOtt/e9TMotDMXowFobxgWZC/lSklDaUaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464938; c=relaxed/simple; bh=wc21kG4AX+ZzJq0gJVXiWEcD+lnUKOYtfwLGM0hGkZ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z6cjILFAxVj7UH8Z0tpWaflxcpAJOD6psr8DBelnS1nncZhNvKvuJg6vWPzvk5mKMa3YurKtgn9Zf1VXf6oshr3fg/e00qO8ENI2s24slZn0iMcjnEuvgyEL7pP/oewb1SBJXimoJRjApNksAn1MG+4xZTKdCftMeFL0zc5YBmo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=T9QBwAJc; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="T9QBwAJc" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 711D11A1570; Tue, 11 Aug 2026 16:15:35 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4598E6033C; Tue, 11 Aug 2026 16:15:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C3E2111C48FAA; Tue, 11 Aug 2026 18:15:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786464930; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=IojpC1611eNpzo/tBaBNvfHDBqXXqjdiSpsL7i7OgbM=; b=T9QBwAJckWUfHjAs534fe1YJcsBfKdQHIgEZHWkL/oHLk3/loVGPHrYZyL5vHKXQDdJmKz 2ddqnrG7wrDJwgYcEFqqPqdMq4nBiFvPUGfncTwA16F3dGunSJXTXaXEgbNtbTeJTcRikl 6jm+NPl7H26cW5yoaaKjJBOFRe33hLlJuIZBnJR5Kn6AB3kl9isOpMQa5qAbnLqKtvogAk lwaOQL/Uce6xJzeQk8CH2VrZdjkbh5aNYfVdvhkl/svoqcKQg53eTJohRXwthqr4H5Mw27 McJagdNfuDx+uXMAG4yJ4ILw+mvCjomClKYBNTHxoo8K4zUiBpjsRxT6XOA2BQ== From: "Thomas Richard (congatec GmbH)" Date: Tue, 11 Aug 2026 18:15:03 +0200 Subject: [PATCH v2 2/5] mfd: cgbc: Make cgbc_devs const Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260811-cgbc-i2c-storage-devices-support-v2-2-3efa998e0ef5@bootlin.com> References: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> In-Reply-To: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> To: Lee Jones , Andi Shyti Cc: Thomas Petazzoni , Werner Gartner , mfd@lists.linux.dev, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, "Thomas Richard (congatec GmbH)" X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 Make cgbc_devs const, so it will be placed in .rodata section. Signed-off-by: Thomas Richard (congatec GmbH) --- drivers/mfd/cgbc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c index 4a409234e66c..f09fd671bc8c 100644 --- a/drivers/mfd/cgbc-core.c +++ b/drivers/mfd/cgbc-core.c @@ -235,7 +235,7 @@ int cgbc_command(struct cgbc_device_data *cgbc, void *c= md, unsigned int cmd_size } EXPORT_SYMBOL_GPL(cgbc_command); =20 -static struct mfd_cell cgbc_devs[] =3D { +static const struct mfd_cell cgbc_devs[] =3D { { .name =3D "cgbc-wdt" }, { .name =3D "cgbc-gpio" }, { .name =3D "cgbc-i2c", .id =3D 1 }, --=20 2.53.0 From nobody Tue Sep 29 06:11:02 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28310466AF0 for ; Tue, 11 Aug 2026 16:15:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464943; cv=none; b=ZkfUJEmtzLXz3tB9n9FvSfReYmLO+08/7cAWCN4Xo4jEIHbq+ELKak2YVBcMgde8AVT3jSSbbcu3xz6Xmz+uaZBotKV4OS85NpaAyRsfrD+xWZKWx2GzmPucZVM5DosdY06hX4DhY+uQQibdHGxz+bQlubIu43tf9aAS5J/eoto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464943; c=relaxed/simple; bh=ZLgJuGU8Ic5vC5CZea8olQRzH82TCCtZe6fwZgqol4o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GYL3bVjp1TBzlsfBVmk2ZgA0WChN/T4l+iBjf/v005mYECi6+xpmVAwxjznWHshaA9VbhHraCgz/VlniBI3XfNF2HRq6yktWDDq74A9iI8ajfFZIxaXjdkulrcDFxAfWTa+CliY2Q1ayQAXQlEkAWn/40LtdW6p0/wD1StNbbF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=zRw6td3f; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="zRw6td3f" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 817F64E411B7; Tue, 11 Aug 2026 16:15:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 581FD6033C; Tue, 11 Aug 2026 16:15:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E8D2111C48FAB; Tue, 11 Aug 2026 18:15:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786464935; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wpVsJatbmKsVB9MeKoIPsRTovacTGNP+K3jGdUo8QQI=; b=zRw6td3fTafqIuJCZzLjdu6yppEhY4klmqi0X93T8qwODxhrdV7yp50TSIWGClpFfzPI8d fCN0UW1Zk57xBxWXlpRQMJtpLVWr6lWVUEg0m80Rwgl4KRDy7XlVQunckIdrPoTgoMhIq4 RXOQrIAiMgHlkypUQkUi776+7ERu1wNGn/ZiWkoe/xnt1Ge4gvsDppP0E1R1K1u8E+3GK0 xMFgXMv+j9dIfKesACSDrqNZXKs5rhgCmJKbK+/81Kl2nKJ9/1KosdJxFrm7X0kAZTrRiP yjYqUL3jHKfiDUKJtvXeapG0cLBCCTuzD4K26Qf979bKNnb5+1uAmMpHnyV7XQ== From: "Thomas Richard (congatec GmbH)" Date: Tue, 11 Aug 2026 18:15:04 +0200 Subject: [PATCH v2 3/5] i2c: cgbc: Add virtual I2C bus support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260811-cgbc-i2c-storage-devices-support-v2-3-3efa998e0ef5@bootlin.com> References: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> In-Reply-To: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> To: Lee Jones , Andi Shyti Cc: Thomas Petazzoni , Werner Gartner , mfd@lists.linux.dev, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, "Thomas Richard (congatec GmbH)" X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 Internally the Board Controller has a virtual I2C bus with some virtual storage devices on it. Add support for it by defining a i2c_adapter entry. This virtual bus has a fixed frequency that cannot be changed. Signed-off-by: Thomas Richard (congatec GmbH) --- drivers/i2c/busses/i2c-cgbc.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-cgbc.c b/drivers/i2c/busses/i2c-cgbc.c index 25a74fa51aa0..c3f1c83b105a 100644 --- a/drivers/i2c/busses/i2c-cgbc.c +++ b/drivers/i2c/busses/i2c-cgbc.c @@ -13,6 +13,7 @@ #include =20 #define CGBC_I2C_PRIMARY_BUS_ID 0 +#define CGBC_I2C_VIRTUAL_BUS_ID 3 #define CGBC_I2C_PM_BUS_ID 4 =20 #define CGBC_I2C_CMD_START 0x40 @@ -147,11 +148,14 @@ static int cgbc_i2c_set_frequency(struct i2c_adapter = *adap, cmd[0] =3D CGBC_I2C_CMD_SPEED | algo_data->bus_id; cmd[1] =3D cgbc_i2c_freq_to_reg(bus_frequency); =20 - ret =3D 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); + /* Virtual bus has a fixed frequency */ + if (algo_data->bus_id !=3D CGBC_I2C_VIRTUAL_BUS_ID) { + ret =3D 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); + } =20 cmd[1] =3D 0x00; =20 @@ -338,6 +342,7 @@ static const struct i2c_algorithm cgbc_i2c_algorithm = =3D { static struct i2c_algo_cgbc_data cgbc_i2c_algo_data[] =3D { { .bus_id =3D CGBC_I2C_PRIMARY_BUS_ID }, { .bus_id =3D CGBC_I2C_PM_BUS_ID }, + { .bus_id =3D CGBC_I2C_VIRTUAL_BUS_ID }, }; =20 static const struct i2c_adapter cgbc_i2c_adapter[] =3D { @@ -357,6 +362,14 @@ static const struct i2c_adapter cgbc_i2c_adapter[] =3D= { .algo_data =3D &cgbc_i2c_algo_data[1], .nr =3D -1, }, + { + .owner =3D THIS_MODULE, + .name =3D "Congatec Virtual I2C adapter", + .class =3D I2C_CLASS_DEPRECATED, + .algo =3D &cgbc_i2c_algorithm, + .algo_data =3D &cgbc_i2c_algo_data[2], + .nr =3D -1, + }, }; =20 static int cgbc_i2c_probe(struct platform_device *pdev) --=20 2.53.0 From nobody Tue Sep 29 06:11:02 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86B96466B47 for ; Tue, 11 Aug 2026 16:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464949; cv=none; b=YioPvsgs58waaHcvd4dpjjEwkO8YpkjvIv5zfYOSFpOao3o8I0lRRq5dpM+a9M9Gp1cWezmENfKB7mT5KgStBMNrT6wHoRH64ZP+GnYJ3uiG5hoCraBMPNFl8Mq5t49AxqCZdtvfmG4KIlrSo5QONqbLH+W082PCdmNe8kwET+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464949; c=relaxed/simple; bh=TGXtrZXdjVqoMa48XR5MI8NAV1kEc9n6IXNdRcpAAaM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W4J9U76lpIwWP7vBl5nUWShH5BHKtXfE2X5ZGBugIQWDkdrvSWrlb40bCvCTdm2DxMInHPjrdSzxVzq0PCkkiXIVsf9Fn/Hw1Zbf1c6iH6L7eMB1oaHk9pF5OwEFW1tqo2c+b8aadYvNeSTwePuqr87+BE/JqnLv1zXi1ZWl4+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KiWyFUmk; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KiWyFUmk" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id F12A94E411B7; Tue, 11 Aug 2026 16:15:45 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C4AA96033C; Tue, 11 Aug 2026 16:15:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id F046011C48FAE; Tue, 11 Aug 2026 18:15:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786464941; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=swodfQHwP9uXMPGV1udBQbxCGjaTe6Q09FMEiRmHWfU=; b=KiWyFUmk5IrIi71HwscYdukh1eqz/jBjbRlGnq1PAah8eRYy6hjHk+jUe+SRTjDxSyOmRR lQaWsxU0Z+LVBAhnhPLY1/5G/0z86sxF++7CKPZWhOwbxoY+l3Bj0JASWfC7LBwMrtYTi8 nLHyLClAOUAjyA6wTP+9EtGrNjfFvOYkBTA1Q+xygkS8QGXWvXF0PzItY2r4Jt21gPa8Sr GBSvfHhSWFMT1AylbrwlBjckSJc8NYHJOU9i4+amB/FeZpI8vO/J8sYZqQU1V2tzBR2HGy YajJiPBaork/e/4WkHpSRKMZhFfdPv3KysyJJfGkJxfRc2W5E+S98DWbmoUPUA== From: "Thomas Richard (congatec GmbH)" Date: Tue, 11 Aug 2026 18:15:05 +0200 Subject: [PATCH v2 4/5] mfd: cgbc: Add virtual I2C bus support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260811-cgbc-i2c-storage-devices-support-v2-4-3efa998e0ef5@bootlin.com> References: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> In-Reply-To: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> To: Lee Jones , Andi Shyti Cc: Thomas Petazzoni , Werner Gartner , mfd@lists.linux.dev, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, "Thomas Richard (congatec GmbH)" X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 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 virtual bus. Signed-off-by: Thomas Richard (congatec GmbH) --- drivers/mfd/cgbc-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c index f09fd671bc8c..e800a0f4e50a 100644 --- a/drivers/mfd/cgbc-core.c +++ b/drivers/mfd/cgbc-core.c @@ -240,6 +240,7 @@ static const struct mfd_cell cgbc_devs[] =3D { { .name =3D "cgbc-gpio" }, { .name =3D "cgbc-i2c", .id =3D 1 }, { .name =3D "cgbc-i2c", .id =3D 2 }, + { .name =3D "cgbc-i2c", .id =3D 3 }, { .name =3D "cgbc-hwmon" }, { .name =3D "cgbc-backlight" }, }; --=20 2.53.0 From nobody Tue Sep 29 06:11:02 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DF65468C30; Tue, 11 Aug 2026 16:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464953; cv=none; b=jOdaBbMN6/cvgeglyHNN6MJdxR+Bb0dG+z+lelX75XS+p6Eop9xd9c6mG1q61LcqSi2FYebF6slEofG/2Epq9P13RrtGXa5Xsv+TQt85ljARWbD3/xy2z+vIQIam4zIrcFi9FhWDRvSvLkJfw4sVj/O3h8A5sPzDG8+ML44mYGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464953; c=relaxed/simple; bh=C95/eT/B4XgIoNYdkna/BJk2cUyTQgBKearWQIH0Omo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MQMWz9hssR3iuRBzAC9JO5odXS3NcxCKCzFjsEOJP0ONTGbdSMi4GhyASC8svt04CHD5G0QFX+Tq1wO5tUXK1FzUIoFG3ujFWjLff0djH6XXJeeOdSqkc1Ix5mArCFGAwMQA1ny7I+IViX1wbPqSRx0sp/RamUmbC8xRFp1d6vY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=NxRFacBB; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="NxRFacBB" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id CDEAD4E411B7; Tue, 11 Aug 2026 16:15:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A35756033C; Tue, 11 Aug 2026 16:15:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5BE2C11C48FB5; Tue, 11 Aug 2026 18:15:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786464946; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/1MK41sLZ4JfBlj5GNXVc1XloBGgOyqLMLE6J7DkXhw=; b=NxRFacBB7eL4zuyPyj9vfKDpbjfZd9yyv1JSFdibG5IejcVfYko/3UgeiTF9503FVCv4Xi N3VMyxiZpkZj4TQ/FX1KxFjg4QcA5yGxkzy+v0L/LKk4aGQfrOX83S+wMm9N3wT2PsYx4w q8NMKeYk8i52sDsXIAT8kbxHXPs/fotqus8GR9BpQP9xfnweXGj2meWuh7jD0mWdfNekjV RLk8QiDvruXLqulemQMXJMvdZqs9494mN1m6/iF+p3r7nmSfwoL3ieDOGai2+phiRdTwAu TkKBIeIYbHDBwNK6O6a12E2GwSHnJckxEVgsYkZX1YZmsFM6c+ebSjJy6xUuxw== From: "Thomas Richard (congatec GmbH)" Date: Tue, 11 Aug 2026 18:15:06 +0200 Subject: [PATCH v2 5/5] i2c: cgbc: Add virtual storage devices on the virtual I2C bus Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260811-cgbc-i2c-storage-devices-support-v2-5-3efa998e0ef5@bootlin.com> References: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> In-Reply-To: <20260811-cgbc-i2c-storage-devices-support-v2-0-3efa998e0ef5@bootlin.com> To: Lee Jones , Andi Shyti Cc: Thomas Petazzoni , Werner Gartner , mfd@lists.linux.dev, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, "Thomas Richard (congatec GmbH)" X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 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) --- drivers/i2c/busses/i2c-cgbc.c | 151 ++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 150 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-cgbc.c b/drivers/i2c/busses/i2c-cgbc.c index c3f1c83b105a..e36755cc963b 100644 --- a/drivers/i2c/busses/i2c-cgbc.c +++ b/drivers/i2c/busses/i2c-cgbc.c @@ -372,6 +372,149 @@ static const struct i2c_adapter cgbc_i2c_adapter[] = =3D { }, }; =20 +static const struct property_entry cgbc_secure_data_eeprom_props[] =3D { + 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 =3D { + .properties =3D cgbc_secure_data_eeprom_props, +}; + +static const struct property_entry cgbc_bc_eeprom_props[] =3D { + 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 =3D { + .properties =3D cgbc_bc_eeprom_props, +}; + +static const struct property_entry cgbc_user_eeprom_props[] =3D { + 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 =3D { + .properties =3D cgbc_user_eeprom_props, +}; + +static const struct property_entry cgbc_bios_eeprom_props[] =3D { + 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 =3D { + .properties =3D cgbc_bios_eeprom_props, +}; + +static const struct property_entry cgbc_bc_ram_props[] =3D { + 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 =3D { + .properties =3D cgbc_bc_ram_props, +}; + +static const struct property_entry cgbc_user_ram_props[] =3D { + 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 =3D { + .properties =3D cgbc_user_ram_props, +}; + +static const struct property_entry cgbc_bios_ram_props[] =3D { + 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 =3D { + .properties =3D cgbc_bios_ram_props, +}; + +static const struct i2c_board_info cgbc_i2c_board_info[] =3D { + { + .type =3D "24c01", + .addr =3D 0x40, + .dev_name =3D "cgbc-secure-data-eeprom", + .swnode =3D &cgbc_secure_data_eeprom_node, + }, + { + .type =3D "24c01", + .addr =3D 0x48, + .dev_name =3D "cgbc-bc-eeprom", + .swnode =3D &cgbc_bc_eeprom_node, + }, + { + .type =3D "24c01", + .addr =3D 0x50, + .dev_name =3D "cgbc-user-eeprom", + .swnode =3D &cgbc_user_eeprom_node, + }, + { + .type =3D "24c01", + .addr =3D 0x58, + .dev_name =3D "cgbc-bios-eeprom", + .swnode =3D &cgbc_bios_eeprom_node, + }, + { + .type =3D "24c01", + .addr =3D 0x60, + .dev_name =3D "cgbc-bc-ram", + .swnode =3D &cgbc_bc_ram_node, + }, + { + .type =3D "24c01", + .addr =3D 0x68, + .dev_name =3D "cgbc-user-ram", + .swnode =3D &cgbc_user_ram_node, + }, + { + .type =3D "24c01", + .addr =3D 0x70, + .dev_name =3D "cgbc-bios-ram", + .swnode =3D &cgbc_bios_ram_node, + } +}; + +static void cgbc_i2c_instantiate_devices(struct i2c_adapter *adap) +{ + struct i2c_algo_cgbc_data *algo_data =3D adap->algo_data; + struct i2c_client *client; + int i; + + /* We only instantiate devices on Virtual bus */ + if (algo_data->bus_id !=3D CGBC_I2C_VIRTUAL_BUS_ID) + return; + + for (i =3D 0; i < ARRAY_SIZE(cgbc_i2c_board_info); i++) { + client =3D i2c_new_client_device(adap, &cgbc_i2c_board_info[i]); + if (IS_ERR(client)) + dev_err(&adap->dev, "Failed to register %s\n", + cgbc_i2c_board_info[i].dev_name); + } +} + static int cgbc_i2c_probe(struct platform_device *pdev) { struct cgbc_device_data *cgbc =3D dev_get_drvdata(pdev->dev.parent); @@ -393,7 +536,13 @@ static int cgbc_i2c_probe(struct platform_device *pdev) if (ret) return ret; =20 - return i2c_add_numbered_adapter(&i2c->adap); + ret =3D i2c_add_numbered_adapter(&i2c->adap); + if (ret) + return ret; + + cgbc_i2c_instantiate_devices(&i2c->adap); + + return ret; } =20 static void cgbc_i2c_remove(struct platform_device *pdev) --=20 2.53.0