sleep-tegra30.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2012, NVIDIA Corporation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <linux/linkage.h>
  17. #include <asm/assembler.h>
  18. #include "sleep.h"
  19. #include "flowctrl.h"
  20. #define TEGRA30_POWER_HOTPLUG_SHUTDOWN (1 << 27) /* Hotplug shutdown */
  21. #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP)
  22. /*
  23. * tegra30_hotplug_shutdown(void)
  24. *
  25. * Powergates the current CPU.
  26. * Should never return.
  27. */
  28. ENTRY(tegra30_hotplug_shutdown)
  29. /* Turn off SMP coherency */
  30. exit_smp r4, r5
  31. /* Powergate this CPU */
  32. mov r0, #TEGRA30_POWER_HOTPLUG_SHUTDOWN
  33. bl tegra30_cpu_shutdown
  34. mov pc, lr @ should never get here
  35. ENDPROC(tegra30_hotplug_shutdown)
  36. /*
  37. * tegra30_cpu_shutdown(unsigned long flags)
  38. *
  39. * Puts the current CPU in wait-for-event mode on the flow controller
  40. * and powergates it -- flags (in R0) indicate the request type.
  41. * Must never be called for CPU 0.
  42. *
  43. * corrupts r0-r4, r12
  44. */
  45. ENTRY(tegra30_cpu_shutdown)
  46. cpu_id r3
  47. cmp r3, #0
  48. moveq pc, lr @ Must never be called for CPU 0
  49. ldr r12, =TEGRA_FLOW_CTRL_VIRT
  50. cpu_to_csr_reg r1, r3
  51. add r1, r1, r12 @ virtual CSR address for this CPU
  52. cpu_to_halt_reg r2, r3
  53. add r2, r2, r12 @ virtual HALT_EVENTS address for this CPU
  54. /*
  55. * Clear this CPU's "event" and "interrupt" flags and power gate
  56. * it when halting but not before it is in the "WFE" state.
  57. */
  58. movw r12, \
  59. FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG | \
  60. FLOW_CTRL_CSR_ENABLE
  61. mov r4, #(1 << 4)
  62. orr r12, r12, r4, lsl r3
  63. str r12, [r1]
  64. /* Halt this CPU. */
  65. mov r3, #0x400
  66. delay_1:
  67. subs r3, r3, #1 @ delay as a part of wfe war.
  68. bge delay_1;
  69. cpsid a @ disable imprecise aborts.
  70. ldr r3, [r1] @ read CSR
  71. str r3, [r1] @ clear CSR
  72. tst r0, #TEGRA30_POWER_HOTPLUG_SHUTDOWN
  73. movne r3, #FLOW_CTRL_WAITEVENT @ For hotplug
  74. str r3, [r2]
  75. ldr r0, [r2]
  76. b wfe_war
  77. __cpu_reset_again:
  78. dsb
  79. .align 5
  80. wfe @ CPU should be power gated here
  81. wfe_war:
  82. b __cpu_reset_again
  83. /*
  84. * 38 nop's, which fills reset of wfe cache line and
  85. * 4 more cachelines with nop
  86. */
  87. .rept 38
  88. nop
  89. .endr
  90. b . @ should never get here
  91. ENDPROC(tegra30_cpu_shutdown)
  92. #endif