cpu_setup_ppc970.S 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. beqlr
  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. beqlr
  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. /* Save away cpu state */
  98. LOAD_REG_ADDR(r5,cpu_state_storage)
  99. /* Save HID0,1,4 and 5 */
  100. mfspr r3,SPRN_HID0
  101. std r3,CS_HID0(r5)
  102. mfspr r3,SPRN_HID1
  103. std r3,CS_HID1(r5)
  104. mfspr r3,SPRN_HID4
  105. std r3,CS_HID4(r5)
  106. mfspr r3,SPRN_HID5
  107. std r3,CS_HID5(r5)
  108. blr
  109. /* Called with no MMU context (typically MSR:IR/DR off) to
  110. * restore CPU state as backed up by the previous
  111. * function. This does not include cache setting
  112. */
  113. _GLOBAL(__restore_cpu_ppc970)
  114. /* Do nothing if not running in HV mode */
  115. mfmsr r0
  116. rldicl. r0,r0,4,63
  117. beqlr
  118. LOAD_REG_ADDR(r5,cpu_state_storage)
  119. /* Before accessing memory, we make sure rm_ci is clear */
  120. li r0,0
  121. mfspr r3,SPRN_HID4
  122. rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
  123. sync
  124. mtspr SPRN_HID4,r3
  125. isync
  126. sync
  127. /* Clear interrupt prefix */
  128. li r0,0
  129. sync
  130. mtspr SPRN_HIOR,0
  131. isync
  132. /* Restore HID0 */
  133. ld r3,CS_HID0(r5)
  134. sync
  135. isync
  136. mtspr SPRN_HID0,r3
  137. mfspr r3,SPRN_HID0
  138. mfspr r3,SPRN_HID0
  139. mfspr r3,SPRN_HID0
  140. mfspr r3,SPRN_HID0
  141. mfspr r3,SPRN_HID0
  142. mfspr r3,SPRN_HID0
  143. sync
  144. isync
  145. /* Restore HID1 */
  146. ld r3,CS_HID1(r5)
  147. sync
  148. isync
  149. mtspr SPRN_HID1,r3
  150. mtspr SPRN_HID1,r3
  151. sync
  152. isync
  153. /* Restore HID4 */
  154. ld r3,CS_HID4(r5)
  155. sync
  156. isync
  157. mtspr SPRN_HID4,r3
  158. sync
  159. isync
  160. /* Restore HID5 */
  161. ld r3,CS_HID5(r5)
  162. sync
  163. isync
  164. mtspr SPRN_HID5,r3
  165. sync
  166. isync
  167. blr