idle_power4.S 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * This file contains the power_save function for 6xx & 7xxx CPUs
  3. * rewritten in assembler
  4. *
  5. * Warning ! This code assumes that if your machine has a 750fx
  6. * it will have PLL 1 set to low speed mode (used during NAP/DOZE).
  7. * if this is not the case some additional changes will have to
  8. * be done to check a runtime var (a bit like powersave-nap)
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. #include <linux/config.h>
  16. #include <linux/threads.h>
  17. #include <asm/processor.h>
  18. #include <asm/page.h>
  19. #include <asm/cputable.h>
  20. #include <asm/thread_info.h>
  21. #include <asm/ppc_asm.h>
  22. #include <asm/offsets.h>
  23. #undef DEBUG
  24. .text
  25. /*
  26. * Init idle, called at early CPU setup time from head.S for each CPU
  27. * So nothing for now. Called with r24 containing CPU number and r3
  28. * reloc offset
  29. */
  30. .globl init_idle_power4
  31. init_idle_power4:
  32. blr
  33. /*
  34. * Here is the power_save_6xx function. This could eventually be
  35. * split into several functions & changing the function pointer
  36. * depending on the various features.
  37. */
  38. .globl power4_idle
  39. power4_idle:
  40. BEGIN_FTR_SECTION
  41. blr
  42. END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
  43. /* We must dynamically check for the NAP feature as it
  44. * can be cleared by CPU init after the fixups are done
  45. */
  46. lis r4,cur_cpu_spec@ha
  47. lwz r4,cur_cpu_spec@l(r4)
  48. lwz r4,CPU_SPEC_FEATURES(r4)
  49. andi. r0,r4,CPU_FTR_CAN_NAP
  50. beqlr
  51. /* Now check if user or arch enabled NAP mode */
  52. lis r4,powersave_nap@ha
  53. lwz r4,powersave_nap@l(r4)
  54. cmpwi 0,r4,0
  55. beqlr
  56. /* Clear MSR:EE */
  57. mfmsr r7
  58. rlwinm r0,r7,0,17,15
  59. mtmsr r0
  60. /* Check current_thread_info()->flags */
  61. rlwinm r4,r1,0,0,18
  62. lwz r4,TI_FLAGS(r4)
  63. andi. r0,r4,_TIF_NEED_RESCHED
  64. beq 1f
  65. mtmsr r7 /* out of line this ? */
  66. blr
  67. 1:
  68. /* Go to NAP now */
  69. BEGIN_FTR_SECTION
  70. DSSALL
  71. sync
  72. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  73. ori r7,r7,MSR_EE /* Could be ommited (already set) */
  74. oris r7,r7,MSR_POW@h
  75. sync
  76. isync
  77. mtmsr r7
  78. isync
  79. sync
  80. blr
  81. .globl powersave_nap
  82. powersave_nap:
  83. .long 0