cpu_setup_power4.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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 <linux/config.h>
  12. #include <asm/processor.h>
  13. #include <asm/page.h>
  14. #include <asm/ppc_asm.h>
  15. #include <asm/cputable.h>
  16. #include <asm/ppc_asm.h>
  17. #include <asm/offsets.h>
  18. #include <asm/cache.h>
  19. _GLOBAL(__970_cpu_preinit)
  20. /*
  21. * Do nothing if not running in HV mode
  22. */
  23. mfmsr r0
  24. rldicl. r0,r0,4,63
  25. beqlr
  26. /*
  27. * Deal only with PPC970 and PPC970FX.
  28. */
  29. mfspr r0,SPRN_PVR
  30. srwi r0,r0,16
  31. cmpwi r0,0x39
  32. beq 1f
  33. cmpwi r0,0x3c
  34. beq 1f
  35. cmpwi r0,0x44
  36. bnelr
  37. 1:
  38. /* Make sure HID4:rm_ci is off before MMU is turned off, that large
  39. * pages are enabled with HID4:61 and clear HID5:DCBZ_size and
  40. * HID5:DCBZ32_ill
  41. */
  42. li r0,0
  43. mfspr r3,SPRN_HID4
  44. rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
  45. rldimi r3,r0,2,61 /* clear bit 61 (lg_pg_en) */
  46. sync
  47. mtspr SPRN_HID4,r3
  48. isync
  49. sync
  50. mfspr r3,SPRN_HID5
  51. rldimi r3,r0,6,56 /* clear bits 56 & 57 (DCBZ*) */
  52. sync
  53. mtspr SPRN_HID5,r3
  54. isync
  55. sync
  56. /* Setup some basic HID1 features */
  57. mfspr r0,SPRN_HID1
  58. li r3,0x1200 /* enable i-fetch cacheability */
  59. sldi r3,r3,44 /* and prefetch */
  60. or r0,r0,r3
  61. mtspr SPRN_HID1,r0
  62. mtspr SPRN_HID1,r0
  63. isync
  64. /* Clear HIOR */
  65. li r0,0
  66. sync
  67. mtspr SPRN_HIOR,0 /* Clear interrupt prefix */
  68. isync
  69. blr
  70. _GLOBAL(__setup_cpu_power4)
  71. blr
  72. _GLOBAL(__setup_cpu_be)
  73. /* Set large page sizes LP=0: 16MB, LP=1: 64KB */
  74. addi r3, 0, 0
  75. ori r3, r3, HID6_LB
  76. sldi r3, r3, 32
  77. nor r3, r3, r3
  78. mfspr r4, SPRN_HID6
  79. and r4, r4, r3
  80. addi r3, 0, 0x02000
  81. sldi r3, r3, 32
  82. or r4, r4, r3
  83. mtspr SPRN_HID6, r4
  84. blr
  85. _GLOBAL(__setup_cpu_ppc970)
  86. mfspr r0,SPRN_HID0
  87. li r11,5 /* clear DOZE and SLEEP */
  88. rldimi r0,r11,52,8 /* set NAP and DPM */
  89. mtspr SPRN_HID0,r0
  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. mfspr r0,SPRN_HID0
  96. sync
  97. isync
  98. blr
  99. /* Definitions for the table use to save CPU states */
  100. #define CS_HID0 0
  101. #define CS_HID1 8
  102. #define CS_HID4 16
  103. #define CS_HID5 24
  104. #define CS_SIZE 32
  105. .data
  106. .balign L1_CACHE_BYTES,0
  107. cpu_state_storage:
  108. .space CS_SIZE
  109. .balign L1_CACHE_BYTES,0
  110. .text
  111. /* Called in normal context to backup CPU 0 state. This
  112. * does not include cache settings. This function is also
  113. * called for machine sleep. This does not include the MMU
  114. * setup, BATs, etc... but rather the "special" registers
  115. * like HID0, HID1, HID4, etc...
  116. */
  117. _GLOBAL(__save_cpu_setup)
  118. /* Some CR fields are volatile, we back it up all */
  119. mfcr r7
  120. /* Get storage ptr */
  121. LOADADDR(r5,cpu_state_storage)
  122. /* We only deal with 970 for now */
  123. mfspr r0,SPRN_PVR
  124. srwi r0,r0,16
  125. cmpwi r0,0x39
  126. beq 1f
  127. cmpwi r0,0x3c
  128. beq 1f
  129. cmpwi r0,0x44
  130. bne 2f
  131. 1: /* Save HID0,1,4 and 5 */
  132. mfspr r3,SPRN_HID0
  133. std r3,CS_HID0(r5)
  134. mfspr r3,SPRN_HID1
  135. std r3,CS_HID1(r5)
  136. mfspr r3,SPRN_HID4
  137. std r3,CS_HID4(r5)
  138. mfspr r3,SPRN_HID5
  139. std r3,CS_HID5(r5)
  140. 2:
  141. mtcr r7
  142. blr
  143. /* Called with no MMU context (typically MSR:IR/DR off) to
  144. * restore CPU state as backed up by the previous
  145. * function. This does not include cache setting
  146. */
  147. _GLOBAL(__restore_cpu_setup)
  148. /* Get storage ptr (FIXME when using anton reloc as we
  149. * are running with translation disabled here
  150. */
  151. LOADADDR(r5,cpu_state_storage)
  152. /* We only deal with 970 for now */
  153. mfspr r0,SPRN_PVR
  154. srwi r0,r0,16
  155. cmpwi r0,0x39
  156. beq 1f
  157. cmpwi r0,0x3c
  158. beq 1f
  159. cmpwi r0,0x44
  160. bnelr
  161. 1: /* Before accessing memory, we make sure rm_ci is clear */
  162. li r0,0
  163. mfspr r3,SPRN_HID4
  164. rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
  165. sync
  166. mtspr SPRN_HID4,r3
  167. isync
  168. sync
  169. /* Clear interrupt prefix */
  170. li r0,0
  171. sync
  172. mtspr SPRN_HIOR,0
  173. isync
  174. /* Restore HID0 */
  175. ld r3,CS_HID0(r5)
  176. sync
  177. isync
  178. mtspr SPRN_HID0,r3
  179. mfspr r3,SPRN_HID0
  180. mfspr r3,SPRN_HID0
  181. mfspr r3,SPRN_HID0
  182. mfspr r3,SPRN_HID0
  183. mfspr r3,SPRN_HID0
  184. mfspr r3,SPRN_HID0
  185. sync
  186. isync
  187. /* Restore HID1 */
  188. ld r3,CS_HID1(r5)
  189. sync
  190. isync
  191. mtspr SPRN_HID1,r3
  192. mtspr SPRN_HID1,r3
  193. sync
  194. isync
  195. /* Restore HID4 */
  196. ld r3,CS_HID4(r5)
  197. sync
  198. isync
  199. mtspr SPRN_HID4,r3
  200. sync
  201. isync
  202. /* Restore HID5 */
  203. ld r3,CS_HID5(r5)
  204. sync
  205. isync
  206. mtspr SPRN_HID5,r3
  207. sync
  208. isync
  209. blr