812-v6.2-0001-nvmem-stm32-move-STM32MP15_BSEC_NUM_LOWER-in-config.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. From fbfc4ca465a1f8d81bf2d67d95bf7fc67c3cf0c2 Mon Sep 17 00:00:00 2001
  2. From: Patrick Delaunay <[email protected]>
  3. Date: Fri, 18 Nov 2022 06:39:20 +0000
  4. Subject: [PATCH] nvmem: stm32: move STM32MP15_BSEC_NUM_LOWER in config
  5. Support STM32MP15_BSEC_NUM_LOWER in stm32 romem config to prepare
  6. the next SoC in STM32MP family.
  7. Signed-off-by: Patrick Delaunay <[email protected]>
  8. Signed-off-by: Srinivas Kandagatla <[email protected]>
  9. Link: https://lore.kernel.org/r/[email protected]
  10. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  11. ---
  12. drivers/nvmem/stm32-romem.c | 21 ++++++++++++++++-----
  13. 1 file changed, 16 insertions(+), 5 deletions(-)
  14. --- a/drivers/nvmem/stm32-romem.c
  15. +++ b/drivers/nvmem/stm32-romem.c
  16. @@ -22,16 +22,15 @@
  17. /* shadow registers offest */
  18. #define STM32MP15_BSEC_DATA0 0x200
  19. -/* 32 (x 32-bits) lower shadow registers */
  20. -#define STM32MP15_BSEC_NUM_LOWER 32
  21. -
  22. struct stm32_romem_cfg {
  23. int size;
  24. + u8 lower;
  25. };
  26. struct stm32_romem_priv {
  27. void __iomem *base;
  28. struct nvmem_config cfg;
  29. + u8 lower;
  30. };
  31. static int stm32_romem_read(void *context, unsigned int offset, void *buf,
  32. @@ -85,7 +84,7 @@ static int stm32_bsec_read(void *context
  33. for (i = roffset; (i < roffset + rbytes); i += 4) {
  34. u32 otp = i >> 2;
  35. - if (otp < STM32MP15_BSEC_NUM_LOWER) {
  36. + if (otp < priv->lower) {
  37. /* read lower data from shadow registers */
  38. val = readl_relaxed(
  39. priv->base + STM32MP15_BSEC_DATA0 + i);
  40. @@ -159,6 +158,8 @@ static int stm32_romem_probe(struct plat
  41. priv->cfg.priv = priv;
  42. priv->cfg.owner = THIS_MODULE;
  43. + priv->lower = 0;
  44. +
  45. cfg = (const struct stm32_romem_cfg *)
  46. of_match_device(dev->driver->of_match_table, dev)->data;
  47. if (!cfg) {
  48. @@ -167,6 +168,7 @@ static int stm32_romem_probe(struct plat
  49. priv->cfg.reg_read = stm32_romem_read;
  50. } else {
  51. priv->cfg.size = cfg->size;
  52. + priv->lower = cfg->lower;
  53. priv->cfg.reg_read = stm32_bsec_read;
  54. priv->cfg.reg_write = stm32_bsec_write;
  55. }
  56. @@ -174,8 +176,17 @@ static int stm32_romem_probe(struct plat
  57. return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &priv->cfg));
  58. }
  59. +/*
  60. + * STM32MP15 BSEC OTP regions: 4096 OTP bits (with 3072 effective bits)
  61. + * => 96 x 32-bits data words
  62. + * - Lower: 1K bits, 2:1 redundancy, incremental bit programming
  63. + * => 32 (x 32-bits) lower shadow registers = words 0 to 31
  64. + * - Upper: 2K bits, ECC protection, word programming only
  65. + * => 64 (x 32-bits) = words 32 to 95
  66. + */
  67. static const struct stm32_romem_cfg stm32mp15_bsec_cfg = {
  68. - .size = 384, /* 96 x 32-bits data words */
  69. + .size = 384,
  70. + .lower = 32,
  71. };
  72. static const struct of_device_id stm32_romem_of_match[] = {