From nobody Fri Oct 2 06:18:28 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 E6DB438B12A for ; Tue, 4 Aug 2026 14:56:15 +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=1785855378; cv=none; b=Kpby1JHwjEBo5dOciiMZmzzF+U7faaOU4x/9WUI/v34rrKLAQJtIak6rzpW8zg/fCfwEfZFeyvQ8w5qGj26lcwTwvaja8pMocF8JrDvEY7kIOdJ5dknq4yXuLFRVxJ50hUZDF6Xrpr9FSPf5pEK0qm4QD83wlO0KK6d6Yv97LSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785855378; c=relaxed/simple; bh=gb+fwROmnOkLdeNycb9l18F0EWuU7KY89ynmb/WqDF4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rnzlVeKMBOVwnkSlQ3EUgx5mmZTqXXWbaHGGdfjExqJj/0uc5D4Pk2s4EE2tLR3kjC3e3nFM3uKSyWp1M5BDwIVXLwtURLSGOP6k0JcbQ0d2SX8ZvjmRbKct7vPSe+ll8ritIZdjIYHY0RchSe2YmQqs4tXmoOwj/YkEKQ8gaAo= 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=UWyDvUBP; 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="UWyDvUBP" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 4FB111A140B; Tue, 4 Aug 2026 14:56:14 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 208A26029E; Tue, 4 Aug 2026 14:56:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9FF5B11C32F24; Tue, 4 Aug 2026 16:56:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1785855373; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=HAyABBQS0V8BnfnIm9rFYNSgw2zlmJq/eAOs916odWA=; b=UWyDvUBPHxqpC/K3b7ba7cNASkBTJy0niCMXlnZ7O11NmoDYJkA/RQQM90r+El7A/m5Bao Gdf9W97gY6A+k/eiqdfzC3LVMIoPVE8HtU8XYait/AWxfvyLhfehdsayyAq7/A5sPFb0xi 7i9M/1ko00erOTvJ+dWxry8pGEY2NGXFjzvILiwRtvYo7iTyHKIa0oE5/9DjEnWnfyJeO4 k5cJy8vsnErdHNVw2P5uvQh3HhHSH1id4KVT4kZq0HJKiGpXKGIyrf3EwYSBphxY3dbKeL qDMq+Rdz11ABjPNWp9iw8gmP0dm+Eqae8Km7fJMFoV4kW1D6kU08fXeQKpI6Cw== From: "Thomas Richard (congatec GmbH)" Date: Tue, 04 Aug 2026 16:55:51 +0200 Subject: [PATCH 1/4] 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: <20260804-cgbc-i2c-storage-devices-support-v1-1-fed38510671c@bootlin.com> References: <20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@bootlin.com> In-Reply-To: <20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@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 Fri Oct 2 06:18:28 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 A618C46AA64 for ; Tue, 4 Aug 2026 14:56:20 +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=1785855382; cv=none; b=QMa4m9eiudn+/8OTNJvLn9s3KDiMksDOfej/8mxbTPcXF8xvgWkE6wneKL+uWBpZ/n7Z527PpOERZ72uey+4Zod2Mu47QbDQUNmImq40Q7xxvRZV28aVtPpY2WtsZqk+Qp5+73VRFccZJD/i/3gDq3vPVPpH1o29fk5U+9zp3DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785855382; c=relaxed/simple; bh=ZLgJuGU8Ic5vC5CZea8olQRzH82TCCtZe6fwZgqol4o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zjn/wg+vrIDxXxDBAO3zko+L5xcPDwcW0uInm8PI+541tHigycADp4g4DIK2ajKNkn1dz9lX+INk03qRs3QoXOC16bCla5D/RyJlg5fe6nGDRFO70v0fRTRgjC6s2m8bcZHVPWR8v5jDyYWk4sxAno4241rBnlzkcuMnxjEdMQI= 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=c4SBPcpG; 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="c4SBPcpG" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 22E884E410DE; Tue, 4 Aug 2026 14:56:19 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E8AE36029E; Tue, 4 Aug 2026 14:56:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C392C11C32F33; Tue, 4 Aug 2026 16:56:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1785855374; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wpVsJatbmKsVB9MeKoIPsRTovacTGNP+K3jGdUo8QQI=; b=c4SBPcpGR3y961C/PATwCD2A5ZIdopV4tcYceUoDFwQ9/ikIIvk5Tn0WJKjHVEtzz6Mk4l uJsJCFN3cEFnLc3y+cdwLGZUWAwBMgGnEgg4WjT6qs/50WP9XcGCLhgOJ4DcoyChiaz5Jc jypnaXFwN8fp5/m1EjZ376f69BLUrqCC7b9svzgBDEi8trOL1b1tSbhy+12SSAzqkPjC20 /xp6sqtLEHiNddC3nSvy9rdXpmQlLpTcBhfV2xlw1CvqMSqRoq2fmjMTcg45HeELKjcGcE LaNBq0riDPYQYcGsxMA/S0YkPBDPvkuGBum00tB30Fzg5eIQLLe4S15U29YyfQ== From: "Thomas Richard (congatec GmbH)" Date: Tue, 04 Aug 2026 16:55:52 +0200 Subject: [PATCH 2/4] 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: <20260804-cgbc-i2c-storage-devices-support-v1-2-fed38510671c@bootlin.com> References: <20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@bootlin.com> In-Reply-To: <20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@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 Fri Oct 2 06:18:28 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 8FFC046C4B2; Tue, 4 Aug 2026 14:56:25 +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=1785855387; cv=none; b=lqHpaJjC/j6DsOXUO33jCer0YqinuliAdx0Arso6gmT64XdXWgqaFIezBW5F1h3J3HvKAYezwrZuxi6KUKnMEXZK0mC0hHyJdJtMiaEzAsi4wa4gmI3r8OuZ3ItlVg+QYF4su8xhXG9qG6hAbghvnN6Sm/OMHDRG8i1x364Xpb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785855387; c=relaxed/simple; bh=RmSrwG1F/7aFAs+HK0sePhP3Sxnni0CaFwzbwEbsY8Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ok91UFFp5pgcj37kU+FYOxgvy1q9lLfsOW1+hPNpE64H5XAj5rZaQSrkNeXp9gXTDjMREQkEtRDVNoq461NkKjzwwjfV3NO2a7jRV1Y2Fa+tTm/cFnlSBj0M+kfFs3AoseBkDvucRGZCEFkBXCZZ9vuzyqM1/KYkU575yNFMgpw= 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=0cqLLQLw; 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="0cqLLQLw" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 33E791A140A; Tue, 4 Aug 2026 14:56:24 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 060F46029E; Tue, 4 Aug 2026 14:56:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A151E11C32F24; Tue, 4 Aug 2026 16:56:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1785855379; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=sKJTZ3340Wy50yFmZKeX4ClEQ3lKUgb8dpkNiuzSFvM=; b=0cqLLQLwDEvg9gnAs07pGYm6N9sU3ZDiMTf2M+f4TSdVvfvEXJeYVCewlvyUiLmUnZUlsz 7Mc2mxLQK/9E20mb2AnA7hdtorR7YI9VVgzNzDecTb2UMBDFKDW8AOGljgSBOGhakQillE 5QniHtghbIw50GAeS13+/r+wcEF9s7yOIxgfIkswvmjd4XRC5BQ7Runmz6TXd5ZoJPEoVu NAGpXWTwuHfzVzqUm+J0Crx3mQCiU3ipYfLr3cAZRIGfzg/nflDIbz0TCnwq6C1eCE54Ex 7zdJfnISVpLLLEAD8PRhsuPjr/errUv+p4U6bV3l2xbfxmbVSitvZ4VbSnFFxw== From: "Thomas Richard (congatec GmbH)" Date: Tue, 04 Aug 2026 16:55:53 +0200 Subject: [PATCH 3/4] 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: <20260804-cgbc-i2c-storage-devices-support-v1-3-fed38510671c@bootlin.com> References: <20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@bootlin.com> In-Reply-To: <20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@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 4a409234e66c..81bd0a381ca1 100644 --- a/drivers/mfd/cgbc-core.c +++ b/drivers/mfd/cgbc-core.c @@ -240,6 +240,7 @@ static 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 Fri Oct 2 06:18:28 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 A048846C854; Tue, 4 Aug 2026 14:56:30 +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=1785855392; cv=none; b=Mu1pi15Zxa32QVHYUzYXfYjaAKkJiULmMePEVfgFiggz17SkvmXJ8XMIdbxJ/8k+24YDu8gR82u+TEtQdQMZU9oNMsSSk0jQuvHQ+lwWX3v96gJgRyKOid2S4VBHRHsQ5KbUgjnRjOfv4Jz1BfZkmQapC8G5NVALBO/cYwMGFSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785855392; c=relaxed/simple; bh=H4oJJslLxt5OjocU4A+qH3WKHoxfVmuuo+ec3TiWAbw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ekf+c7iZFvga6U7XrPkBhGCfTdv4twvBMIFeTtsR5GrQqFBeV1NGpUfXMUnMNbA9/t/RPbgMv2u5+d6mhHCRYNzSlm6AHJjrWAudETVPi7bqAXkMxUhGZrlN9H+vSQZXDiZXxWlvE/8PV9Iz1v+nk9bzLjyvuQPTUab2IZarPkc= 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=15AN4IX2; 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="15AN4IX2" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 2D6F91A140A; Tue, 4 Aug 2026 14:56:29 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id F28916029E; Tue, 4 Aug 2026 14:56:28 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AF9E111C32F37; Tue, 4 Aug 2026 16:56:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1785855384; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=pgeyWE5OZKQl6M8USoJy7AhlzXJd3GEZj40nBZ0djFU=; b=15AN4IX2hkCILgxcYPjslfZ2p+BCNhmLPpYCyIszvqzUSEYLH4Aonw8nVt/NPLScjor5+n 93ebLtKeM6fJsIw9LRK5QMH7pQUtv+QPGyzxEiNaXxo974Ia+CIeiL9574XkPMIUWZ/5FC wvgZ9GiC01f0AurmiGAFCI4v2yR8tGzeQAd2wtpFoNdDcLgp4nu2SiZIk1VMERCMChxcKn XPCa2+HAN8mBi6TGni0LqwcnoEh4K3lpuf/eDPQnZZSZV73mzgkhwFETeQZlsPGG7XhlL1 l3XyLTZ9JppB6F7meIjOP1XDZSIi78d9wibEU8iNl4bE0qzBU6Z4/D0onnkNog== From: "Thomas Richard (congatec GmbH)" Date: Tue, 04 Aug 2026 16:55:54 +0200 Subject: [PATCH 4/4] 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: <20260804-cgbc-i2c-storage-devices-support-v1-4-fed38510671c@bootlin.com> References: <20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@bootlin.com> In-Reply-To: <20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@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..418de90e11bb 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-eprom"), + { } +}; + +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