idle_power7.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * This file contains the power_save function for 970-family CPUs.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <linux/threads.h>
  10. #include <asm/processor.h>
  11. #include <asm/page.h>
  12. #include <asm/cputable.h>
  13. #include <asm/thread_info.h>
  14. #include <asm/ppc_asm.h>
  15. #include <asm/asm-offsets.h>
  16. #include <asm/ppc-opcode.h>
  17. #undef DEBUG
  18. .text
  19. _GLOBAL(power7_idle)
  20. /* Now check if user or arch enabled NAP mode */
  21. LOAD_REG_ADDRBASE(r3,powersave_nap)
  22. lwz r4,ADDROFF(powersave_nap)(r3)
  23. cmpwi 0,r4,0
  24. beqlr
  25. /* NAP is a state loss, we create a regs frame on the
  26. * stack, fill it up with the state we care about and
  27. * stick a pointer to it in PACAR1. We really only
  28. * need to save PC, some CR bits and the NV GPRs,
  29. * but for now an interrupt frame will do.
  30. */
  31. mflr r0
  32. std r0,16(r1)
  33. stdu r1,-INT_FRAME_SIZE(r1)
  34. std r0,_LINK(r1)
  35. std r0,_NIP(r1)
  36. #ifndef CONFIG_SMP
  37. /* Make sure FPU, VSX etc... are flushed as we may lose
  38. * state when going to nap mode
  39. */
  40. bl .discard_lazy_cpu_state
  41. #endif /* CONFIG_SMP */
  42. /* Hard disable interrupts */
  43. mfmsr r9
  44. rldicl r9,r9,48,1
  45. rotldi r9,r9,16
  46. mtmsrd r9,1 /* hard-disable interrupts */
  47. li r0,0
  48. stb r0,PACASOFTIRQEN(r13) /* we'll hard-enable shortly */
  49. stb r0,PACAHARDIRQEN(r13)
  50. stb r0,PACA_NAPSTATELOST(r13)
  51. /* Continue saving state */
  52. SAVE_GPR(2, r1)
  53. SAVE_NVGPRS(r1)
  54. mfcr r3
  55. std r3,_CCR(r1)
  56. std r9,_MSR(r1)
  57. std r1,PACAR1(r13)
  58. /* Magic NAP mode enter sequence */
  59. std r0,0(r1)
  60. ptesync
  61. ld r0,0(r1)
  62. 1: cmp cr0,r0,r0
  63. bne 1b
  64. PPC_NAP
  65. b .
  66. _GLOBAL(power7_wakeup_loss)
  67. ld r1,PACAR1(r13)
  68. REST_NVGPRS(r1)
  69. REST_GPR(2, r1)
  70. ld r3,_CCR(r1)
  71. ld r4,_MSR(r1)
  72. ld r5,_NIP(r1)
  73. addi r1,r1,INT_FRAME_SIZE
  74. mtcr r3
  75. mtspr SPRN_SRR1,r4
  76. mtspr SPRN_SRR0,r5
  77. rfid
  78. _GLOBAL(power7_wakeup_noloss)
  79. lbz r0,PACA_NAPSTATELOST(r13)
  80. cmpwi r0,0
  81. bne .power7_wakeup_loss
  82. ld r1,PACAR1(r13)
  83. ld r4,_MSR(r1)
  84. ld r5,_NIP(r1)
  85. addi r1,r1,INT_FRAME_SIZE
  86. mtspr SPRN_SRR1,r4
  87. mtspr SPRN_SRR0,r5
  88. rfid