From nobody Sat Jun 13 16:30:43 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 50F6343E490; Wed, 6 May 2026 12:28:32 +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=1778070513; cv=none; b=hLsgiVZokFxZDpfZwyh1LrLzsJFrELA6IXr/3lWxul5AbsPnVa+UQZRT1NHoj35SpUFg0y25dozSF+9Pk/YN7O8wXLwzewvFNEYoGXp9wx+r8yhf8lMQyep85lhvJS6BGPo1GbUUD+38N8viKTHDBvmC4EDiskVB1ByoJ9cBG68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778070513; c=relaxed/simple; bh=i28b5kPae1O6TJgN0WQ3X6zS29yFb9fnQDyZIJdT6z4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rhh2DgBkKsgt2eswnDNwdL6uhCJcIOrqrW+EtU1tCSQNOxqbKDy3zTbAshj1haaGqNsjPNVlYr2Czhx1uZHdRQiqFokYr4cQo3fN4q7uYFsnC79yDopxrvhXrZCU+HvV78D9h0WEPNgri6Qh4eD4cDci7Jv0pUHQ4mDPyA4pJeU= 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=Vg0lSLnD; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0xB8F7sC; 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="Vg0lSLnD"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0xB8F7sC" From: Gregor Herburger DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778070511; 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=Z7wPFQrFfOibwr4CB74CBepe/VCcRdrCCdHhqX/hkBQ=; b=Vg0lSLnDalfX899ful3UlIF1C9VwGRlOfqYjWmjJ0X/RSva3FVRKHZkK9N/jbaVjDPDgMH wtg2PD2xW+rdpW9lrLCFf2/P1R9RIgufwci5bZuBg/juUjf2m0SqRZiz8el7JfmeiMCmoU RB/km84VF6GYshyNlQ5LCewvZycF1EERQVgdXVEpKSUYQ5BzH+g+9sNkao//GWO7Nz3Tbo NzOhqmE+3OlZRcH0dml7OXnhUM38b+virM8Ztb3yXlg5c9uODskMRH8HTqCm3z6F24/MeV M9xVdDINQiK73iJuoVN/wz/y2j7d4+ZgoCl9P+WVHTB0rFkug8CnzqYDQxSJqw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778070511; 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=Z7wPFQrFfOibwr4CB74CBepe/VCcRdrCCdHhqX/hkBQ=; b=0xB8F7sC2iozuFJgRE7iV0an35nm5ZaESmF8JQwTUL+log07n0lDIJzAPKacSLsFYJCnKJ ifJ0LrF7txwPeTDA== Date: Wed, 06 May 2026 14:28:15 +0200 Subject: [PATCH v3 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: <20260506-rpi-otp-driver-v3-1-294602663695@linutronix.de> References: <20260506-rpi-otp-driver-v3-0-294602663695@linutronix.de> In-Reply-To: <20260506-rpi-otp-driver-v3-0-294602663695@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=1778070510; l=1154; i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; bh=i28b5kPae1O6TJgN0WQ3X6zS29yFb9fnQDyZIJdT6z4=; b=QQTunFcNSxejov3aYv+Hx9pRqK4bevXNHD2tSPUg9fCuSRmy/vw0JHrcmbGH0mzxOyp1K5aM+ AHFrDtCVOi+CuJFcxhVnYqlbMpX5dpgrURqOpol6IcRX900JRQS0nG3 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 --- .../bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml | 13 +++++++++= +--- 1 file changed, 10 insertions(+), 3 deletions(-) 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..fbcfa2bc168a 100644 --- a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmwar= e.yaml +++ b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmwar= e.yaml @@ -21,9 +21,16 @@ select: =20 properties: compatible: - items: - - const: raspberrypi,bcm2835-firmware - - const: simple-mfd + oneOf: + - items: + - enum: + - raspberrypi,bcm2712-firmware + - raspberrypi,bcm2835-firmware + - const: simple-mfd + - items: + - const: raspberrypi,bcm2712-firmware + - const: raspberrypi,bcm2835-firmware + - const: simple-mfd =20 mboxes: maxItems: 1 --=20 2.47.3 From nobody Sat Jun 13 16:30:43 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 A67C14418DC; Wed, 6 May 2026 12:28:32 +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=1778070514; cv=none; b=R+4hO97ZSTj7K1nQxJ8d1oclwM5SIR8y2Ta9j2hM3tJJ1VixV61rhaNb/O2m4Wu8eEGRYVikqx5UCSeSv0JMhb2apZqqmYSkY2AHCTf15R5hC7MhFmZ8VlbOp88HrdZ8g0RFPFNYOl8rQ44kYHLqEazd5BQl/uPS1h+UHhbYMRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778070514; c=relaxed/simple; bh=cenfUPJywg9h85EjYMVCg1WoTkkCC2Bv7lzs1zxucvQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TlXJRfFTRTCtlkYGcQoGogsAtmCLVoaGiL6sZAYCumYNUjRokCn3kRPe8KwInMuKRuoInwLjFmGgwG7jLpraI90IgZpAh82KMa8qnAas+H4mbo0pl3ONe7LMHIetDIEuHFiIZEPYR0pAIW1wy+kr/3bKaNWq8FcS72dk17YHLl4= 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=NXFVHssU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=LHzwGRUC; 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="NXFVHssU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LHzwGRUC" From: Gregor Herburger DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778070511; 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=Ky7eSHzdjtFzGmvU/FD0rTrYQ1cE+COYoYjGfDz2nrw=; b=NXFVHssUXauiFgatQm2MAAJmPBP2EM6xPO8vuC8Ev5Gzv0T0rz4hczSdu24RcQNIsN94Oe nNx6Xa+m7FXnlHI9vcqXtio0e8hg/W9hlNDSwk/VlVOcbq6hgDUUChYELlj4850vtX6UeM 8JnqRWeeAKmWNnFwkjRftWDRoMGeWWp+aBuUvzEHu9CyDQUAu1kvtC9Fj2ZIrXReUF95Hz UvXmJ/W3L0V9JM41Bla1z363qhzGI+kTR2tX3LyUXB+kySMuTS4qpO/54hp1XGcP2SyYbE rc4jWBkSMgCMa0R0uVO1vGMWNXpG7DjnaIK7Ls6b9+pKlavVvbS59JR6w+bnsQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778070511; 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=Ky7eSHzdjtFzGmvU/FD0rTrYQ1cE+COYoYjGfDz2nrw=; b=LHzwGRUC9x8wO/l8Y65+vnGXIB/pbwSPwmA2ee0joy5qKAt4GH8TQ3MxAzoCb0lKdIAc6I UCN7/c6GYn/JVjAw== Date: Wed, 06 May 2026 14:28:16 +0200 Subject: [PATCH v3 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: <20260506-rpi-otp-driver-v3-2-294602663695@linutronix.de> References: <20260506-rpi-otp-driver-v3-0-294602663695@linutronix.de> In-Reply-To: <20260506-rpi-otp-driver-v3-0-294602663695@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=1778070510; l=6034; i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; bh=cenfUPJywg9h85EjYMVCg1WoTkkCC2Bv7lzs1zxucvQ=; b=SJqpB9oy3Yg9WCLs9+ZTlML/p7RO4XG6sksAdT7go6jHCqZIAGEbSdxAut8WPXZwq416+MVbw jQYLAj245imAWU5TCYkZArMcvW0e6lPmEYG9fP9VfaRHH2F8TqUd4St 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 | 120 +++++++++++++++++++++++++= ++++ include/soc/bcm2835/raspberrypi-firmware.h | 9 +++ 4 files changed, 140 insertions(+) diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 74ddbd0f79b0..aac31f43385e 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 && !RASPBERRYPI_FIRMWARE) + 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..1edf2d5538d0 --- /dev/null +++ b/drivers/nvmem/raspberrypi-otp.c @@ -0,0 +1,120 @@ +// 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 { + __le32 start; + __le32 count; + __le32 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 cpu_to_le32(offset / 4); + fwbuf->count =3D cpu_to_le32(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 cpu_to_le32(offset / 4); + fwbuf->count =3D cpu_to_le32(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"); +MODULE_ALIAS("platform:raspberrypi-otp"); 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 Sat Jun 13 16:30:43 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 1689E4418CC; Wed, 6 May 2026 12:28:33 +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=1778070514; cv=none; b=AzNuMKdN/Iz91s+PXP2++Ey0XG7RWrw3hCoOKee9JF7z25yI5jhwUrsXUd1NmuZUS3HPe2zAwWd4MEaaXohO+6rHLTuB9bdfcPYMUvAZgl84hEyfAqmVyLFItfDGViZfIoW2gql/T6UL6LO+GpA28NWdX5JE4JLF2GS01ng/S1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778070514; c=relaxed/simple; bh=rr5QjJVjuZvNPD8Qs2aGQvMUMttlLqqHNodH4QGCTqA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aqxepvH8HKmsdGWGyFRcU2c4F8uR8TLmyXh9KcPujsepUbZBRqdvuH/x2kASsaGVglg1Nf4eONkGlgWTNeTljJ6EaAGEluhhdpaL+OW67DcgYx5+qs1FZ8tEByEZr7Qp/BeKd1jhR/47bc7brmSQW3UbWIvxOK4yotXCq9vL6Jk= 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=T/GmmfMq; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=54EXdJla; 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="T/GmmfMq"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="54EXdJla" From: Gregor Herburger DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778070511; 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=T/GmmfMqvlXpxIrLwipYiqFj0Ize2DF4uCbEoQA/mwyJT7TmR6osEkbXZrDutFXjmaqnK7 DBzz6O773UwCKv6rxOAJvCNYWE7mxeGrymCC1W0IOpVYqytONj/DD1v05F+tC7n6MKgk7I 1OXvF5B1Sm8eOkoHaHKjMGABcVvfotmHYNhWz1FKHWBDntD+WfT7NAhcYaZ1HpeUX2cM6q v0aUGK9op83HFowzIlB3LHGUAKtQJ8EgzHBGnTLi20A3cL32GoJ4RZ4KjLcorR5yJnPILR 6Wa2rrXKW2SXmqKbfNkK39qq9bg7Ntctaw+FKu0bc5Rc6occImeVwEW+316E4Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778070511; 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=54EXdJlam9wbpbi222sKhR89MWCCeuP7I5yuqYIoT2SlxJ0gzhoiAcyf+QFR0cBpAW26Bb TjKNWxN5JOD/AHAg== Date: Wed, 06 May 2026 14:28:17 +0200 Subject: [PATCH v3 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: <20260506-rpi-otp-driver-v3-3-294602663695@linutronix.de> References: <20260506-rpi-otp-driver-v3-0-294602663695@linutronix.de> In-Reply-To: <20260506-rpi-otp-driver-v3-0-294602663695@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=1778070510; l=4244; i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; bh=rr5QjJVjuZvNPD8Qs2aGQvMUMttlLqqHNodH4QGCTqA=; b=RrUabSwT7CvxOcnbB7X2EBuPyiqt/xUEbwRu7hZBO6HDRJBxta+lUe5OiAwb8OEh2Avm0gq7Q 5697mpFVuZaDOKJ9U+fWRtFG2H0DXJkf10bD8YQLJtWG5vXNQqopIs1 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 Sat Jun 13 16:30:43 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 78C0144A711; Wed, 6 May 2026 12:28:33 +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=1778070514; cv=none; b=jUwgIahd8EB5jXrCs2jGHeS4kC5rtInYNO31K4xzZUb3wbUPeFbojchaDJagiNo811nwNnXAL6Q0lCAqCmWt0JkGvWvSJ9QIbhnwvuYPCMECn4lKDixxOrVwzuAuMrmRPKIlvYEY+v53u5Q5TBCbjjxRzXqMxjS3VbrtprS4XKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778070514; c=relaxed/simple; bh=gyTIyYto7tzKXHDd6kMNK0OhSiLeThERn6mhwt9FF3w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GqaQffn3q/I1rgZ6w5zAB134jlvAewgvq5CJRJbiziCVnB9CVvl6QpHyyu6oG+VS50LTv+SZ7tSlfD/+uf/l8DzHXfz9mv08VPzIL0nK3axEJiw5f1yKRz7p0RQcsDOI1Ik3sVB4MF9iKYs4rq5LTt96E9bmRvgSGV2fiMwXLWU= 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=oMipbHDu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=01sC0nxb; 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="oMipbHDu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="01sC0nxb" From: Gregor Herburger DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778070512; 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=81MPp/cPmY31f4oil6TsY2E5xHh8dQK79p3Ch11N/PI=; b=oMipbHDuz7jHZ7kQlqsyTvIDCJv8dbs+leMtbnO16IqA16Ws4OQvZsEsAzXeSzxhBlo32G CkmHA9WEGvogE3hGl/Hr1nOIV+XX8kZ+bRWIVhYgFlZfjWW70yBZFcRrxEO9ET7FqSo9pr lrp4Qxhz/n9AMWdefFUGP6JsP3keuj29u44c/xQZp0cSiTdiz1vq0fpQOY1PPakyArKdYZ Y86cL9NE943ciwUhr+fFA0PqunFyaIJH+b2eJExryYqmwGHvNtmf70CLlpj1lNT2sqsO2f v1YcyIQbn47ynmog9bp0jL0sonEbEly9VWR/2ngIl/M0LxpWU5Da4Iq4S9+Tlw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778070512; 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=81MPp/cPmY31f4oil6TsY2E5xHh8dQK79p3Ch11N/PI=; b=01sC0nxbEWUe6WhuAm66nnDKOwfrWP4AHKaMcBhFojTMC5PbWyW3lEv4tH1bwOFI0wwcI8 6rkau1EvNd9Df+Dw== Date: Wed, 06 May 2026 14:28:18 +0200 Subject: [PATCH v3 4/4] arm64: dts: broadcom: bcm2712: add raspberrypi,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: <20260506-rpi-otp-driver-v3-4-294602663695@linutronix.de> References: <20260506-rpi-otp-driver-v3-0-294602663695@linutronix.de> In-Reply-To: <20260506-rpi-otp-driver-v3-0-294602663695@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=1778070510; l=1152; i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; bh=gyTIyYto7tzKXHDd6kMNK0OhSiLeThERn6mhwt9FF3w=; b=Gzlfl1GuLTZcLn96DVY3bF9xAHrAq8qFXqN+MIjMGwDgn0+hI2axTKfQnXJVDD8+HVDKR0kkI bHiurxQX9sCB/4dQd8B02vaCimYJbr9CrG1yw/dRnDRG73xAfiB0h7y X-Developer-Key: i=gregor.herburger@linutronix.de; a=ed25519; pk=u72Lv7+/lS5CC1hmSrb17lv/6CK7HBh4Lvz77PHA5LM= The Raspberry Pi 5 (BCM2712) firmware exposes additional features such as the additional OTP register region called 'private OTP'. Add the raspberrypi,bcm2712-firmware compatible to allow drivers to distinguish this hardware variant while keeping raspberrypi,bcm2835-firmware as a fallback for backward compatibility with existing drivers. Signed-off-by: Gregor Herburger --- arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-base.dtsi | 4 +++- 1 file changed, 3 insertions(+), 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..4aa8ec7601b8 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,9 @@ power_button: power-button { =20 firmware { firmware: rpi-firmware { - compatible =3D "raspberrypi,bcm2835-firmware", "simple-mfd"; + compatible =3D "raspberrypi,bcm2712-firmware", + "raspberrypi,bcm2835-firmware", + "simple-mfd"; =20 mboxes =3D <&mailbox>; =20 --=20 2.47.3