idle_power7.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /* Continue saving state */
  51. SAVE_GPR(2, r1)
  52. SAVE_NVGPRS(r1)
  53. mfcr r3
  54. std r3,_CCR(r1)
  55. std r9,_MSR(r1)
  56. std r1,PACAR1(r13)
  57. /* Magic NAP mode enter sequence */
  58. std r0,0(r1)
  59. ptesync
  60. ld r0,0(r1)
  61. 1: cmp cr0,r0,r0
  62. bne 1b
  63. PPC_NAP
  64. b .
  65. _GLOBAL(power7_wakeup_loss)
  66. ld r1,PACAR1(r13)
  67. REST_NVGPRS(r1)
  68. REST_GPR(2, r1)
  69. ld r3,_CCR(r1)
  70. ld r4,_MSR(r1)
  71. ld r5,_NIP(r1)
  72. addi r1,r1,INT_FRAME_SIZE
  73. mtcr r3
  74. mtspr SPRN_SRR1,r4
  75. mtspr SPRN_SRR0,r5
  76. rfid
  77. _GLOBAL(power7_wakeup_noloss)
  78. ld r1,PACAR1(r13)
  79. ld r4,_MSR(r1)
  80. ld r5,_NIP(r1)
  81. addi r1,r1,INT_FRAME_SIZE
  82. mtspr SPRN_SRR1,r4
  83. mtspr SPRN_SRR0,r5
  84. rfid