sleep.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (c) 2010-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. #ifndef __MACH_TEGRA_SLEEP_H
  17. #define __MACH_TEGRA_SLEEP_H
  18. #include "iomap.h"
  19. #define TEGRA_ARM_PERIF_VIRT (TEGRA_ARM_PERIF_BASE - IO_CPU_PHYS \
  20. + IO_CPU_VIRT)
  21. #define TEGRA_FLOW_CTRL_VIRT (TEGRA_FLOW_CTRL_BASE - IO_PPSB_PHYS \
  22. + IO_PPSB_VIRT)
  23. #define TEGRA_CLK_RESET_VIRT (TEGRA_CLK_RESET_BASE - IO_PPSB_PHYS \
  24. + IO_PPSB_VIRT)
  25. #ifdef __ASSEMBLY__
  26. /* returns the offset of the flow controller halt register for a cpu */
  27. .macro cpu_to_halt_reg rd, rcpu
  28. cmp \rcpu, #0
  29. subne \rd, \rcpu, #1
  30. movne \rd, \rd, lsl #3
  31. addne \rd, \rd, #0x14
  32. moveq \rd, #0
  33. .endm
  34. /* returns the offset of the flow controller csr register for a cpu */
  35. .macro cpu_to_csr_reg rd, rcpu
  36. cmp \rcpu, #0
  37. subne \rd, \rcpu, #1
  38. movne \rd, \rd, lsl #3
  39. addne \rd, \rd, #0x18
  40. moveq \rd, #8
  41. .endm
  42. /* returns the ID of the current processor */
  43. .macro cpu_id, rd
  44. mrc p15, 0, \rd, c0, c0, 5
  45. and \rd, \rd, #0xF
  46. .endm
  47. /* loads a 32-bit value into a register without a data access */
  48. .macro mov32, reg, val
  49. movw \reg, #:lower16:\val
  50. movt \reg, #:upper16:\val
  51. .endm
  52. /* Macro to exit SMP coherency. */
  53. .macro exit_smp, tmp1, tmp2
  54. mrc p15, 0, \tmp1, c1, c0, 1 @ ACTLR
  55. bic \tmp1, \tmp1, #(1<<6) | (1<<0) @ clear ACTLR.SMP | ACTLR.FW
  56. mcr p15, 0, \tmp1, c1, c0, 1 @ ACTLR
  57. isb
  58. cpu_id \tmp1
  59. mov \tmp1, \tmp1, lsl #2
  60. mov \tmp2, #0xf
  61. mov \tmp2, \tmp2, lsl \tmp1
  62. mov32 \tmp1, TEGRA_ARM_PERIF_VIRT + 0xC
  63. str \tmp2, [\tmp1] @ invalidate SCU tags for CPU
  64. dsb
  65. .endm
  66. /* Macro to resume & re-enable L2 cache */
  67. #ifndef L2X0_CTRL_EN
  68. #define L2X0_CTRL_EN 1
  69. #endif
  70. #ifdef CONFIG_CACHE_L2X0
  71. .macro l2_cache_resume, tmp1, tmp2, tmp3, phys_l2x0_saved_regs
  72. adr \tmp1, \phys_l2x0_saved_regs
  73. ldr \tmp1, [\tmp1]
  74. ldr \tmp2, [\tmp1, #L2X0_R_PHY_BASE]
  75. ldr \tmp3, [\tmp2, #L2X0_CTRL]
  76. tst \tmp3, #L2X0_CTRL_EN
  77. bne exit_l2_resume
  78. ldr \tmp3, [\tmp1, #L2X0_R_TAG_LATENCY]
  79. str \tmp3, [\tmp2, #L2X0_TAG_LATENCY_CTRL]
  80. ldr \tmp3, [\tmp1, #L2X0_R_DATA_LATENCY]
  81. str \tmp3, [\tmp2, #L2X0_DATA_LATENCY_CTRL]
  82. ldr \tmp3, [\tmp1, #L2X0_R_PREFETCH_CTRL]
  83. str \tmp3, [\tmp2, #L2X0_PREFETCH_CTRL]
  84. ldr \tmp3, [\tmp1, #L2X0_R_PWR_CTRL]
  85. str \tmp3, [\tmp2, #L2X0_POWER_CTRL]
  86. ldr \tmp3, [\tmp1, #L2X0_R_AUX_CTRL]
  87. str \tmp3, [\tmp2, #L2X0_AUX_CTRL]
  88. mov \tmp3, #L2X0_CTRL_EN
  89. str \tmp3, [\tmp2, #L2X0_CTRL]
  90. exit_l2_resume:
  91. .endm
  92. #else /* CONFIG_CACHE_L2X0 */
  93. .macro l2_cache_resume, tmp1, tmp2, tmp3, phys_l2x0_saved_regs
  94. .endm
  95. #endif /* CONFIG_CACHE_L2X0 */
  96. #else
  97. void tegra_resume(void);
  98. int tegra_sleep_cpu_finish(unsigned long);
  99. #ifdef CONFIG_HOTPLUG_CPU
  100. void tegra20_hotplug_init(void);
  101. void tegra30_hotplug_init(void);
  102. #else
  103. static inline void tegra20_hotplug_init(void) {}
  104. static inline void tegra30_hotplug_init(void) {}
  105. #endif
  106. int tegra30_sleep_cpu_secondary_finish(unsigned long);
  107. void tegra30_tear_down_cpu(void);
  108. #endif
  109. #endif