cpu_setup_fsl_booke.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * This file contains low level CPU setup functions.
  3. * Kumar Gala <galak@kernel.crashing.org>
  4. * Copyright 2009 Freescale Semiconductor, Inc.
  5. *
  6. * Based on cpu_setup_6xx code by
  7. * Benjamin Herrenschmidt <benh@kernel.crashing.org>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. *
  14. */
  15. #include <asm/processor.h>
  16. #include <asm/cputable.h>
  17. #include <asm/ppc_asm.h>
  18. #include <asm/mmu-book3e.h>
  19. #include <asm/asm-offsets.h>
  20. _GLOBAL(__e500_icache_setup)
  21. mfspr r0, SPRN_L1CSR1
  22. andi. r3, r0, L1CSR1_ICE
  23. bnelr /* Already enabled */
  24. oris r0, r0, L1CSR1_CPE@h
  25. ori r0, r0, (L1CSR1_ICFI | L1CSR1_ICLFR | L1CSR1_ICE)
  26. mtspr SPRN_L1CSR1, r0 /* Enable I-Cache */
  27. isync
  28. blr
  29. _GLOBAL(__e500_dcache_setup)
  30. mfspr r0, SPRN_L1CSR0
  31. andi. r3, r0, L1CSR0_DCE
  32. bnelr /* Already enabled */
  33. msync
  34. isync
  35. li r0, 0
  36. mtspr SPRN_L1CSR0, r0 /* Disable */
  37. msync
  38. isync
  39. li r0, (L1CSR0_DCFI | L1CSR0_CLFC)
  40. mtspr SPRN_L1CSR0, r0 /* Invalidate */
  41. isync
  42. 1: mfspr r0, SPRN_L1CSR0
  43. andi. r3, r0, L1CSR0_CLFC
  44. bne+ 1b /* Wait for lock bits reset */
  45. oris r0, r0, L1CSR0_CPE@h
  46. ori r0, r0, L1CSR0_DCE
  47. msync
  48. isync
  49. mtspr SPRN_L1CSR0, r0 /* Enable */
  50. isync
  51. blr
  52. _GLOBAL(__setup_cpu_e6500)
  53. mflr r6
  54. #ifdef CONFIG_PPC64
  55. bl .setup_altivec_ivors
  56. #endif
  57. bl __setup_cpu_e5500
  58. mtlr r6
  59. blr
  60. #ifdef CONFIG_PPC32
  61. _GLOBAL(__setup_cpu_e200)
  62. /* enable dedicated debug exception handling resources (Debug APU) */
  63. mfspr r3,SPRN_HID0
  64. ori r3,r3,HID0_DAPUEN@l
  65. mtspr SPRN_HID0,r3
  66. b __setup_e200_ivors
  67. _GLOBAL(__setup_cpu_e500v1)
  68. _GLOBAL(__setup_cpu_e500v2)
  69. mflr r4
  70. bl __e500_icache_setup
  71. bl __e500_dcache_setup
  72. bl __setup_e500_ivors
  73. #ifdef CONFIG_FSL_RIO
  74. /* Ensure that RFXE is set */
  75. mfspr r3,SPRN_HID1
  76. oris r3,r3,HID1_RFXE@h
  77. mtspr SPRN_HID1,r3
  78. #endif
  79. mtlr r4
  80. blr
  81. _GLOBAL(__setup_cpu_e500mc)
  82. _GLOBAL(__setup_cpu_e5500)
  83. mflr r5
  84. bl __e500_icache_setup
  85. bl __e500_dcache_setup
  86. bl __setup_e500mc_ivors
  87. /*
  88. * We only want to touch IVOR38-41 if we're running on hardware
  89. * that supports category E.HV. The architectural way to determine
  90. * this is MMUCFG[LPIDSIZE].
  91. */
  92. mfspr r3, SPRN_MMUCFG
  93. rlwinm. r3, r3, 0, MMUCFG_LPIDSIZE
  94. beq 1f
  95. bl __setup_ehv_ivors
  96. b 2f
  97. 1:
  98. lwz r3, CPU_SPEC_FEATURES(r4)
  99. /* We need this check as cpu_setup is also called for
  100. * the secondary cores. So, if we have already cleared
  101. * the feature on the primary core, avoid doing it on the
  102. * secondary core.
  103. */
  104. andis. r6, r3, CPU_FTR_EMB_HV@h
  105. beq 2f
  106. rlwinm r3, r3, 0, ~CPU_FTR_EMB_HV
  107. stw r3, CPU_SPEC_FEATURES(r4)
  108. 2:
  109. mtlr r5
  110. blr
  111. #endif
  112. #ifdef CONFIG_PPC_BOOK3E_64
  113. _GLOBAL(__restore_cpu_e6500)
  114. mflr r5
  115. bl .setup_altivec_ivors
  116. bl __restore_cpu_e5500
  117. mtlr r5
  118. blr
  119. _GLOBAL(__restore_cpu_e5500)
  120. mflr r4
  121. bl __e500_icache_setup
  122. bl __e500_dcache_setup
  123. bl .__setup_base_ivors
  124. bl .setup_perfmon_ivor
  125. bl .setup_doorbell_ivors
  126. /*
  127. * We only want to touch IVOR38-41 if we're running on hardware
  128. * that supports category E.HV. The architectural way to determine
  129. * this is MMUCFG[LPIDSIZE].
  130. */
  131. mfspr r10,SPRN_MMUCFG
  132. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  133. beq 1f
  134. bl .setup_ehv_ivors
  135. 1:
  136. mtlr r4
  137. blr
  138. _GLOBAL(__setup_cpu_e5500)
  139. mflr r5
  140. bl __e500_icache_setup
  141. bl __e500_dcache_setup
  142. bl .__setup_base_ivors
  143. bl .setup_perfmon_ivor
  144. bl .setup_doorbell_ivors
  145. /*
  146. * We only want to touch IVOR38-41 if we're running on hardware
  147. * that supports category E.HV. The architectural way to determine
  148. * this is MMUCFG[LPIDSIZE].
  149. */
  150. mfspr r10,SPRN_MMUCFG
  151. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  152. beq 1f
  153. bl .setup_ehv_ivors
  154. b 2f
  155. 1:
  156. ld r10,CPU_SPEC_FEATURES(r4)
  157. LOAD_REG_IMMEDIATE(r9,CPU_FTR_EMB_HV)
  158. andc r10,r10,r9
  159. std r10,CPU_SPEC_FEATURES(r4)
  160. 2:
  161. mtlr r5
  162. blr
  163. #endif