cpu_setup_ppc970.S 3.3 KB

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