cpu_setup_a2.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * A2 specific assembly support code
  3. *
  4. * Copyright 2009 Ben Herrenschmidt, IBM Corp.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <asm/asm-offsets.h>
  12. #include <asm/ppc_asm.h>
  13. #include <asm/ppc-opcode.h>
  14. #include <asm/processor.h>
  15. #include <asm/reg_a2.h>
  16. #include <asm/reg.h>
  17. #include <asm/thread_info.h>
  18. /*
  19. * Disable thdid and class fields in ERATs to bump PID to full 14 bits capacity.
  20. * This also prevents external LPID accesses but that isn't a problem when not a
  21. * guest. Under PV, this setting will be ignored and MMUCR will return the right
  22. * number of PID bits we can use.
  23. */
  24. #define MMUCR1_EXTEND_PID \
  25. (MMUCR1_ICTID | MMUCR1_ITTID | MMUCR1_DCTID | \
  26. MMUCR1_DTTID | MMUCR1_DCCD)
  27. /*
  28. * Use extended PIDs if enabled.
  29. * Don't clear the ERATs on context sync events and enable I & D LRU.
  30. * Enable ERAT back invalidate when tlbwe overwrites an entry.
  31. */
  32. #define INITIAL_MMUCR1 \
  33. (MMUCR1_EXTEND_PID | MMUCR1_CSINV_NEVER | MMUCR1_IRRE | \
  34. MMUCR1_DRRE | MMUCR1_TLBWE_BINV)
  35. _GLOBAL(__setup_cpu_a2)
  36. /* Some of these are actually thread local and some are
  37. * core local but doing it always won't hurt
  38. */
  39. #ifdef CONFIG_PPC_ICSWX
  40. /* Make sure ACOP starts out as zero */
  41. li r3,0
  42. mtspr SPRN_ACOP,r3
  43. /* Skip the following if we are in Guest mode */
  44. mfmsr r3
  45. andis. r0,r3,MSR_GS@h
  46. bne _icswx_skip_guest
  47. /* Enable icswx instruction */
  48. mfspr r3,SPRN_A2_CCR2
  49. ori r3,r3,A2_CCR2_ENABLE_ICSWX
  50. mtspr SPRN_A2_CCR2,r3
  51. /* Unmask all CTs in HACOP */
  52. li r3,-1
  53. mtspr SPRN_HACOP,r3
  54. _icswx_skip_guest:
  55. #endif /* CONFIG_PPC_ICSWX */
  56. /* Enable doorbell */
  57. mfspr r3,SPRN_A2_CCR2
  58. oris r3,r3,A2_CCR2_ENABLE_PC@h
  59. mtspr SPRN_A2_CCR2,r3
  60. isync
  61. /* Setup CCR0 to disable power saving for now as it's busted
  62. * in the current implementations. Setup CCR1 to wake on
  63. * interrupts normally (we write the default value but who
  64. * knows what FW may have clobbered...)
  65. */
  66. li r3,0
  67. mtspr SPRN_A2_CCR0, r3
  68. LOAD_REG_IMMEDIATE(r3,0x0f0f0f0f)
  69. mtspr SPRN_A2_CCR1, r3
  70. /* Initialise MMUCR1 */
  71. lis r3,INITIAL_MMUCR1@h
  72. ori r3,r3,INITIAL_MMUCR1@l
  73. mtspr SPRN_MMUCR1,r3
  74. /* Set MMUCR2 to enable 4K, 64K, 1M, 16M and 1G pages */
  75. LOAD_REG_IMMEDIATE(r3, 0x000a7531)
  76. mtspr SPRN_MMUCR2,r3
  77. /* Set MMUCR3 to write all thids bit to the TLB */
  78. LOAD_REG_IMMEDIATE(r3, 0x0000000f)
  79. mtspr SPRN_MMUCR3,r3
  80. /* Don't do ERAT stuff if running guest mode */
  81. mfmsr r3
  82. andis. r0,r3,MSR_GS@h
  83. bne 1f
  84. /* Now set the I-ERAT watermark to 15 */
  85. lis r4,(MMUCR0_TLBSEL_I|MMUCR0_ECL)@h
  86. mtspr SPRN_MMUCR0, r4
  87. li r4,A2_IERAT_SIZE-1
  88. PPC_ERATWE(r4,r4,3)
  89. /* Now set the D-ERAT watermark to 31 */
  90. lis r4,(MMUCR0_TLBSEL_D|MMUCR0_ECL)@h
  91. mtspr SPRN_MMUCR0, r4
  92. li r4,A2_DERAT_SIZE-1
  93. PPC_ERATWE(r4,r4,3)
  94. /* And invalidate the beast just in case. That won't get rid of
  95. * a bolted entry though it will be in LRU and so will go away eventually
  96. * but let's not bother for now
  97. */
  98. PPC_ERATILX(0,0,0)
  99. 1:
  100. blr
  101. _GLOBAL(__restore_cpu_a2)
  102. b __setup_cpu_a2