nvmem: aspeed: Add read-only AST2600 OTP support
Subsystems (3)
v3 cover nvmem: aspeed: Add read-only AST2600 OTP support
Hi,
Add an NVMEM binding and read-only access to permitted AST2600 OTP words for userspace BMC bring-up diagnostics.
AST2600 accesses OTP through shared command and result registers, so reads must be serialized. Earlier firmware may leave the macro in programming mode, requiring read-mode initialization. The protected prefix can grow during operation, requiring live protection checks. A timeout leaves command completion uncertain, so further commands are blocked because no safe retry sequence is documented.
Supplementary design notes:
https://github.com/prasanthp20/asrock-b650d4u-bmc-support/blob/main/docs/security/ast2600-otp-nvmem-design.md
Changes since v2:
- Explain hardware constraints; put test results below the commit separator.
- Use generic ASPEED naming and named mode-register addresses.
- Share unlock/relock helpers without mixing scoped locking and goto.
- Return EIO for unlock failure; simplify pair copying and registration.
- Drop redundant MAINTAINERS matching, zero assignments and probe readback.
Changes since v1 (introduced in v2):
- Add the separate SBC/NVMEM binding patch; rename the source and module.
- Replace double polling with one bounded poll after an initial 1-us delay.
- Initialize read mode and read CONF0 once at probe; use a fixed keepout.
- Check the live SEC54 range on each hardware read in confirmed 128-byte units.
- Simplify word copying with unaligned-safe LE stores; accept empty reads.
- Adopt scoped mutex locking and managed initialization; simplify Kconfig.
Tested on B650D4U (AST2600 A3) with upstream-based Linux 7.4-rc1:
repeated reads, cross-pair/final-pair comparisons, 40 concurrent reads and a 12-byte ASPEED-derived reference comparison passed. The RAM boot used the working OpenBMC DTB and initramfs. The ARM kernel build used W=1.
The selected dt_binding_check target passed using dtschema 2026.4 with a local diagnostic-crash fix; no checks were disabled. Two unrelated TI type diagnostics remain, with no SBC errors. Host-model range, copying and timeout checks also passed.
AI assistance was used for driver revisions, validation tooling and patch text, based on the downstream driver, review comments and Neal's guidance. Hardware tests were run by the submitter.
Previous revision (v2 cover letter):
https://lore.kernel.org/all/[email protected]/
Patch and review history:
v1 1/1 - original OTP driver and review:
https://patchwork.ozlabs.org/project/linux-aspeed/patch/[email protected]/
v2 1/2 - SBC/NVMEM binding:
https://patchwork.ozlabs.org/project/linux-aspeed/patch/[email protected]/
v2 2/2 - revised OTP driver and review:
https://patchwork.ozlabs.org/project/linux-aspeed/patch/[email protected]/
ASPEED hardware clarification - Neal Liu:
https://lore.kernel.org/linux-aspeed/KL1PR0601MB3986A356BD06F98D0FF9AD5E80792@KL1PR0601MB3986.apcprd06.prod.outlook.com/
Prasanth Kumar Padarthi (2):
dt-bindings: arm: aspeed: sbc: Describe OTP NVMEM provider
nvmem: aspeed: Add read-only AST2600 OTP support
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
PATCH v3 1/2 dt-bindings: arm: aspeed: sbc: Describe OTP NVMEM provider
The AST2600 secure boot controller also provides access to its OTP data region. Reference the NVMEM provider schema and use unevaluatedProperties so common NVMEM properties are accepted while unknown properties remain rejected. Cell offsets address OTP data rather than controller registers.
---
Validation: dt-doc-validate and the selected dt_binding_check target passed. The binding target used dtschema 2026.4 with a local diagnostic lookup fix for trailing # in schema IDs. No validation rules were disabled. Two unrelated TI type diagnostics remain; no SBC diagnostics were emitted. The valid example passed, and an unknown-property negative control failed as expected.
.../devicetree/bindings/arm/aspeed/aspeed,sbc.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/arm/aspeed/aspeed,sbc.yaml +8 -2
@@ -13,7 +13,12 @@ maintainers: description: | The ASPEED SoCs have a register bank for interacting with the secure boot - controller. + controller. The controller also provides access to the OTP data region + through NVMEM. NVMEM cell offsets are byte offsets within the OTP data + region, not offsets within the controller register bank. + +allOf: + - $ref: /schemas/nvmem/nvmem.yaml# properties: compatible:
@@ -27,11 +32,12 @@ required: - compatible - reg -additionalProperties: false +unevaluatedProperties: false examples: - | sbc: secure-boot-controller@1e6f2000 { compatible = "aspeed,ast2600-sbc"; reg = <0x1e6f2000 0x1000>; + read-only; };
Signature · 1 line
2.47.3
PATCH v3 2/2 nvmem: aspeed: Add read-only AST2600 OTP support
In reply to Prasanth Kumar PadarthiAST2600's secure boot controller provides an 8-KiB OTP data region through paired-word commands rather than memory-mapped storage. Expose permitted words through NVMEM for privileged userspace bring-up diagnostics, which compare raw OTP offsets with reference reads; no named cells are required by this consumer.
Earlier firmware may leave the OTP macro in programming mode, so Linux must establish read mode before using it. Programming protection does not prevent reads, but the configured secure prefix and SEC54 restrict the readable region. SEC54 can increase until ARM reset, so a probe-time snapshot alone cannot describe every later read restriction.
SEC00 relocking does not cancel a running command. Since there is no documented safe retry after a timeout, stop issuing commands rather than risk overlapping an outstanding operation. Normal reads take less than 1 us; the 100-ms bound is deliberately generous, not a specified maximum.
The read sequence is adapted from ASPEED's downstream driver.
---
Tested on ASRock Rack B650D4U (AST2600 A3), Linux 7.4-rc1:
- ARM zImage build with W=1 completed.
- Repeated 12-byte reads and cross-pair/final-pair comparisons passed.
- Four concurrent readers completed 40 matching reads.
- Bytes 8172..8183 matched the saved ASPEED-derived reference fingerprint. The kernel was RAM-booted with the working OpenBMC DTB and initramfs.
Host-model checks passed 4096 protection combinations, 200 copying cases and 24 timeout cases, including unlock-failure cleanup. Strict source checkpatch passed. The existing ASPEED MAINTAINERS matcher covers the file.
drivers/nvmem/Kconfig | 13 ++ drivers/nvmem/Makefile | 1 + drivers/nvmem/nvmem-aspeed-otp.c | 299 +++++++++++++++++++++++++++++++ 3 files changed, 313 insertions(+) create mode 100644 drivers/nvmem/nvmem-aspeed-otp.c
drivers/nvmem/Kconfig +13 -0
@@ -164,6 +164,19 @@ config NVMEM_APPLE_SPMI This driver can also be built as a module. If so, the module will be called apple-nvmem-spmi. +config NVMEM_ASPEED_OTP + tristate "ASPEED OTP support" + depends on ARCH_ASPEED || COMPILE_TEST + depends on HAS_IOMEM + help + Say Y here to enable read-only access to the OTP data region + on ASPEED AST2600 BMCs through the NVMEM interface. + + This driver can also be built as a module. If so, the module + will be called nvmem-aspeed-otp. + + If unsure, say N. + config NVMEM_BCM_OCOTP tristate "Broadcom On-Chip OTP Controller support" depends on ARCH_BCM_IPROC || COMPILE_TEST
drivers/nvmem/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_NVMEM_APPLE_EFUSES) += nvmem-apple-efuses.o nvmem-apple-efuses-y := apple-efuses.o obj-$(CONFIG_NVMEM_APPLE_SPMI) += apple_nvmem_spmi.o apple_nvmem_spmi-y := apple-spmi-nvmem.o +obj-$(CONFIG_NVMEM_ASPEED_OTP) += nvmem-aspeed-otp.o obj-$(CONFIG_NVMEM_BCM_OCOTP) += nvmem-bcm-ocotp.o nvmem-bcm-ocotp-y := bcm-ocotp.o obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o
drivers/nvmem/nvmem-aspeed-otp.c new file +299 -0
299 lines not on this page · raw message
Signature · 1 line
2.47.3
Hello,
drivers/nvmem/nvmem-aspeed-otp.c line 17
Quoted 10 lines · Prasanth Kumar Padarthi
drivers/nvmem/nvmem-aspeed-otp.c new file +10
-0+#include <linux/bitfield.h> +#include <linux/cleanup.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/nvmem-provider.h> +#include <linux/platform_device.h> +#include <linux/unaligned.h>
<linux/platform_device.h> already provides of_device_id without all the dependencies that are implied by using <linux/mod_devicetable.h>. So please drop the latter.
Best regards
Uwe
Thanks, Uwe. I’ll drop the linux/mod_devicetable.h include in the next revision.
Quoted 21 lines · Uwe Kleine-König,
Hello,
drivers/nvmem/nvmem-aspeed-otp.c line 17
Quoted 10 lines · Prasanth Kumar Padarthi
drivers/nvmem/nvmem-aspeed-otp.c new file +10
-0+#include <linux/bitfield.h> +#include <linux/cleanup.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/nvmem-provider.h> +#include <linux/platform_device.h> +#include <linux/unaligned.h> <
linux/platform_device.h> already providesof_device_idwithout all the dependencies that are implied by using <linux/mod_devicetable.h>. So please drop the latter.Best regards
Uwe
Thanks, Uwe. I’ll drop the linux/mod_devicetable.h include in the next revision.
Quoted 21 lines · Uwe Kleine-König
Hello,
drivers/nvmem/nvmem-aspeed-otp.c line 17
Quoted 10 lines · Prasanth Kumar Padarthi
drivers/nvmem/nvmem-aspeed-otp.c new file +10
-0+#include <linux/bitfield.h> +#include <linux/cleanup.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/nvmem-provider.h> +#include <linux/platform_device.h> +#include <linux/unaligned.h> <
linux/platform_device.h> already providesof_device_idwithout all the dependencies that are implied by using <linux/mod_devicetable.h>. So please drop the latter.Best regards
Uwe