From nobody Sun Jun 14 00:16:56 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7FEE13BD643; Tue, 5 May 2026 07:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777965917; cv=none; b=oyydorTZYsbz95G4SjBTuoEAOCx0oKyV4AlIumhuwhNjeewulIllv/bLasa8ghfs6kiDslM30ob/U+nspBD/M3NgI+RLGZudjpqsV98DFwCIp9otnyfUhU9T5tpasGKQVblx19Xw6NdCuOE/A7i7wJSo7O9s4zmWNS8S0Ouwwd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777965917; c=relaxed/simple; bh=ku25ZC7Xfr1mnVIoO/JCu5TSYP52wMnTpzpP3xJcXKg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cNGIUax1imOmEd5jchHcfQJyTJXFTz0+l5dgl/Y2JQcd/PgLD1AXWR2wNXSOCEq0wmetstdvGVIsQlbKI/qChoDSAmpFdaL108hjmQo5TznSM6QL5y7ZPgPtm0NqI7z2RaZRWZRfPjqxSvUwUpBxzzsM4YydR4fM6wjaqm+6WeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=03wm87OJ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CXKZrWQK; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="03wm87OJ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CXKZrWQK" From: Gregor Herburger DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777965915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jhHEBcXQu0dSPfZI7PKo5xY8SurnMGXO53mDLy+S/5A=; b=03wm87OJLojRX3pP+36IGJDqB71ElhKLRiA2oKfsGC4ekfacsmtTfQbnZ8978VD+pZ3oYn Fbm9/7TNKK3c4rZ7COtM0ge6PiGweiA9F+icjQocMDpWOBrbUjXAkI9cfkpfbbQUPtxS47 zHqz2fgq8JQOFNh06CgHNYyWR81GeBhAucE53twElx2Y87P203OsDrQjRaY+1THU18thOb LVx3bV5FfX79tFVDHPtaj8zHDmUj9Nruo60a+x56k9V7lBMDPpalaBiNgvYH9F6KtQkM+A 8JD5ne7KwhHMApjDswX8CWYfMHPr3bZthclf+O+flprN1FeQFwjOMVKZpfXkNA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777965915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jhHEBcXQu0dSPfZI7PKo5xY8SurnMGXO53mDLy+S/5A=; b=CXKZrWQKrSMc4dIrCWKXlT1lQn+ZIzLnsFb+loGrqBB7t87J1PY6KWfggUlTNCBJ3NpG0I TRQQ88wke2L23DBw== Date: Tue, 05 May 2026 09:25:09 +0200 Subject: [PATCH v2 1/4] dt-bindings: raspberrypi,bcm2835-firmware: Add bcm2712-firmware compatible 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: <20260505-rpi-otp-driver-v2-1-e9176ec72837@linutronix.de> References: <20260505-rpi-otp-driver-v2-0-e9176ec72837@linutronix.de> In-Reply-To: <20260505-rpi-otp-driver-v2-0-e9176ec72837@linutronix.de> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Eric Anholt , Stefan Wahren , Srinivas Kandagatla , Kees Cook , "Gustavo A. R. Silva" Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Gregor Herburger X-Developer-Signature: v=1; a=ed25519-sha256; t=1777965913; l=903; i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; bh=ku25ZC7Xfr1mnVIoO/JCu5TSYP52wMnTpzpP3xJcXKg=; b=3MZiqMrb4EjsSOBa4aSVVciqxGDPpHH5NSiMS+fNLZ/Q9C0jn80z/Hn0vyPfw1pyXii8MSeE0 Ws1D+hrYLFBArIYRqRDaYeqCXBIk3h2IW28+7ZPC2LdCeXR0KMw75vG X-Developer-Key: i=gregor.herburger@linutronix.de; a=ed25519; pk=u72Lv7+/lS5CC1hmSrb17lv/6CK7HBh4Lvz77PHA5LM= Add a compatible string for the bcm2712 firmware. Signed-off-by: Gregor Herburger --- .../devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml | 4 = +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-= firmware.yaml b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm28= 35-firmware.yaml index 983ea80eaec9..eb6b556511d8 100644 --- a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmwar= e.yaml +++ b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmwar= e.yaml @@ -22,7 +22,9 @@ select: properties: compatible: items: - - const: raspberrypi,bcm2835-firmware + - enum: + - raspberrypi,bcm2712-firmware + - raspberrypi,bcm2835-firmware - const: simple-mfd =20 mboxes: --=20 2.47.3 From nobody Sun Jun 14 00:16:56 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D700F3DC4CB; Tue, 5 May 2026 07:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777965918; cv=none; b=gR+M1oT/96UcuiXHNq7jgGfGfdSd2T5GYTOjNE5Xusabm/5oUUb0EXzJHi8MOvMidMcBpB3uZbuqN8hWbFKCURTp8vuWynwxnnhvWBEt7xfKI/SB9RUjK47D9CB+bdQg9OzNQstvtFOPI3u7aFdcVDU52plpzytTyzLrCHI1QhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777965918; c=relaxed/simple; bh=a2ptnuNqX1aUnQDiinu8cyfWAbSy9akuDiv3x+rEw6s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qb+ivEZWWyu/EntypKuvsBtETFPllCSzUv7bgujzLFxj0SeFAoj0X0/1BgRwTQw9qQuQcIknxyLyH+2OpOFBtMfYnEEvFSbwE2r4J3Ku3zjt/q4mNgtTx4IXlxPxqqgXRWlFG6AbQlbn7K7IpB5qVgXtHKkknWgBZFrMolPTWmU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fvJoFP2Y; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ytI1+iJC; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fvJoFP2Y"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ytI1+iJC" From: Gregor Herburger DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777965915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=URyjBZx93D93GEfbZa0g9Emw0SDcKQggXo+MwOLy0Bk=; b=fvJoFP2YwU8OJjgfp2gUxm/AdI4vA58NqLxovOiocyVnw2hMAyWD4CwfdiL+pM3kin0tK0 MLllV2Z9PcU7SUKpewFFBHnUosVWCt3fUPforli8TJJP4gDA0i/UyIO/StAy7bB1k1zIFu qJz55xzVELnb4CsEux4aVFSUU5/Wg+pTntwucWy05rJDb7s0KQo/x7h9eYu4YzAQe0lgMN 57QKirOEF/pQL2WZUOuYCWXbRPnvDRQOEg2K0vLooNfDx6I07zw4Qob89NCm3A6kNEctRw ab3+0a43qRmx03VvFsSL+ya0N00k0xk8mfoAbzRIs+s8rbKknk6Abfx8bJFXZQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777965915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=URyjBZx93D93GEfbZa0g9Emw0SDcKQggXo+MwOLy0Bk=; b=ytI1+iJCv+/PDPNDLv6Ibs/ris3EBzu6MqJO1bGqk0SJlvmWcn39cTPuLkFFsU4F7I4Eje VbGGNyPC8yXCDRCQ== Date: Tue, 05 May 2026 09:25:10 +0200 Subject: [PATCH v2 2/4] nvmem: Add the Raspberry Pi OTP driver 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: <20260505-rpi-otp-driver-v2-2-e9176ec72837@linutronix.de> References: <20260505-rpi-otp-driver-v2-0-e9176ec72837@linutronix.de> In-Reply-To: <20260505-rpi-otp-driver-v2-0-e9176ec72837@linutronix.de> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Eric Anholt , Stefan Wahren , Srinivas Kandagatla , Kees Cook , "Gustavo A. R. Silva" Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Gregor Herburger X-Developer-Signature: v=1; a=ed25519-sha256; t=1777965913; l=5902; i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; bh=a2ptnuNqX1aUnQDiinu8cyfWAbSy9akuDiv3x+rEw6s=; b=nDkj09t59fRWI2S46hN+5ZHj1mMpqm3hU00GHlzzxxJp3fJ6aUQHhXuDKzpJvQGn1GP9VCOkM HA63pZVRZKHDEInBDEUySYSeYyvrIp/AJ2q3bdRtR9BZkxlm4KMqbfs X-Developer-Key: i=gregor.herburger@linutronix.de; a=ed25519; pk=u72Lv7+/lS5CC1hmSrb17lv/6CK7HBh4Lvz77PHA5LM= Raspberry Pis have OTP registers which can be accessed through the videocore firmware. Add a nvmem driver to support these OTP registers. Signed-off-by: Gregor Herburger --- drivers/nvmem/Kconfig | 10 +++ drivers/nvmem/Makefile | 1 + drivers/nvmem/raspberrypi-otp.c | 119 +++++++++++++++++++++++++= ++++ include/soc/bcm2835/raspberrypi-firmware.h | 9 +++ 4 files changed, 139 insertions(+) diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 74ddbd0f79b0..4ecfb0dfbe6b 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -483,4 +483,14 @@ config NVMEM_QORIQ_EFUSE This driver can also be built as a module. If so, the module will be called nvmem_qoriq_efuse. =20 +config NVMEM_RASPBERRYPI_OTP + tristate "Raspberry Pi OTP support" + depends on RASPBERRYPI_FIRMWARE || COMPILE_TEST + help + This driver provides access to the Raspberry Pi OTP memory via the + nvmem subsystem. The driver supports the customer OTP as well as the + device specific private key OTP (BCM2712 only). + + This driver can also be built as a module. If so, the module + will be called raspberrypi-otp. endif diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 7252b8ec88d4..8ca2095e068f 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -95,3 +95,4 @@ obj-$(CONFIG_NVMEM_ZYNQMP) +=3D nvmem_zynqmp_nvmem.o nvmem_zynqmp_nvmem-y :=3D zynqmp_nvmem.o obj-$(CONFIG_NVMEM_QORIQ_EFUSE) +=3D nvmem-qoriq-efuse.o nvmem-qoriq-efuse-y :=3D qoriq-efuse.o +obj-$(CONFIG_NVMEM_RASPBERRYPI_OTP) +=3D raspberrypi-otp.o diff --git a/drivers/nvmem/raspberrypi-otp.c b/drivers/nvmem/raspberrypi-ot= p.c new file mode 100644 index 000000000000..83624aa85bb3 --- /dev/null +++ b/drivers/nvmem/raspberrypi-otp.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include + +struct rpi_otp_priv { + struct rpi_firmware *fw; + struct device *dev; + u32 read_tag; + u32 write_tag; +}; + +struct rpi_otp_header { + u32 start; + u32 count; + u32 data[] __counted_by(count); +}; + +static int rpi_otp_read(void *context, unsigned int offset, void *buf, siz= e_t bytes) +{ + struct rpi_otp_priv *priv =3D context; + struct rpi_otp_header *fwbuf; + u32 count =3D bytes / 4; + int ret; + + fwbuf =3D kzalloc(struct_size(fwbuf, data, count), GFP_KERNEL); + if (!fwbuf) + return -ENOMEM; + + fwbuf->start =3D offset / 4; + fwbuf->count =3D count; + + ret =3D rpi_firmware_property(priv->fw, priv->read_tag, fwbuf, + sizeof(struct rpi_otp_header) + bytes); + if (ret) + goto out; + + memcpy(buf, fwbuf->data, bytes); + +out: + kfree(fwbuf); + return ret; +} + +static int rpi_otp_write(void *context, unsigned int offset, void *val, si= ze_t bytes) +{ + struct rpi_otp_priv *priv =3D context; + struct rpi_otp_header *fwbuf; + u32 count =3D bytes / 4; + int ret; + + fwbuf =3D kzalloc(struct_size(fwbuf, data, count), GFP_KERNEL); + if (!fwbuf) + return -ENOMEM; + + fwbuf->start =3D offset / 4; + fwbuf->count =3D count; + memcpy(fwbuf->data, val, bytes); + + ret =3D rpi_firmware_property(priv->fw, priv->write_tag, fwbuf, + sizeof(struct rpi_otp_header) + bytes); + + kfree(fwbuf); + return ret; +} + +static int rpi_otp_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct nvmem_device *nvmem; + struct rpi_otp_priv *priv; + const struct rpi_otp_driver_data *data; + struct nvmem_config config =3D { + .read_only =3D false, + .word_size =3D 4, + .stride =3D 4, + .reg_read =3D rpi_otp_read, + .reg_write =3D rpi_otp_write, + .id =3D NVMEM_DEVID_NONE, + }; + + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + data =3D dev_get_platdata(dev); + if (!data) + return -ENODEV; + + priv->fw =3D dev_get_drvdata(dev->parent); + priv->dev =3D dev; + priv->read_tag =3D data->read_tag; + priv->write_tag =3D data->write_tag; + config.dev =3D dev; + config.priv =3D priv; + config.name =3D data->name; + config.size =3D data->size; + + nvmem =3D devm_nvmem_register(dev, &config); + if (IS_ERR(nvmem)) + return dev_err_probe(dev, PTR_ERR(nvmem), "error registering nvmem confi= g\n"); + + return 0; +} + +static struct platform_driver raspberry_otp_driver =3D { + .probe =3D rpi_otp_probe, + .driver =3D { + .name =3D "raspberrypi-otp", + }, +}; +module_platform_driver(raspberry_otp_driver); + +MODULE_AUTHOR("Gregor Herburger "); +MODULE_DESCRIPTION("Raspberry Pi OTP driver"); +MODULE_LICENSE("GPL"); diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm28= 35/raspberrypi-firmware.h index e1f87fbfe554..ae73c9cd19ba 100644 --- a/include/soc/bcm2835/raspberrypi-firmware.h +++ b/include/soc/bcm2835/raspberrypi-firmware.h @@ -92,6 +92,8 @@ enum rpi_firmware_property_tag { RPI_FIRMWARE_SET_POE_HAT_VAL =3D 0x00030050, RPI_FIRMWARE_NOTIFY_XHCI_RESET =3D 0x00030058, RPI_FIRMWARE_NOTIFY_DISPLAY_DONE =3D 0x00030066, + RPI_FIRMWARE_GET_PRIVATE_OTP =3D 0x00030081, + RPI_FIRMWARE_SET_PRIVATE_OTP =3D 0x00038081, =20 /* Dispmanx TAGS */ RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE =3D 0x00040001, @@ -174,6 +176,13 @@ struct rpi_firmware_clk_rate_request { .id =3D cpu_to_le32(_id), \ } =20 +struct rpi_otp_driver_data { + const char *name; + u32 read_tag; + u32 write_tag; + int size; +}; + #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) int rpi_firmware_property(struct rpi_firmware *fw, u32 tag, void *data, size_t len); --=20 2.47.3 From nobody Sun Jun 14 00:16:56 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 5FB133DA5D1; Tue, 5 May 2026 07:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777965918; cv=none; b=Rpep2905ZJ2Ntw3U474YSt0UnzRollUneZVuLAEisy81FRmmHKU+jGS17M/1iVFfi1+dp6bwf7SOKyZUOnGVU9amtfsAB7267A8JO7bKVLgVSNB1N478bsLWW4emsiMmLM5fVueN1VTAzsZKbPzhJNQcPjRQrgXcPDnr4evQAjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777965918; c=relaxed/simple; bh=rr5QjJVjuZvNPD8Qs2aGQvMUMttlLqqHNodH4QGCTqA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qkZgYy1Y/elo/8BlnNd8K3rAsxsItkRtDK74WatrANMb+g4w4lSsVacTyHfQ/hlqiVm+dUA6vNAmPRfZSu2/FGGXl7Wa5YB4Jem60OgN2uRZUZWtN7nJTFyL86KKvC1GoPJ2zynNFPMv5IIZrOpjJto6iIbaPSxHDsbcsJ/vMpQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nJ5OBX3m; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=m+6N4OBh; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nJ5OBX3m"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="m+6N4OBh" From: Gregor Herburger DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777965915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gwcLabDXoFYL8fo3t2f3I5h6exflydXeBx0CmYLbbns=; b=nJ5OBX3mdJqV5ADW45He5uPmaKoGGZ8YQNyokay6eAT+02XYWCgnmCJ/5eMg/4fGRLB0nK up9zxcK5nBs2ymRAAEX6MNZ+xFFfpdKd8pBS8ghgd41s5iwVjXVoay60VN4IaDFl2Uv7LG hpRlVZ7AvjbkPgNNc/6EnRZJKxbhvzcP/0JH/7SI//6m1rPh0zCfmIqQuc7KUxLyhUg1kP BXmOAmv7qG/wSzMhG/+TcAY+3mwNQH7H+shIorcngx605rHVXV2mGZ/5clOWUAxHdu8CHp tMyTujrQ2RffXsU+YTe1DXpmaY9N2bW3kfY1dTVqgdCzfd7zevUDaKZg+A6nzg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777965915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gwcLabDXoFYL8fo3t2f3I5h6exflydXeBx0CmYLbbns=; b=m+6N4OBhWHQx3F8+0QfbE9yLktiemYXh/TISgu8pvUp9gowUoR7DEBEPPyV/RrcSp/D6CD 3sBpG1ifkKka+kBQ== Date: Tue, 05 May 2026 09:25:11 +0200 Subject: [PATCH v2 3/4] firmware: raspberrypi: register nvmem driver 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: <20260505-rpi-otp-driver-v2-3-e9176ec72837@linutronix.de> References: <20260505-rpi-otp-driver-v2-0-e9176ec72837@linutronix.de> In-Reply-To: <20260505-rpi-otp-driver-v2-0-e9176ec72837@linutronix.de> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Eric Anholt , Stefan Wahren , Srinivas Kandagatla , Kees Cook , "Gustavo A. R. Silva" Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Gregor Herburger X-Developer-Signature: v=1; a=ed25519-sha256; t=1777965913; l=4244; i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; bh=rr5QjJVjuZvNPD8Qs2aGQvMUMttlLqqHNodH4QGCTqA=; b=A38JlWf2GaZe2rFvlhQD4kViYcOZ+lmEDJMLjLRp0Zy9qhMXlyN97ZwX6sNM8YccGpOcX2TMI YNB/yvjZvjYBzz4Fz1XObSjQxhSO+WmiXpxtWFNhaaYjiIK4R0y3ELJ X-Developer-Key: i=gregor.herburger@linutronix.de; a=ed25519; pk=u72Lv7+/lS5CC1hmSrb17lv/6CK7HBh4Lvz77PHA5LM= The Raspberry Pi firmware exposes two regions with otp registers. The first region called "customer otp" is available on all Raspberry Pi models. The second is only available on the Raspberry Pi 5 (bcm2712). Signed-off-by: Gregor Herburger --- drivers/firmware/raspberrypi.c | 59 ++++++++++++++++++++++++++= +++- include/soc/bcm2835/raspberrypi-firmware.h | 5 +++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 0aa322e9a2e7..b363ec7bc5b4 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -24,12 +24,15 @@ =20 static struct platform_device *rpi_hwmon; static struct platform_device *rpi_clk; +static struct platform_device *rpi_otp_customer; +static struct platform_device *rpi_otp_private; =20 struct rpi_firmware { struct mbox_client cl; struct mbox_chan *chan; /* The property channel. */ struct completion c; u32 enabled; + enum rpi_firmware_soc soc; =20 struct kref consumers; }; @@ -231,6 +234,45 @@ static void rpi_register_clk_driver(struct device *dev) -1, NULL, 0); } =20 +static const struct rpi_otp_driver_data rpi_otp_customer_data =3D { + .name =3D "rpi-otp-customer", + .read_tag =3D RPI_FIRMWARE_GET_CUSTOMER_OTP, + .write_tag =3D RPI_FIRMWARE_SET_CUSTOMER_OTP, + .size =3D 32, +}; + +static const struct rpi_otp_driver_data rpi_otp_private_data =3D { + .name =3D "rpi-otp-private", + .read_tag =3D RPI_FIRMWARE_GET_PRIVATE_OTP, + .write_tag =3D RPI_FIRMWARE_SET_PRIVATE_OTP, + .size =3D 32, +}; + +static void rpi_register_otp_driver(struct device *dev) +{ + struct rpi_firmware *fw =3D dev_get_drvdata(dev); + + rpi_otp_customer =3D platform_device_register_data(dev, "raspberrypi-otp", + PLATFORM_DEVID_AUTO, + &rpi_otp_customer_data, + sizeof(rpi_otp_customer_data)); + + if (IS_ERR(rpi_otp_customer)) + dev_err(dev, "Failed to register customer OTP device: %ld\n", + PTR_ERR(rpi_otp_customer)); + + if (fw->soc =3D=3D RPI_FIRMWARE_SOC_BCM2712) { + rpi_otp_private =3D platform_device_register_data(dev, "raspberrypi-otp", + PLATFORM_DEVID_AUTO, + &rpi_otp_private_data, + sizeof(rpi_otp_private_data)); + + if (IS_ERR(rpi_otp_private)) + dev_err(dev, "Failed to register private OTP device: %ld\n", + PTR_ERR(rpi_otp_private)); + } +} + unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, unsign= ed int id) { struct rpi_firmware_clk_rate_request msg =3D @@ -299,12 +341,14 @@ static int rpi_firmware_probe(struct platform_device = *pdev) =20 init_completion(&fw->c); kref_init(&fw->consumers); + fw->soc =3D (uintptr_t)device_get_match_data(dev); =20 platform_set_drvdata(pdev, fw); =20 rpi_firmware_print_firmware_revision(fw); rpi_register_hwmon_driver(dev, fw); rpi_register_clk_driver(dev); + rpi_register_otp_driver(dev); =20 return 0; } @@ -327,12 +371,25 @@ static void rpi_firmware_remove(struct platform_devic= e *pdev) rpi_hwmon =3D NULL; platform_device_unregister(rpi_clk); rpi_clk =3D NULL; + platform_device_unregister(rpi_otp_customer); + rpi_otp_customer =3D NULL; + if (rpi_otp_private) + platform_device_unregister(rpi_otp_private); + + rpi_otp_private =3D NULL; =20 rpi_firmware_put(fw); } =20 static const struct of_device_id rpi_firmware_of_match[] =3D { - { .compatible =3D "raspberrypi,bcm2835-firmware", }, + { + .compatible =3D "raspberrypi,bcm2835-firmware", + .data =3D (void *)RPI_FIRMWARE_SOC_BCM2835, + }, + { + .compatible =3D "raspberrypi,bcm2712-firmware", + .data =3D (void *)RPI_FIRMWARE_SOC_BCM2712, + }, {}, }; MODULE_DEVICE_TABLE(of, rpi_firmware_of_match); diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm28= 35/raspberrypi-firmware.h index ae73c9cd19ba..17595a96e90b 100644 --- a/include/soc/bcm2835/raspberrypi-firmware.h +++ b/include/soc/bcm2835/raspberrypi-firmware.h @@ -9,6 +9,11 @@ #include #include =20 +enum rpi_firmware_soc { + RPI_FIRMWARE_SOC_BCM2835, + RPI_FIRMWARE_SOC_BCM2712, +}; + struct rpi_firmware; =20 enum rpi_firmware_property_status { --=20 2.47.3 From nobody Sun Jun 14 00:16:56 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A41CE3DD505; Tue, 5 May 2026 07:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777965918; cv=none; b=LwqkgON+rhNPrf7WprmyO4yWSqd4vx9+AQzbk5XXhw4C7YOg7VGgVcGps/9Y0f+rViKdGSotgcIymp+3Gf1bCDRHU+lEB7ldau1kdiXaUgAXXvlAfdNWrAioHOTRwekeJThIo8jPpBud1wr6FOaF7xpDi6jbTKj+4gB8B9dt2uE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777965918; c=relaxed/simple; bh=J8uzf0UxBnakhr29755Qqmk8YumZt3G68S6svRZD3q0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BBk03onMFspocs/hLJbAiAMxG6wEtpTzHJiC37AbZA2/4Dgd3dClPM81Tm9PoYh5/fi1AzqhyhfgGxi+Fu0H3Se7hyZdive5+ePXeo0rpifMj4VRB4CQAt4DfSHMffBw5mj+nMvV1LugpMBVS0xd1L7quy4WNDbd3Xq1g0orYJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zSDE4QF7; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SykxpLQ7; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zSDE4QF7"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SykxpLQ7" From: Gregor Herburger DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777965916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6AcipymrztotqziX7C3pSX0j0j5jMczP0kYAPjLO05o=; b=zSDE4QF7sfIkPaBRDfkGp8V87GlkHgZCZEZpncKPWiXlyVJPc5iklFJxyoC16BgEbt/kkX 2/S43Lno3CWobTMm3YJwKXW0do/UTnI4sI+dRCvaDRe3K82RF7EIjMQmhrdPOUaDXbOedG UFB50O+qx+OL83+cJI2dUvkRo/LuXY5cEN8I0MhiGKbZVaWiOwsgeU9RdmbzPuTzpYnSbO PC55BDqgVFBuKki8owbX/M7adA7mAyj7BJq5hwOTp09mwT2/Jg4S8CGQ9CCOyL2XLGL4e1 7ZyaoJsVxcEzikkoeiq9Iiqa36tFqLiWvkVz8pK5J4vRJaNwFN2sI0CP26B6Yg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777965916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6AcipymrztotqziX7C3pSX0j0j5jMczP0kYAPjLO05o=; b=SykxpLQ7b67XIrm/zjHnicmSoWLEZpc+pH2lErTk3DlUN8HiW2GK2rFgka4rlSv8UFle6m mxef/cehlM3+caAA== Date: Tue, 05 May 2026 09:25:12 +0200 Subject: [PATCH v2 4/4] arm64: dts: broadcom: bcm2712: add bcm2712-firmware compatible 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: <20260505-rpi-otp-driver-v2-4-e9176ec72837@linutronix.de> References: <20260505-rpi-otp-driver-v2-0-e9176ec72837@linutronix.de> In-Reply-To: <20260505-rpi-otp-driver-v2-0-e9176ec72837@linutronix.de> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Eric Anholt , Stefan Wahren , Srinivas Kandagatla , Kees Cook , "Gustavo A. R. Silva" Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Gregor Herburger X-Developer-Signature: v=1; a=ed25519-sha256; t=1777965913; l=858; i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; bh=J8uzf0UxBnakhr29755Qqmk8YumZt3G68S6svRZD3q0=; b=OaBrTyYswxhcwx6rx7uAFSQ3p80HfRcgtEUXXpD9an/IpdfKr+T5LotzbdIHIz2qHTmbVAFjY 5qGpMDkMCn0Bh0Q0lFezPrJ+ubSvh+FiQ+sKayJpFI87xPSOh5d4kZ7 X-Developer-Key: i=gregor.herburger@linutronix.de; a=ed25519; pk=u72Lv7+/lS5CC1hmSrb17lv/6CK7HBh4Lvz77PHA5LM= The Raspberry Pi 5 firmware exposes additional features. Update the compatible to reflect these differences. Signed-off-by: Gregor Herburger --- arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-base.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-base.dtsi b/arch/= arm64/boot/dts/broadcom/bcm2712-rpi-5-b-base.dtsi index b7a6bc34ae1a..7283078fd441 100644 --- a/arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-base.dtsi +++ b/arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-base.dtsi @@ -46,7 +46,7 @@ power_button: power-button { =20 firmware { firmware: rpi-firmware { - compatible =3D "raspberrypi,bcm2835-firmware", "simple-mfd"; + compatible =3D "raspberrypi,bcm2712-firmware", "simple-mfd"; =20 mboxes =3D <&mailbox>; =20 --=20 2.47.3