sleep.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2010-2013, NVIDIA Corporation. All rights reserved.
  4. */
  5. #ifndef __MACH_TEGRA_SLEEP_H
  6. #define __MACH_TEGRA_SLEEP_H
  7. #include "iomap.h"
  8. #include "irammap.h"
  9. #define TEGRA_ARM_PERIF_VIRT (TEGRA_ARM_PERIF_BASE - IO_CPU_PHYS \
  10. + IO_CPU_VIRT)
  11. #define TEGRA_FLOW_CTRL_VIRT (TEGRA_FLOW_CTRL_BASE - IO_PPSB_PHYS \
  12. + IO_PPSB_VIRT)
  13. #define TEGRA_CLK_RESET_VIRT (TEGRA_CLK_RESET_BASE - IO_PPSB_PHYS \
  14. + IO_PPSB_VIRT)
  15. #define TEGRA_APB_MISC_VIRT (TEGRA_APB_MISC_BASE - IO_APB_PHYS \
  16. + IO_APB_VIRT)
  17. #define TEGRA_PMC_VIRT (TEGRA_PMC_BASE - IO_APB_PHYS + IO_APB_VIRT)
  18. #define TEGRA_IRAM_RESET_BASE_VIRT (IO_IRAM_VIRT + \
  19. TEGRA_IRAM_RESET_HANDLER_OFFSET)
  20. /* PMC_SCRATCH37-39 and 41 are used for tegra_pen_lock and idle */
  21. #define PMC_SCRATCH37 0x130
  22. #define PMC_SCRATCH38 0x134
  23. #define PMC_SCRATCH39 0x138
  24. #define PMC_SCRATCH41 0x140
  25. #ifdef CONFIG_ARCH_TEGRA_2x_SOC
  26. #define CPU_RESETTABLE 2
  27. #define CPU_RESETTABLE_SOON 1
  28. #define CPU_NOT_RESETTABLE 0
  29. #endif
  30. /* flag of tegra_disable_clean_inv_dcache to do LoUIS or all */
  31. #define TEGRA_FLUSH_CACHE_LOUIS 0
  32. #define TEGRA_FLUSH_CACHE_ALL 1
  33. #ifdef __ASSEMBLY__
  34. /* waits until the microsecond counter (base) is > rn */
  35. .macro wait_until, rn, base, tmp
  36. add \rn, \rn, #1
  37. 1001: ldr \tmp, [\base]
  38. cmp \tmp, \rn
  39. bmi 1001b
  40. .endm
  41. /* returns the offset of the flow controller halt register for a cpu */
  42. .macro cpu_to_halt_reg rd, rcpu
  43. cmp \rcpu, #0
  44. subne \rd, \rcpu, #1
  45. movne \rd, \rd, lsl #3
  46. addne \rd, \rd, #0x14
  47. moveq \rd, #0
  48. .endm
  49. /* returns the offset of the flow controller csr register for a cpu */
  50. .macro cpu_to_csr_reg rd, rcpu
  51. cmp \rcpu, #0
  52. subne \rd, \rcpu, #1
  53. movne \rd, \rd, lsl #3
  54. addne \rd, \rd, #0x18
  55. moveq \rd, #8
  56. .endm
  57. /* returns the ID of the current processor */
  58. .macro cpu_id, rd
  59. mrc p15, 0, \rd, c0, c0, 5
  60. and \rd, \rd, #0xF
  61. .endm
  62. /* loads a 32-bit value into a register without a data access */
  63. .macro mov32, reg, val
  64. movw \reg, #:lower16:\val
  65. movt \reg, #:upper16:\val
  66. .endm
  67. /* Marco to check CPU part num */
  68. .macro check_cpu_part_num part_num, tmp1, tmp2
  69. mrc p15, 0, \tmp1, c0, c0, 0
  70. ubfx \tmp1, \tmp1, #4, #12
  71. mov32 \tmp2, \part_num
  72. cmp \tmp1, \tmp2
  73. .endm
  74. /* Macro to exit SMP coherency. */
  75. .macro exit_smp, tmp1, tmp2
  76. mrc p15, 0, \tmp1, c1, c0, 1 @ ACTLR
  77. bic \tmp1, \tmp1, #(1<<6) | (1<<0) @ clear ACTLR.SMP | ACTLR.FW
  78. mcr p15, 0, \tmp1, c1, c0, 1 @ ACTLR
  79. isb
  80. #ifdef CONFIG_HAVE_ARM_SCU
  81. check_cpu_part_num 0xc09, \tmp1, \tmp2
  82. mrceq p15, 0, \tmp1, c0, c0, 5
  83. andeq \tmp1, \tmp1, #0xF
  84. moveq \tmp1, \tmp1, lsl #2
  85. moveq \tmp2, #0xf
  86. moveq \tmp2, \tmp2, lsl \tmp1
  87. ldreq \tmp1, =(TEGRA_ARM_PERIF_VIRT + 0xC)
  88. streq \tmp2, [\tmp1] @ invalidate SCU tags for CPU
  89. dsb
  90. #endif
  91. .endm
  92. /* Macro to check Tegra revision */
  93. #define APB_MISC_GP_HIDREV 0x804
  94. .macro tegra_get_soc_id base, tmp1
  95. mov32 \tmp1, \base
  96. ldr \tmp1, [\tmp1, #APB_MISC_GP_HIDREV]
  97. and \tmp1, \tmp1, #0xff00
  98. mov \tmp1, \tmp1, lsr #8
  99. .endm
  100. #else
  101. void tegra_resume(void);
  102. int tegra_sleep_cpu_finish(unsigned long);
  103. void tegra_disable_clean_inv_dcache(u32 flag);
  104. void tegra20_hotplug_shutdown(void);
  105. void tegra30_hotplug_shutdown(void);
  106. void tegra20_tear_down_cpu(void);
  107. void tegra30_tear_down_cpu(void);
  108. #endif
  109. #endif