ocram.S 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2021 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <soc_default_base_addr.h>
  8. #include <soc_default_helper_macros.h>
  9. .global ocram_init
  10. /*
  11. * void ocram_init(uintptr_t start_addr, size_t size)
  12. *
  13. * This function will do OCRAM ECC.
  14. * OCRAM is initialized with 64-bit writes and then a write
  15. * performed to address 0x0010_0534 with the value 0x0000_0008.
  16. *
  17. * x0: start_addr
  18. * x1: size in bytes
  19. * Called from C
  20. */
  21. func ocram_init
  22. /* save the aarch32/64 non-volatile registers */
  23. stp x4, x5, [sp, #-16]!
  24. stp x6, x7, [sp, #-16]!
  25. stp x8, x9, [sp, #-16]!
  26. stp x10, x11, [sp, #-16]!
  27. stp x12, x13, [sp, #-16]!
  28. stp x18, x30, [sp, #-16]!
  29. /* convert bytes to 64-byte chunks */
  30. lsr x1, x1, #6
  31. 1:
  32. /* for each location, read and write-back */
  33. dc ivac, x0
  34. dsb sy
  35. ldp x4, x5, [x0]
  36. ldp x6, x7, [x0, #16]
  37. ldp x8, x9, [x0, #32]
  38. ldp x10, x11, [x0, #48]
  39. stp x4, x5, [x0]
  40. stp x6, x7, [x0, #16]
  41. stp x8, x9, [x0, #32]
  42. stp x10, x11, [x0, #48]
  43. dc cvac, x0
  44. sub x1, x1, #1
  45. cbz x1, 2f
  46. add x0, x0, #64
  47. b 1b
  48. 2:
  49. /* Clear OCRAM ECC status bit in SBEESR2 and MBEESR2 */
  50. ldr w1, =OCRAM_EESR_MASK
  51. ldr x0, =DCFG_SBEESR2_ADDR
  52. str w1, [x0]
  53. ldr x0, =DCFG_MBEESR2_ADDR
  54. str w1, [x0]
  55. /* restore the aarch32/64 non-volatile registers */
  56. ldp x18, x30, [sp], #16
  57. ldp x12, x13, [sp], #16
  58. ldp x10, x11, [sp], #16
  59. ldp x8, x9, [sp], #16
  60. ldp x6, x7, [sp], #16
  61. ldp x4, x5, [sp], #16
  62. ret
  63. endfunc ocram_init