powersave.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2006-2007 PA Semi, Inc
  4. *
  5. * Maintained by: Olof Johansson <[email protected]>
  6. */
  7. #include <asm/processor.h>
  8. #include <asm/page.h>
  9. #include <asm/ppc_asm.h>
  10. #include <asm/cputable.h>
  11. #include <asm/cache.h>
  12. #include <asm/thread_info.h>
  13. #include <asm/asm-offsets.h>
  14. /* Power savings opcodes since not all binutils have them at this time */
  15. #define DOZE .long 0x4c000324
  16. #define NAP .long 0x4c000364
  17. #define SLEEP .long 0x4c0003a4
  18. #define RVW .long 0x4c0003e4
  19. /* Common sequence to do before going to any of the
  20. * powersavings modes.
  21. */
  22. #define PRE_SLEEP_SEQUENCE \
  23. std r3,8(r1); \
  24. ptesync ; \
  25. ld r3,8(r1); \
  26. 1: cmpd r3,r3; \
  27. bne 1b
  28. _doze:
  29. PRE_SLEEP_SEQUENCE
  30. DOZE
  31. b .
  32. _GLOBAL(idle_spin)
  33. blr
  34. _GLOBAL(idle_doze)
  35. LOAD_REG_ADDR(r3, _doze)
  36. b sleep_common
  37. /* Add more modes here later */
  38. sleep_common:
  39. mflr r0
  40. std r0, 16(r1)
  41. stdu r1,-64(r1)
  42. #ifdef CONFIG_PPC_PASEMI_CPUFREQ
  43. std r3, 48(r1)
  44. /* Only do power savings when in astate 0 */
  45. bl check_astate
  46. cmpwi r3,0
  47. bne 1f
  48. ld r3, 48(r1)
  49. #endif
  50. LOAD_REG_IMMEDIATE(r6,MSR_DR|MSR_IR|MSR_ME|MSR_EE)
  51. mfmsr r4
  52. andc r5,r4,r6
  53. mtmsrd r5,0
  54. mtctr r3
  55. bctrl
  56. mtmsrd r4,0
  57. 1: addi r1,r1,64
  58. ld r0,16(r1)
  59. mtlr r0
  60. blr