Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvmem: stm32: add support for STM32MP25 BSEC to control OTP data

On STM32MP25, OTP area may be read/written by using BSEC (boot, security
and OTP control). The BSEC internal peripheral is only managed by the
secure world.

The 12 Kbits of OTP (effective) are organized into the following regions:
- lower OTP (OTP0 to OTP127) = 4096 lower OTP bits,
bitwise (1-bit) programmable
- mid OTP (OTP128 to OTP255) = 4096 middle OTP bits,
bulk (32-bit) programmable
- upper OTP (OTP256 to OTP383) = 4096 upper OTP bits,
bulk (32-bit) programmable,
only accessible when BSEC is in closed state.

As HWKEY and ECIES key are only accessible by ROM code;
only 368 OTP words are managed in this driver (OTP0 to OTP267).

This patch adds the STM32MP25 configuration for reading and writing
the OTP data using the OP-TEE BSEC TA services.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231215111536.316972-11-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Patrick Delaunay and committed by
Greg Kroah-Hartman
f0ac5b23 a729c0f5

+16
+16
drivers/nvmem/stm32-romem.c
··· 269 269 .ta = true, 270 270 }; 271 271 272 + /* 273 + * STM32MP25 BSEC OTP: 3 regions of 32-bits data words 274 + * lower OTP (OTP0 to OTP127), bitwise (1-bit) programmable 275 + * mid OTP (OTP128 to OTP255), bulk (32-bit) programmable 276 + * upper OTP (OTP256 to OTP383), bulk (32-bit) programmable 277 + * but no access to HWKEY and ECIES key: limited at OTP367 278 + */ 279 + static const struct stm32_romem_cfg stm32mp25_bsec_cfg = { 280 + .size = 368 * 4, 281 + .lower = 127, 282 + .ta = true, 283 + }; 284 + 272 285 static const struct of_device_id stm32_romem_of_match[] __maybe_unused = { 273 286 { .compatible = "st,stm32f4-otp", }, { 274 287 .compatible = "st,stm32mp15-bsec", ··· 289 276 }, { 290 277 .compatible = "st,stm32mp13-bsec", 291 278 .data = (void *)&stm32mp13_bsec_cfg, 279 + }, { 280 + .compatible = "st,stm32mp25-bsec", 281 + .data = (void *)&stm32mp25_bsec_cfg, 292 282 }, 293 283 { /* sentinel */ }, 294 284 };