idle_power4.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/irqflags.h>
  17. #include <asm/hw_irq.h>
  18. #include <asm/feature-fixups.h>
  19. #undef DEBUG
  20. .text
  21. _GLOBAL(power4_idle)
  22. BEGIN_FTR_SECTION
  23. blr
  24. END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
  25. /* Now check if user or arch enabled NAP mode */
  26. LOAD_REG_ADDRBASE(r3,powersave_nap)
  27. lwz r4,ADDROFF(powersave_nap)(r3)
  28. cmpwi 0,r4,0
  29. beqlr
  30. /* This sequence is similar to prep_irq_for_idle() */
  31. /* Hard disable interrupts */
  32. mfmsr r7
  33. rldicl r0,r7,48,1
  34. rotldi r0,r0,16
  35. mtmsrd r0,1
  36. /* Check if something happened while soft-disabled */
  37. lbz r0,PACAIRQHAPPENED(r13)
  38. cmpwi cr0,r0,0
  39. bne- 2f
  40. /*
  41. * Soft-enable interrupts. This will make power4_fixup_nap return
  42. * to our caller with interrupts enabled (soft and hard). The caller
  43. * can cope with either interrupts disabled or enabled upon return.
  44. */
  45. #ifdef CONFIG_TRACE_IRQFLAGS
  46. /* Tell the tracer interrupts are on, because idle responds to them. */
  47. mflr r0
  48. std r0,16(r1)
  49. stdu r1,-128(r1)
  50. bl trace_hardirqs_on
  51. addi r1,r1,128
  52. ld r0,16(r1)
  53. mtlr r0
  54. mfmsr r7
  55. #endif /* CONFIG_TRACE_IRQFLAGS */
  56. li r0,IRQS_ENABLED
  57. stb r0,PACAIRQSOFTMASK(r13) /* we'll hard-enable shortly */
  58. BEGIN_FTR_SECTION
  59. DSSALL
  60. sync
  61. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  62. CURRENT_THREAD_INFO(r9, r1)
  63. ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */
  64. ori r8,r8,_TLF_NAPPING /* so when we take an exception */
  65. std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */
  66. ori r7,r7,MSR_EE
  67. oris r7,r7,MSR_POW@h
  68. 1: sync
  69. isync
  70. mtmsrd r7
  71. isync
  72. b 1b
  73. 2: /* Return if an interrupt had happened while soft disabled */
  74. /* Set the HARD_DIS flag because interrupts are now hard disabled */
  75. ori r0,r0,PACA_IRQ_HARD_DIS
  76. stb r0,PACAIRQHAPPENED(r13)
  77. blr