819-v6.8-0007-nvmem-stm32-add-support-for-STM32MP25-BSEC-to-contro.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From f0ac5b23039610619ca4a4805528553ecb6bc815 Mon Sep 17 00:00:00 2001
  2. From: Patrick Delaunay <[email protected]>
  3. Date: Fri, 15 Dec 2023 11:15:36 +0000
  4. Subject: [PATCH] nvmem: stm32: add support for STM32MP25 BSEC to control OTP
  5. data
  6. On STM32MP25, OTP area may be read/written by using BSEC (boot, security
  7. and OTP control). The BSEC internal peripheral is only managed by the
  8. secure world.
  9. The 12 Kbits of OTP (effective) are organized into the following regions:
  10. - lower OTP (OTP0 to OTP127) = 4096 lower OTP bits,
  11. bitwise (1-bit) programmable
  12. - mid OTP (OTP128 to OTP255) = 4096 middle OTP bits,
  13. bulk (32-bit) programmable
  14. - upper OTP (OTP256 to OTP383) = 4096 upper OTP bits,
  15. bulk (32-bit) programmable,
  16. only accessible when BSEC is in closed state.
  17. As HWKEY and ECIES key are only accessible by ROM code;
  18. only 368 OTP words are managed in this driver (OTP0 to OTP267).
  19. This patch adds the STM32MP25 configuration for reading and writing
  20. the OTP data using the OP-TEE BSEC TA services.
  21. Signed-off-by: Patrick Delaunay <[email protected]>
  22. Signed-off-by: Srinivas Kandagatla <[email protected]>
  23. Link: https://lore.kernel.org/r/[email protected]
  24. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  25. ---
  26. drivers/nvmem/stm32-romem.c | 16 ++++++++++++++++
  27. 1 file changed, 16 insertions(+)
  28. --- a/drivers/nvmem/stm32-romem.c
  29. +++ b/drivers/nvmem/stm32-romem.c
  30. @@ -269,6 +269,19 @@ static const struct stm32_romem_cfg stm3
  31. .ta = true,
  32. };
  33. +/*
  34. + * STM32MP25 BSEC OTP: 3 regions of 32-bits data words
  35. + * lower OTP (OTP0 to OTP127), bitwise (1-bit) programmable
  36. + * mid OTP (OTP128 to OTP255), bulk (32-bit) programmable
  37. + * upper OTP (OTP256 to OTP383), bulk (32-bit) programmable
  38. + * but no access to HWKEY and ECIES key: limited at OTP367
  39. + */
  40. +static const struct stm32_romem_cfg stm32mp25_bsec_cfg = {
  41. + .size = 368 * 4,
  42. + .lower = 127,
  43. + .ta = true,
  44. +};
  45. +
  46. static const struct of_device_id stm32_romem_of_match[] __maybe_unused = {
  47. { .compatible = "st,stm32f4-otp", }, {
  48. .compatible = "st,stm32mp15-bsec",
  49. @@ -276,6 +289,9 @@ static const struct of_device_id stm32_r
  50. }, {
  51. .compatible = "st,stm32mp13-bsec",
  52. .data = (void *)&stm32mp13_bsec_cfg,
  53. + }, {
  54. + .compatible = "st,stm32mp25-bsec",
  55. + .data = (void *)&stm32mp25_bsec_cfg,
  56. },
  57. { /* sentinel */ },
  58. };