cpu_setup_ppc970.S 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * This file contains low level CPU setup functions.
  3. * Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. *
  10. */
  11. #include <asm/processor.h>
  12. #include <asm/page.h>
  13. #include <asm/cputable.h>
  14. #include <asm/ppc_asm.h>
  15. #include <asm/asm-offsets.h>
  16. #include <asm/cache.h>
  17. _GLOBAL(__cpu_preinit_ppc970)
  18. /* Do nothing if not running in HV mode */
  19. mfmsr r0
  20. rldicl. r0,r0,4,63
  21. beqlr
  22. /* Make sure HID4:rm_ci is off before MMU is turned off, that large
  23. * pages are enabled with HID4:61 and clear HID5:DCBZ_size and
  24. * HID5:DCBZ32_ill
  25. */
  26. li r0,0
  27. mfspr r3,SPRN_HID4
  28. rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
  29. rldimi r3,r0,2,61 /* clear bit 61 (lg_pg_en) */
  30. sync
  31. mtspr SPRN_HID4,r3
  32. isync
  33. sync
  34. mfspr r3,SPRN_HID5
  35. rldimi r3,r0,6,56 /* clear bits 56 & 57 (DCBZ*) */
  36. sync
  37. mtspr SPRN_HID5,r3
  38. isync
  39. sync
  40. /* Setup some basic HID1 features */
  41. mfspr r0,SPRN_HID1
  42. li r3,0x1200 /* enable i-fetch cacheability */
  43. sldi r3,r3,44 /* and prefetch */
  44. or r0,r0,r3
  45. mtspr SPRN_HID1,r0
  46. mtspr SPRN_HID1,r0
  47. isync
  48. /* Clear HIOR */
  49. li r0,0
  50. sync
  51. mtspr SPRN_HIOR,0 /* Clear interrupt prefix */
  52. isync
  53. blr
  54. /* Definitions for the table use to save CPU states */
  55. #define CS_HID0 0
  56. #define CS_HID1 8
  57. #define CS_HID4 16
  58. #define CS_HID5 24
  59. #define CS_SIZE 32
  60. .data
  61. .balign L1_CACHE_BYTES,0
  62. cpu_state_storage:
  63. .space CS_SIZE
  64. .balign L1_CACHE_BYTES,0
  65. .text
  66. _GLOBAL(__setup_cpu_ppc970)
  67. /* Do nothing if not running in HV mode */
  68. mfmsr r0
  69. rldicl. r0,r0,4,63
  70. beq no_hv_mode
  71. mfspr r0,SPRN_HID0
  72. li r11,5 /* clear DOZE and SLEEP */
  73. rldimi r0,r11,52,8 /* set NAP and DPM */
  74. li r11,0
  75. rldimi r0,r11,32,31 /* clear EN_ATTN */
  76. b load_hids /* Jump to shared code */
  77. _GLOBAL(__setup_cpu_ppc970MP)
  78. /* Do nothing if not running in HV mode */
  79. mfmsr r0
  80. rldicl. r0,r0,4,63
  81. beq no_hv_mode
  82. mfspr r0,SPRN_HID0
  83. li r11,0x15 /* clear DOZE and SLEEP */
  84. rldimi r0,r11,52,6 /* set DEEPNAP, NAP and DPM */
  85. li r11,0
  86. rldimi r0,r11,32,31 /* clear EN_ATTN */
  87. load_hids:
  88. mtspr SPRN_HID0,r0
  89. mfspr r0,SPRN_HID0
  90. mfspr r0,SPRN_HID0
  91. mfspr r0,SPRN_HID0
  92. mfspr r0,SPRN_HID0
  93. mfspr r0,SPRN_HID0
  94. mfspr r0,SPRN_HID0
  95. sync
  96. isync
  97. /* Try to set LPES = 01 in HID4 */
  98. mfspr r0,SPRN_HID4
  99. clrldi r0,r0,1 /* clear LPES0 */
  100. ori r0,r0,HID4_LPES1 /* set LPES1 */
  101. sync
  102. mtspr SPRN_HID4,r0
  103. isync
  104. /* Save away cpu state */
  105. LOAD_REG_ADDR(r5,cpu_state_storage)
  106. /* Save HID0,1,4 and 5 */
  107. mfspr r3,SPRN_HID0
  108. std r3,CS_HID0(r5)
  109. mfspr r3,SPRN_HID1
  110. std r3,CS_HID1(r5)
  111. mfspr r4,SPRN_HID4
  112. std r4,CS_HID4(r5)
  113. mfspr r3,SPRN_HID5
  114. std r3,CS_HID5(r5)
  115. /* See if we successfully set LPES1 to 1; if not we are in Apple mode */
  116. andi. r4,r4,HID4_LPES1
  117. bnelr
  118. no_hv_mode:
  119. /* Disable CPU_FTR_HVMODE and exit, since we don't have HV mode */
  120. ld r5,CPU_SPEC_FEATURES(r4)
  121. LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
  122. andc r5,r5,r6
  123. std r5,CPU_SPEC_FEATURES(r4)
  124. blr
  125. /* Called with no MMU context (typically MSR:IR/DR off) to
  126. * restore CPU state as backed up by the previous
  127. * function. This does not include cache setting
  128. */
  129. _GLOBAL(__restore_cpu_ppc970)
  130. /* Do nothing if not running in HV mode */
  131. mfmsr r0
  132. rldicl. r0,r0,4,63
  133. beqlr
  134. LOAD_REG_ADDR(r5,cpu_state_storage)
  135. /* Before accessing memory, we make sure rm_ci is clear */
  136. li r0,0
  137. mfspr r3,SPRN_HID4
  138. rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
  139. sync
  140. mtspr SPRN_HID4,r3
  141. isync
  142. sync
  143. /* Clear interrupt prefix */
  144. li r0,0
  145. sync
  146. mtspr SPRN_HIOR,0
  147. isync
  148. /* Restore HID0 */
  149. ld r3,CS_HID0(r5)
  150. sync
  151. isync
  152. mtspr SPRN_HID0,r3
  153. mfspr r3,SPRN_HID0
  154. mfspr r3,SPRN_HID0
  155. mfspr r3,SPRN_HID0
  156. mfspr r3,SPRN_HID0
  157. mfspr r3,SPRN_HID0
  158. mfspr r3,SPRN_HID0
  159. sync
  160. isync
  161. /* Restore HID1 */
  162. ld r3,CS_HID1(r5)
  163. sync
  164. isync
  165. mtspr SPRN_HID1,r3
  166. mtspr SPRN_HID1,r3
  167. sync
  168. isync
  169. /* Restore HID4 */
  170. ld r3,CS_HID4(r5)
  171. sync
  172. isync
  173. mtspr SPRN_HID4,r3
  174. sync
  175. isync
  176. /* Restore HID5 */
  177. ld r3,CS_HID5(r5)
  178. sync
  179. isync
  180. mtspr SPRN_HID5,r3
  181. sync
  182. isync
  183. blr