cpu_setup_fsl_booke.S 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. /*
  53. * FIXME - we haven't yet done testing to determine a reasonable default
  54. * value for PW20_WAIT_IDLE_BIT.
  55. */
  56. #define PW20_WAIT_IDLE_BIT 50 /* 1ms, TB frequency is 41.66MHZ */
  57. _GLOBAL(setup_pw20_idle)
  58. mfspr r3, SPRN_PWRMGTCR0
  59. /* Set PW20_WAIT bit, enable pw20 state*/
  60. ori r3, r3, PWRMGTCR0_PW20_WAIT
  61. li r11, PW20_WAIT_IDLE_BIT
  62. /* Set Automatic PW20 Core Idle Count */
  63. rlwimi r3, r11, PWRMGTCR0_PW20_ENT_SHIFT, PWRMGTCR0_PW20_ENT
  64. mtspr SPRN_PWRMGTCR0, r3
  65. blr
  66. /*
  67. * FIXME - we haven't yet done testing to determine a reasonable default
  68. * value for AV_WAIT_IDLE_BIT.
  69. */
  70. #define AV_WAIT_IDLE_BIT 50 /* 1ms, TB frequency is 41.66MHZ */
  71. _GLOBAL(setup_altivec_idle)
  72. mfspr r3, SPRN_PWRMGTCR0
  73. /* Enable Altivec Idle */
  74. oris r3, r3, PWRMGTCR0_AV_IDLE_PD_EN@h
  75. li r11, AV_WAIT_IDLE_BIT
  76. /* Set Automatic AltiVec Idle Count */
  77. rlwimi r3, r11, PWRMGTCR0_AV_IDLE_CNT_SHIFT, PWRMGTCR0_AV_IDLE_CNT
  78. mtspr SPRN_PWRMGTCR0, r3
  79. blr
  80. #ifdef CONFIG_PPC_E500MC
  81. _GLOBAL(__setup_cpu_e6500)
  82. mflr r6
  83. #ifdef CONFIG_PPC64
  84. bl setup_altivec_ivors
  85. /* Touch IVOR42 only if the CPU supports E.HV category */
  86. mfspr r10,SPRN_MMUCFG
  87. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  88. beq 1f
  89. bl setup_lrat_ivor
  90. 1:
  91. #endif
  92. bl setup_pw20_idle
  93. bl setup_altivec_idle
  94. bl __setup_cpu_e5500
  95. mtlr r6
  96. blr
  97. #endif /* CONFIG_PPC_E500MC */
  98. #ifdef CONFIG_PPC32
  99. #ifdef CONFIG_E200
  100. _GLOBAL(__setup_cpu_e200)
  101. /* enable dedicated debug exception handling resources (Debug APU) */
  102. mfspr r3,SPRN_HID0
  103. ori r3,r3,HID0_DAPUEN@l
  104. mtspr SPRN_HID0,r3
  105. b __setup_e200_ivors
  106. #endif /* CONFIG_E200 */
  107. #ifdef CONFIG_E500
  108. #ifndef CONFIG_PPC_E500MC
  109. _GLOBAL(__setup_cpu_e500v1)
  110. _GLOBAL(__setup_cpu_e500v2)
  111. mflr r4
  112. bl __e500_icache_setup
  113. bl __e500_dcache_setup
  114. bl __setup_e500_ivors
  115. #if defined(CONFIG_FSL_RIO) || defined(CONFIG_FSL_PCI)
  116. /* Ensure that RFXE is set */
  117. mfspr r3,SPRN_HID1
  118. oris r3,r3,HID1_RFXE@h
  119. mtspr SPRN_HID1,r3
  120. #endif
  121. mtlr r4
  122. blr
  123. #else /* CONFIG_PPC_E500MC */
  124. _GLOBAL(__setup_cpu_e500mc)
  125. _GLOBAL(__setup_cpu_e5500)
  126. mflr r5
  127. bl __e500_icache_setup
  128. bl __e500_dcache_setup
  129. bl __setup_e500mc_ivors
  130. /*
  131. * We only want to touch IVOR38-41 if we're running on hardware
  132. * that supports category E.HV. The architectural way to determine
  133. * this is MMUCFG[LPIDSIZE].
  134. */
  135. mfspr r3, SPRN_MMUCFG
  136. rlwinm. r3, r3, 0, MMUCFG_LPIDSIZE
  137. beq 1f
  138. bl __setup_ehv_ivors
  139. b 2f
  140. 1:
  141. lwz r3, CPU_SPEC_FEATURES(r4)
  142. /* We need this check as cpu_setup is also called for
  143. * the secondary cores. So, if we have already cleared
  144. * the feature on the primary core, avoid doing it on the
  145. * secondary core.
  146. */
  147. andis. r6, r3, CPU_FTR_EMB_HV@h
  148. beq 2f
  149. rlwinm r3, r3, 0, ~CPU_FTR_EMB_HV
  150. stw r3, CPU_SPEC_FEATURES(r4)
  151. 2:
  152. mtlr r5
  153. blr
  154. #endif /* CONFIG_PPC_E500MC */
  155. #endif /* CONFIG_E500 */
  156. #endif /* CONFIG_PPC32 */
  157. #ifdef CONFIG_PPC_BOOK3E_64
  158. _GLOBAL(__restore_cpu_e6500)
  159. mflr r5
  160. bl setup_altivec_ivors
  161. /* Touch IVOR42 only if the CPU supports E.HV category */
  162. mfspr r10,SPRN_MMUCFG
  163. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  164. beq 1f
  165. bl setup_lrat_ivor
  166. 1:
  167. bl setup_pw20_idle
  168. bl setup_altivec_idle
  169. bl __restore_cpu_e5500
  170. mtlr r5
  171. blr
  172. _GLOBAL(__restore_cpu_e5500)
  173. mflr r4
  174. bl __e500_icache_setup
  175. bl __e500_dcache_setup
  176. bl __setup_base_ivors
  177. bl setup_perfmon_ivor
  178. bl setup_doorbell_ivors
  179. /*
  180. * We only want to touch IVOR38-41 if we're running on hardware
  181. * that supports category E.HV. The architectural way to determine
  182. * this is MMUCFG[LPIDSIZE].
  183. */
  184. mfspr r10,SPRN_MMUCFG
  185. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  186. beq 1f
  187. bl setup_ehv_ivors
  188. 1:
  189. mtlr r4
  190. blr
  191. _GLOBAL(__setup_cpu_e5500)
  192. mflr r5
  193. bl __e500_icache_setup
  194. bl __e500_dcache_setup
  195. bl __setup_base_ivors
  196. bl setup_perfmon_ivor
  197. bl setup_doorbell_ivors
  198. /*
  199. * We only want to touch IVOR38-41 if we're running on hardware
  200. * that supports category E.HV. The architectural way to determine
  201. * this is MMUCFG[LPIDSIZE].
  202. */
  203. mfspr r10,SPRN_MMUCFG
  204. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  205. beq 1f
  206. bl setup_ehv_ivors
  207. b 2f
  208. 1:
  209. ld r10,CPU_SPEC_FEATURES(r4)
  210. LOAD_REG_IMMEDIATE(r9,CPU_FTR_EMB_HV)
  211. andc r10,r10,r9
  212. std r10,CPU_SPEC_FEATURES(r4)
  213. 2:
  214. mtlr r5
  215. blr
  216. #endif