cpu_setup_power.S 2.2 KB

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