lowlevel_init.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2012-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <config.h>
  7. #include <linux/linkage.h>
  8. #include <linux/sizes.h>
  9. #include <asm/system.h>
  10. #include <mach/arm-mpcore.h>
  11. #include <mach/sbc-regs.h>
  12. #include <mach/ssc-regs.h>
  13. ENTRY(lowlevel_init)
  14. mov r8, lr @ persevere link reg across call
  15. /*
  16. * The UniPhier Boot ROM loads SPL code to the L2 cache.
  17. * But CPUs can only do instruction fetch now because start.S has
  18. * cleared C and M bits.
  19. * First we need to turn on MMU and Dcache again to get back
  20. * data access to L2.
  21. */
  22. mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
  23. orr r0, r0, #(CR_C | CR_M) @ enable MMU and Dcache
  24. mcr p15, 0, r0, c1, c0, 0
  25. #ifdef CONFIG_DEBUG_LL
  26. bl debug_ll_init
  27. #endif
  28. /*
  29. * Now we are using the page table embedded in the Boot ROM.
  30. * It is not handy since it is not a straight mapped table for sLD3.
  31. * What we need to do next is to switch over to the page table in SPL.
  32. */
  33. ldr r3, =init_page_table @ page table must be 16KB aligned
  34. /* Disable MMU and Dcache before switching Page Table */
  35. mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
  36. bic r0, r0, #(CR_C | CR_M) @ disable MMU and Dcache
  37. mcr p15, 0, r0, c1, c0, 0
  38. bl enable_mmu
  39. bl setup_init_ram @ RAM area for temporary stack pointer
  40. mov lr, r8 @ restore link
  41. mov pc, lr @ back to my caller
  42. ENDPROC(lowlevel_init)
  43. ENTRY(enable_mmu)
  44. mrc p15, 0, r0, c2, c0, 2 @ TTBCR (Translation Table Base Control Register)
  45. bic r0, r0, #0x37
  46. orr r0, r0, #0x20 @ disable TTBR1
  47. mcr p15, 0, r0, c2, c0, 2
  48. orr r0, r3, #0x8 @ Outer Cacheability for table walks: WBWA
  49. mcr p15, 0, r0, c2, c0, 0 @ TTBR0
  50. mov r0, #0
  51. mcr p15, 0, r0, c8, c7, 0 @ invalidate TLBs
  52. mov r0, #-1 @ manager for all domains (No permission check)
  53. mcr p15, 0, r0, c3, c0, 0 @ DACR (Domain Access Control Register)
  54. dsb
  55. isb
  56. /*
  57. * MMU on:
  58. * TLBs was already invalidated in "../start.S"
  59. * So, we don't need to invalidate it here.
  60. */
  61. mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
  62. orr r0, r0, #(CR_C | CR_M) @ MMU and Dcache enable
  63. mcr p15, 0, r0, c1, c0, 0
  64. mov pc, lr
  65. ENDPROC(enable_mmu)
  66. /*
  67. * For PH1-Pro4 or older SoCs, the size of WAY is 32KB.
  68. * It is large enough for tmp RAM.
  69. */
  70. #define BOOT_RAM_SIZE (SZ_32K)
  71. #define BOOT_WAY_BITS (0x00000100) /* way 8 */
  72. ENTRY(setup_init_ram)
  73. /*
  74. * Touch to zero for the boot way
  75. */
  76. 0:
  77. /*
  78. * set SSCOQM, SSCOQAD, SSCOQSZ, SSCOQWN in this order
  79. */
  80. ldr r0, = 0x00408006 @ touch to zero with address range
  81. ldr r1, = SSCOQM
  82. str r0, [r1]
  83. ldr r0, = (CONFIG_SPL_STACK - BOOT_RAM_SIZE) @ base address
  84. ldr r1, = SSCOQAD
  85. str r0, [r1]
  86. ldr r0, = BOOT_RAM_SIZE
  87. ldr r1, = SSCOQSZ
  88. str r0, [r1]
  89. ldr r0, = BOOT_WAY_BITS
  90. ldr r1, = SSCOQWN
  91. str r0, [r1]
  92. ldr r1, = SSCOPPQSEF
  93. ldr r0, [r1]
  94. cmp r0, #0 @ check if the command is successfully set
  95. bne 0b @ try again if an error occurs
  96. ldr r1, = SSCOLPQS
  97. 1:
  98. ldr r0, [r1]
  99. cmp r0, #0x4
  100. bne 1b @ wait until the operation is completed
  101. str r0, [r1] @ clear the complete notification flag
  102. mov pc, lr
  103. ENDPROC(setup_init_ram)