cpu_setup_ppc970.S 3.3 KB

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