idle_64e.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2010 IBM Corp, Benjamin Herrenschmidt <[email protected]>
  4. *
  5. * Generic idle routine for 64 bits e500 processors
  6. */
  7. #include <linux/threads.h>
  8. #include <asm/reg.h>
  9. #include <asm/ppc_asm.h>
  10. #include <asm/asm-offsets.h>
  11. #include <asm/ppc-opcode.h>
  12. #include <asm/processor.h>
  13. #include <asm/thread_info.h>
  14. #include <asm/epapr_hcalls.h>
  15. #include <asm/hw_irq.h>
  16. /* 64-bit version only for now */
  17. .macro BOOK3E_IDLE name loop
  18. _GLOBAL(\name)
  19. /* Save LR for later */
  20. mflr r0
  21. std r0,16(r1)
  22. /* Hard disable interrupts */
  23. wrteei 0
  24. /* Now check if an interrupt came in while we were soft disabled
  25. * since we may otherwise lose it (doorbells etc...).
  26. */
  27. lbz r3,PACAIRQHAPPENED(r13)
  28. cmpwi cr0,r3,0
  29. bne 2f
  30. /* Now we are going to mark ourselves as soft and hard enabled in
  31. * order to be able to take interrupts while asleep. We inform lockdep
  32. * of that. We don't actually turn interrupts on just yet tho.
  33. */
  34. #ifdef CONFIG_TRACE_IRQFLAGS
  35. stdu r1,-128(r1)
  36. bl trace_hardirqs_on
  37. addi r1,r1,128
  38. #endif
  39. li r0,IRQS_ENABLED
  40. stb r0,PACAIRQSOFTMASK(r13)
  41. /* Interrupts will make use return to LR, so get something we want
  42. * in there
  43. */
  44. bl 1f
  45. /* And return (interrupts are on) */
  46. ld r0,16(r1)
  47. mtlr r0
  48. blr
  49. 1: /* Let's set the _TLF_NAPPING flag so interrupts make us return
  50. * to the right spot
  51. */
  52. ld r11, PACACURRENT(r13)
  53. ld r10,TI_LOCAL_FLAGS(r11)
  54. ori r10,r10,_TLF_NAPPING
  55. std r10,TI_LOCAL_FLAGS(r11)
  56. /* We can now re-enable hard interrupts and go to sleep */
  57. wrteei 1
  58. \loop
  59. 2:
  60. lbz r10,PACAIRQHAPPENED(r13)
  61. ori r10,r10,PACA_IRQ_HARD_DIS
  62. stb r10,PACAIRQHAPPENED(r13)
  63. blr
  64. .endm
  65. .macro BOOK3E_IDLE_LOOP
  66. 1:
  67. PPC_WAIT_v203
  68. b 1b
  69. .endm
  70. /* epapr_ev_idle_start below is patched with the proper hcall
  71. opcodes during kernel initialization */
  72. .macro EPAPR_EV_IDLE_LOOP
  73. idle_loop:
  74. LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
  75. .global epapr_ev_idle_start
  76. epapr_ev_idle_start:
  77. li r3, -1
  78. nop
  79. nop
  80. nop
  81. b idle_loop
  82. .endm
  83. BOOK3E_IDLE epapr_ev_idle EPAPR_EV_IDLE_LOOP
  84. BOOK3E_IDLE e500_idle BOOK3E_IDLE_LOOP