cpu_setup_fsl_booke.S 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. #ifdef CONFIG_PPC32
  53. _GLOBAL(__setup_cpu_e200)
  54. /* enable dedicated debug exception handling resources (Debug APU) */
  55. mfspr r3,SPRN_HID0
  56. ori r3,r3,HID0_DAPUEN@l
  57. mtspr SPRN_HID0,r3
  58. b __setup_e200_ivors
  59. _GLOBAL(__setup_cpu_e500v1)
  60. _GLOBAL(__setup_cpu_e500v2)
  61. mflr r4
  62. bl __e500_icache_setup
  63. bl __e500_dcache_setup
  64. bl __setup_e500_ivors
  65. #ifdef CONFIG_FSL_RIO
  66. /* Ensure that RFXE is set */
  67. mfspr r3,SPRN_HID1
  68. oris r3,r3,HID1_RFXE@h
  69. mtspr SPRN_HID1,r3
  70. #endif
  71. mtlr r4
  72. blr
  73. _GLOBAL(__setup_cpu_e500mc)
  74. _GLOBAL(__setup_cpu_e5500)
  75. mflr r5
  76. bl __e500_icache_setup
  77. bl __e500_dcache_setup
  78. bl __setup_e500mc_ivors
  79. /*
  80. * We only want to touch IVOR38-41 if we're running on hardware
  81. * that supports category E.HV. The architectural way to determine
  82. * this is MMUCFG[LPIDSIZE].
  83. */
  84. mfspr r3, SPRN_MMUCFG
  85. rlwinm. r3, r3, 0, MMUCFG_LPIDSIZE
  86. beq 1f
  87. bl __setup_ehv_ivors
  88. b 2f
  89. 1:
  90. lwz r3, CPU_SPEC_FEATURES(r4)
  91. /* We need this check as cpu_setup is also called for
  92. * the secondary cores. So, if we have already cleared
  93. * the feature on the primary core, avoid doing it on the
  94. * secondary core.
  95. */
  96. andis. r6, r3, CPU_FTR_EMB_HV@h
  97. beq 2f
  98. rlwinm r3, r3, 0, ~CPU_FTR_EMB_HV
  99. stw r3, CPU_SPEC_FEATURES(r4)
  100. 2:
  101. mtlr r5
  102. blr
  103. #endif
  104. #ifdef CONFIG_PPC_BOOK3E_64
  105. _GLOBAL(__restore_cpu_e5500)
  106. mflr r4
  107. bl __e500_icache_setup
  108. bl __e500_dcache_setup
  109. bl .__setup_base_ivors
  110. bl .setup_perfmon_ivor
  111. bl .setup_doorbell_ivors
  112. /*
  113. * We only want to touch IVOR38-41 if we're running on hardware
  114. * that supports category E.HV. The architectural way to determine
  115. * this is MMUCFG[LPIDSIZE].
  116. */
  117. mfspr r10,SPRN_MMUCFG
  118. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  119. beq 1f
  120. bl .setup_ehv_ivors
  121. 1:
  122. mtlr r4
  123. blr
  124. _GLOBAL(__setup_cpu_e5500)
  125. mflr r5
  126. bl __e500_icache_setup
  127. bl __e500_dcache_setup
  128. bl .__setup_base_ivors
  129. bl .setup_perfmon_ivor
  130. bl .setup_doorbell_ivors
  131. /*
  132. * We only want to touch IVOR38-41 if we're running on hardware
  133. * that supports category E.HV. The architectural way to determine
  134. * this is MMUCFG[LPIDSIZE].
  135. */
  136. mfspr r10,SPRN_MMUCFG
  137. rlwinm. r10,r10,0,MMUCFG_LPIDSIZE
  138. beq 1f
  139. bl .setup_ehv_ivors
  140. b 2f
  141. 1:
  142. ld r10,CPU_SPEC_FEATURES(r4)
  143. LOAD_REG_IMMEDIATE(r9,CPU_FTR_EMB_HV)
  144. andc r10,r10,r9
  145. std r10,CPU_SPEC_FEATURES(r4)
  146. 2:
  147. mtlr r5
  148. blr
  149. #endif