cpu_setup_power.S 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. /* Entry: r3 = crap, r4 = ptr to cputable entry
  18. *
  19. * Note that we can be called twice for pseudo-PVRs
  20. */
  21. _GLOBAL(__setup_cpu_power7)
  22. mflr r11
  23. bl __init_hvmode_206
  24. mtlr r11
  25. beqlr
  26. li r0,0
  27. mtspr SPRN_LPID,r0
  28. mfspr r3,SPRN_LPCR
  29. bl __init_LPCR
  30. bl __init_TLB
  31. mtlr r11
  32. blr
  33. _GLOBAL(__restore_cpu_power7)
  34. mflr r11
  35. mfmsr r3
  36. rldicl. r0,r3,4,63
  37. beqlr
  38. li r0,0
  39. mtspr SPRN_LPID,r0
  40. mfspr r3,SPRN_LPCR
  41. bl __init_LPCR
  42. bl __init_TLB
  43. mtlr r11
  44. blr
  45. _GLOBAL(__setup_cpu_power8)
  46. mflr r11
  47. bl __init_hvmode_206
  48. mtlr r11
  49. beqlr
  50. li r0,0
  51. mtspr SPRN_LPID,r0
  52. mfspr r3,SPRN_LPCR
  53. oris r3, r3, LPCR_AIL_3@h
  54. bl __init_LPCR
  55. bl __init_TLB
  56. mtlr r11
  57. blr
  58. _GLOBAL(__restore_cpu_power8)
  59. mflr r11
  60. mfmsr r3
  61. rldicl. r0,r3,4,63
  62. beqlr
  63. li r0,0
  64. mtspr SPRN_LPID,r0
  65. mfspr r3,SPRN_LPCR
  66. oris r3, r3, LPCR_AIL_3@h
  67. bl __init_LPCR
  68. bl __init_TLB
  69. mtlr r11
  70. blr
  71. __init_hvmode_206:
  72. /* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
  73. mfmsr r3
  74. rldicl. r0,r3,4,63
  75. bnelr
  76. ld r5,CPU_SPEC_FEATURES(r4)
  77. LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
  78. xor r5,r5,r6
  79. std r5,CPU_SPEC_FEATURES(r4)
  80. blr
  81. __init_LPCR:
  82. /* Setup a sane LPCR:
  83. * Called with initial LPCR in R3
  84. *
  85. * LPES = 0b01 (HSRR0/1 used for 0x500)
  86. * PECE = 0b111
  87. * DPFD = 4
  88. * HDICE = 0
  89. * VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
  90. * VRMASD = 0b10000 (L=1, LP=00)
  91. *
  92. * Other bits untouched for now
  93. */
  94. li r5,1
  95. rldimi r3,r5, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
  96. ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
  97. li r5,4
  98. rldimi r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
  99. clrrdi r3,r3,1 /* clear HDICE */
  100. li r5,4
  101. rldimi r3,r5, LPCR_VC_SH, 0
  102. li r5,0x10
  103. rldimi r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
  104. mtspr SPRN_LPCR,r3
  105. isync
  106. blr
  107. __init_TLB:
  108. /* Clear the TLB */
  109. li r6,128
  110. mtctr r6
  111. li r7,0xc00 /* IS field = 0b11 */
  112. ptesync
  113. 2: tlbiel r7
  114. addi r7,r7,0x1000
  115. bdnz 2b
  116. ptesync
  117. 1: blr