sleep.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2013 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com
  4. *
  5. * Exynos low-level resume code
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/linkage.h>
  18. #include <asm/asm-offsets.h>
  19. #include <asm/hardware/cache-l2x0.h>
  20. #include "smc.h"
  21. #define CPU_MASK 0xff0ffff0
  22. #define CPU_CORTEX_A9 0x410fc090
  23. .text
  24. .align
  25. /*
  26. * sleep magic, to allow the bootloader to check for an valid
  27. * image to resume to. Must be the first word before the
  28. * exynos_cpu_resume entry.
  29. */
  30. .word 0x2bedf00d
  31. /*
  32. * exynos_cpu_resume
  33. *
  34. * resume code entry for bootloader to call
  35. */
  36. ENTRY(exynos_cpu_resume)
  37. #ifdef CONFIG_CACHE_L2X0
  38. mrc p15, 0, r0, c0, c0, 0
  39. ldr r1, =CPU_MASK
  40. and r0, r0, r1
  41. ldr r1, =CPU_CORTEX_A9
  42. cmp r0, r1
  43. bleq l2c310_early_resume
  44. #endif
  45. b cpu_resume
  46. ENDPROC(exynos_cpu_resume)
  47. .align
  48. ENTRY(exynos_cpu_resume_ns)
  49. mrc p15, 0, r0, c0, c0, 0
  50. ldr r1, =CPU_MASK
  51. and r0, r0, r1
  52. ldr r1, =CPU_CORTEX_A9
  53. cmp r0, r1
  54. bne skip_cp15
  55. adr r0, _cp15_save_power
  56. ldr r1, [r0]
  57. ldr r1, [r0, r1]
  58. adr r0, _cp15_save_diag
  59. ldr r2, [r0]
  60. ldr r2, [r0, r2]
  61. mov r0, #SMC_CMD_C15RESUME
  62. dsb
  63. smc #0
  64. #ifdef CONFIG_CACHE_L2X0
  65. adr r0, 1f
  66. ldr r2, [r0]
  67. add r0, r2, r0
  68. /* Check that the address has been initialised. */
  69. ldr r1, [r0, #L2X0_R_PHY_BASE]
  70. teq r1, #0
  71. beq skip_l2x0
  72. /* Check if controller has been enabled. */
  73. ldr r2, [r1, #L2X0_CTRL]
  74. tst r2, #0x1
  75. bne skip_l2x0
  76. ldr r1, [r0, #L2X0_R_TAG_LATENCY]
  77. ldr r2, [r0, #L2X0_R_DATA_LATENCY]
  78. ldr r3, [r0, #L2X0_R_PREFETCH_CTRL]
  79. mov r0, #SMC_CMD_L2X0SETUP1
  80. smc #0
  81. /* Reload saved regs pointer because smc corrupts registers. */
  82. adr r0, 1f
  83. ldr r2, [r0]
  84. add r0, r2, r0
  85. ldr r1, [r0, #L2X0_R_PWR_CTRL]
  86. ldr r2, [r0, #L2X0_R_AUX_CTRL]
  87. mov r0, #SMC_CMD_L2X0SETUP2
  88. smc #0
  89. mov r0, #SMC_CMD_L2X0INVALL
  90. smc #0
  91. mov r1, #1
  92. mov r0, #SMC_CMD_L2X0CTRL
  93. smc #0
  94. skip_l2x0:
  95. #endif /* CONFIG_CACHE_L2X0 */
  96. skip_cp15:
  97. b cpu_resume
  98. ENDPROC(exynos_cpu_resume_ns)
  99. .align
  100. _cp15_save_power:
  101. .long cp15_save_power - .
  102. _cp15_save_diag:
  103. .long cp15_save_diag - .
  104. #ifdef CONFIG_CACHE_L2X0
  105. 1: .long l2x0_saved_regs - .
  106. #endif /* CONFIG_CACHE_L2X0 */
  107. .data
  108. .globl cp15_save_diag
  109. cp15_save_diag:
  110. .long 0 @ cp15 diagnostic
  111. .globl cp15_save_power
  112. cp15_save_power:
  113. .long 0 @ cp15 power control