cpu_setup_fsl_booke.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. _GLOBAL(__setup_cpu_e6500)
  81. mflr r6
  82. #ifdef CONFIG_PPC64
  83. bl setup_altivec_ivors
  84. /* Touch IVOR42 only if the CPU supports E.HV category */
  85. mfspr r10,SPRN_MMUCFG
  86. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  87. beq 1f
  88. bl setup_lrat_ivor
  89. 1:
  90. #endif
  91. bl setup_pw20_idle
  92. bl setup_altivec_idle
  93. bl __setup_cpu_e5500
  94. mtlr r6
  95. blr
  96. #ifdef CONFIG_PPC32
  97. _GLOBAL(__setup_cpu_e200)
  98. /* enable dedicated debug exception handling resources (Debug APU) */
  99. mfspr r3,SPRN_HID0
  100. ori r3,r3,HID0_DAPUEN@l
  101. mtspr SPRN_HID0,r3
  102. b __setup_e200_ivors
  103. _GLOBAL(__setup_cpu_e500v1)
  104. _GLOBAL(__setup_cpu_e500v2)
  105. mflr r4
  106. bl __e500_icache_setup
  107. bl __e500_dcache_setup
  108. bl __setup_e500_ivors
  109. #if defined(CONFIG_FSL_RIO) || defined(CONFIG_FSL_PCI)
  110. /* Ensure that RFXE is set */
  111. mfspr r3,SPRN_HID1
  112. oris r3,r3,HID1_RFXE@h
  113. mtspr SPRN_HID1,r3
  114. #endif
  115. mtlr r4
  116. blr
  117. _GLOBAL(__setup_cpu_e500mc)
  118. _GLOBAL(__setup_cpu_e5500)
  119. mflr r5
  120. bl __e500_icache_setup
  121. bl __e500_dcache_setup
  122. bl __setup_e500mc_ivors
  123. /*
  124. * We only want to touch IVOR38-41 if we're running on hardware
  125. * that supports category E.HV. The architectural way to determine
  126. * this is MMUCFG[LPIDSIZE].
  127. */
  128. mfspr r3, SPRN_MMUCFG
  129. rlwinm. r3, r3, 0, MMUCFG_LPIDSIZE
  130. beq 1f
  131. bl __setup_ehv_ivors
  132. b 2f
  133. 1:
  134. lwz r3, CPU_SPEC_FEATURES(r4)
  135. /* We need this check as cpu_setup is also called for
  136. * the secondary cores. So, if we have already cleared
  137. * the feature on the primary core, avoid doing it on the
  138. * secondary core.
  139. */
  140. andis. r6, r3, CPU_FTR_EMB_HV@h
  141. beq 2f
  142. rlwinm r3, r3, 0, ~CPU_FTR_EMB_HV
  143. stw r3, CPU_SPEC_FEATURES(r4)
  144. 2:
  145. mtlr r5
  146. blr
  147. #endif
  148. #ifdef CONFIG_PPC_BOOK3E_64
  149. _GLOBAL(__restore_cpu_e6500)
  150. mflr r5
  151. bl setup_altivec_ivors
  152. /* Touch IVOR42 only if the CPU supports E.HV category */
  153. mfspr r10,SPRN_MMUCFG
  154. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  155. beq 1f
  156. bl setup_lrat_ivor
  157. 1:
  158. bl setup_pw20_idle
  159. bl setup_altivec_idle
  160. bl __restore_cpu_e5500
  161. mtlr r5
  162. blr
  163. _GLOBAL(__restore_cpu_e5500)
  164. mflr r4
  165. bl __e500_icache_setup
  166. bl __e500_dcache_setup
  167. bl __setup_base_ivors
  168. bl setup_perfmon_ivor
  169. bl setup_doorbell_ivors
  170. /*
  171. * We only want to touch IVOR38-41 if we're running on hardware
  172. * that supports category E.HV. The architectural way to determine
  173. * this is MMUCFG[LPIDSIZE].
  174. */
  175. mfspr r10,SPRN_MMUCFG
  176. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  177. beq 1f
  178. bl setup_ehv_ivors
  179. 1:
  180. mtlr r4
  181. blr
  182. _GLOBAL(__setup_cpu_e5500)
  183. mflr r5
  184. bl __e500_icache_setup
  185. bl __e500_dcache_setup
  186. bl __setup_base_ivors
  187. bl setup_perfmon_ivor
  188. bl setup_doorbell_ivors
  189. /*
  190. * We only want to touch IVOR38-41 if we're running on hardware
  191. * that supports category E.HV. The architectural way to determine
  192. * this is MMUCFG[LPIDSIZE].
  193. */
  194. mfspr r10,SPRN_MMUCFG
  195. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  196. beq 1f
  197. bl setup_ehv_ivors
  198. b 2f
  199. 1:
  200. ld r10,CPU_SPEC_FEATURES(r4)
  201. LOAD_REG_IMMEDIATE(r9,CPU_FTR_EMB_HV)
  202. andc r10,r10,r9
  203. std r10,CPU_SPEC_FEATURES(r4)
  204. 2:
  205. mtlr r5
  206. blr
  207. #endif