lowlevel_init.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (C) 2012-2015 Panasonic Corporation
  3. * Copyright (C) 2015 Socionext Inc.
  4. * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <config.h>
  9. #include <linux/linkage.h>
  10. #include <linux/sizes.h>
  11. #include <asm/system.h>
  12. #include <mach/led.h>
  13. #include <mach/arm-mpcore.h>
  14. #include <mach/sbc-regs.h>
  15. #include <mach/ssc-regs.h>
  16. ENTRY(lowlevel_init)
  17. mov r8, lr @ persevere link reg across call
  18. /*
  19. * The UniPhier Boot ROM loads SPL code to the L2 cache.
  20. * But CPUs can only do instruction fetch now because start.S has
  21. * cleared C and M bits.
  22. * First we need to turn on MMU and Dcache again to get back
  23. * data access to L2.
  24. */
  25. mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
  26. orr r0, r0, #(CR_C | CR_M) @ enable MMU and Dcache
  27. mcr p15, 0, r0, c1, c0, 0
  28. #ifdef CONFIG_DEBUG_LL
  29. bl setup_lowlevel_debug
  30. #endif
  31. /*
  32. * Now we are using the page table embedded in the Boot ROM.
  33. * It is not handy since it is not a straight mapped table for sLD3.
  34. * What we need to do next is to switch over to the page table in SPL.
  35. */
  36. ldr r3, =init_page_table @ page table must be 16KB aligned
  37. /* Disable MMU and Dcache before switching Page Table */
  38. mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
  39. bic r0, r0, #(CR_C | CR_M) @ disable MMU and Dcache
  40. mcr p15, 0, r0, c1, c0, 0
  41. bl enable_mmu
  42. #ifdef CONFIG_UNIPHIER_SMP
  43. /*
  44. * ACTLR (Auxiliary Control Register) for Cortex-A9
  45. * bit[9] Parity on
  46. * bit[8] Alloc in one way
  47. * bit[7] EXCL (Exclusive cache bit)
  48. * bit[6] SMP
  49. * bit[3] Write full line of zeros mode
  50. * bit[2] L1 prefetch enable
  51. * bit[1] L2 prefetch enable
  52. * bit[0] FW (Cache and TLB maintenance broadcast)
  53. */
  54. mrc p15, 0, r0, c1, c0, 1 @ ACTLR (Auxiliary Control Register)
  55. orr r0, r0, #0x41 @ enable SMP, FW bit
  56. mcr p15, 0, r0, c1, c0, 1
  57. /* branch by CPU ID */
  58. mrc p15, 0, r0, c0, c0, 5 @ MPIDR (Multiprocessor Affinity Register)
  59. and r0, r0, #0x3
  60. cmp r0, #0x0
  61. beq primary_cpu
  62. ldr r1, =ROM_BOOT_ROMRSV2
  63. mov r0, #0
  64. str r0, [r1]
  65. 0: wfe
  66. ldr r0, [r1]
  67. cmp r0, #0
  68. beq 0b
  69. bx r0 @ r0: entry point of U-Boot main for the secondary CPU
  70. primary_cpu:
  71. ldr r1, =ROM_BOOT_ROMRSV2
  72. ldr r0, =_start @ entry for the secondary CPU
  73. str r0, [r1]
  74. ldr r0, [r1] @ make sure str is complete before sev
  75. sev @ kick the secondary CPU
  76. mrc p15, 4, r1, c15, c0, 0 @ Configuration Base Address Register
  77. bfc r1, #0, #13 @ clear bit 12-0
  78. mov r0, #-1
  79. str r0, [r1, #SCU_INV_ALL] @ SCU Invalidate All Register
  80. mov r0, #1 @ SCU enable
  81. str r0, [r1, #SCU_CTRL] @ SCU Control Register
  82. #endif
  83. bl setup_init_ram @ RAM area for temporary stack pointer
  84. mov lr, r8 @ restore link
  85. mov pc, lr @ back to my caller
  86. ENDPROC(lowlevel_init)
  87. ENTRY(enable_mmu)
  88. mrc p15, 0, r0, c2, c0, 2 @ TTBCR (Translation Table Base Control Register)
  89. bic r0, r0, #0x37
  90. orr r0, r0, #0x20 @ disable TTBR1
  91. mcr p15, 0, r0, c2, c0, 2
  92. orr r0, r3, #0x8 @ Outer Cacheability for table walks: WBWA
  93. mcr p15, 0, r0, c2, c0, 0 @ TTBR0
  94. mov r0, #0
  95. mcr p15, 0, r0, c8, c7, 0 @ invalidate TLBs
  96. mov r0, #-1 @ manager for all domains (No permission check)
  97. mcr p15, 0, r0, c3, c0, 0 @ DACR (Domain Access Control Register)
  98. dsb
  99. isb
  100. /*
  101. * MMU on:
  102. * TLBs was already invalidated in "../start.S"
  103. * So, we don't need to invalidate it here.
  104. */
  105. mrc p15, 0, r0, c1, c0, 0 @ SCTLR (System Control Register)
  106. orr r0, r0, #(CR_C | CR_M) @ MMU and Dcache enable
  107. mcr p15, 0, r0, c1, c0, 0
  108. mov pc, lr
  109. ENDPROC(enable_mmu)
  110. /*
  111. * For PH1-Pro4 or older SoCs, the size of WAY is 32KB.
  112. * It is large enough for tmp RAM.
  113. */
  114. #define BOOT_RAM_SIZE (SZ_32K)
  115. #define BOOT_WAY_BITS (0x00000100) /* way 8 */
  116. ENTRY(setup_init_ram)
  117. /*
  118. * Touch to zero for the boot way
  119. */
  120. 0:
  121. /*
  122. * set SSCOQM, SSCOQAD, SSCOQSZ, SSCOQWN in this order
  123. */
  124. ldr r0, = 0x00408006 @ touch to zero with address range
  125. ldr r1, = SSCOQM
  126. str r0, [r1]
  127. ldr r0, = (CONFIG_SPL_STACK - BOOT_RAM_SIZE) @ base address
  128. ldr r1, = SSCOQAD
  129. str r0, [r1]
  130. ldr r0, = BOOT_RAM_SIZE
  131. ldr r1, = SSCOQSZ
  132. str r0, [r1]
  133. ldr r0, = BOOT_WAY_BITS
  134. ldr r1, = SSCOQWN
  135. str r0, [r1]
  136. ldr r1, = SSCOPPQSEF
  137. ldr r0, [r1]
  138. cmp r0, #0 @ check if the command is successfully set
  139. bne 0b @ try again if an error occurs
  140. ldr r1, = SSCOLPQS
  141. 1:
  142. ldr r0, [r1]
  143. cmp r0, #0x4
  144. bne 1b @ wait until the operation is completed
  145. str r0, [r1] @ clear the complete notification flag
  146. mov pc, lr
  147. ENDPROC(setup_init_ram)