sleep.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* linux/arch/arm/plat-s3c64xx/sleep.S
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * S3C64XX CPU sleep code
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/linkage.h>
  15. #include <asm/assembler.h>
  16. #include <mach/map.h>
  17. #undef S3C64XX_VA_GPIO
  18. #define S3C64XX_VA_GPIO (0x0)
  19. #include <mach/regs-gpio.h>
  20. #include <mach/gpio-bank-n.h>
  21. #define LL_UART (S3C_PA_UART + (0x400 * CONFIG_S3C_LOWLEVEL_UART_PORT))
  22. .text
  23. /* s3c_cpu_save
  24. *
  25. * Save enough processor state to allow the restart of the pm.c
  26. * code after resume.
  27. *
  28. * entry:
  29. * r0 = pointer to the save block
  30. */
  31. ENTRY(s3c_cpu_save)
  32. stmfd sp!, { r4 - r12, lr }
  33. mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID
  34. mrc p15, 0, r5, c3, c0, 0 @ Domain ID
  35. mrc p15, 0, r6, c2, c0, 0 @ Translation Table BASE0
  36. mrc p15, 0, r7, c2, c0, 1 @ Translation Table BASE1
  37. mrc p15, 0, r8, c2, c0, 2 @ Translation Table Control
  38. mrc p15, 0, r9, c1, c0, 0 @ Control register
  39. mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register
  40. mrc p15, 0, r11, c1, c0, 2 @ Co-processor access controls
  41. stmia r0, { r4 - r13 } @ Save CP registers and SP
  42. @@ save our state to ram
  43. bl s3c_pm_cb_flushcache
  44. @@ call final suspend code
  45. ldr r0, =pm_cpu_sleep
  46. ldr pc, [r0]
  47. @@ return to the caller, after the MMU is turned on.
  48. @@ restore the last bits of the stack and return.
  49. resume_with_mmu:
  50. ldmfd sp!, { r4 - r12, pc } @ return, from sp from s3c_cpu_save
  51. .data
  52. /* the next bit is code, but it requires easy access to the
  53. * s3c_sleep_save_phys data before the MMU is switched on, so
  54. * we store the code that needs this variable in the .data where
  55. * the value can be written to (the .text segment is RO).
  56. */
  57. .global s3c_sleep_save_phys
  58. s3c_sleep_save_phys:
  59. .word 0
  60. /* Sleep magic, the word before the resume entry point so that the
  61. * bootloader can check for a resumeable image. */
  62. .word 0x2bedf00d
  63. /* s3c_cpu_reusme
  64. *
  65. * This is the entry point, stored by whatever method the bootloader
  66. * requires to get the kernel runnign again. This code expects to be
  67. * entered with no caches live and the MMU disabled. It will then
  68. * restore the MMU and other basic CP registers saved and restart
  69. * the kernel C code to finish the resume code.
  70. */
  71. ENTRY(s3c_cpu_resume)
  72. msr cpsr_c, #PSR_I_BIT | PSR_F_BIT | SVC_MODE
  73. ldr r2, =LL_UART /* for debug */
  74. #ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK
  75. /* Initialise the GPIO state if we are debugging via the SMDK LEDs,
  76. * as the uboot version supplied resets these to inputs during the
  77. * resume checks.
  78. */
  79. ldr r3, =S3C64XX_PA_GPIO
  80. ldr r0, [ r3, #S3C64XX_GPNCON ]
  81. bic r0, r0, #(S3C64XX_GPN_CONMASK(12) | S3C64XX_GPN_CONMASK(13) | \
  82. S3C64XX_GPN_CONMASK(14) | S3C64XX_GPN_CONMASK(15))
  83. orr r0, r0, #(S3C64XX_GPN_OUTPUT(12) | S3C64XX_GPN_OUTPUT(13) | \
  84. S3C64XX_GPN_OUTPUT(14) | S3C64XX_GPN_OUTPUT(15))
  85. str r0, [ r3, #S3C64XX_GPNCON ]
  86. ldr r0, [ r3, #S3C64XX_GPNDAT ]
  87. bic r0, r0, #0xf << 12 @ GPN12..15
  88. orr r0, r0, #1 << 15 @ GPN15
  89. str r0, [ r3, #S3C64XX_GPNDAT ]
  90. #endif
  91. /* __v6_setup from arch/arm/mm/proc-v6.S, ensure that the caches
  92. * are thoroughly cleaned just in case the bootloader didn't do it
  93. * for us. */
  94. mov r0, #0
  95. mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
  96. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  97. mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
  98. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  99. @@mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
  100. @@mcr p15, 0, r0, c7, c7, 0 @ Invalidate I + D caches
  101. ldr r0, s3c_sleep_save_phys
  102. ldmia r0, { r4 - r13 }
  103. mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID
  104. mcr p15, 0, r5, c3, c0, 0 @ Domain ID
  105. mcr p15, 0, r6, c2, c0, 0 @ Translation Table BASE0
  106. mcr p15, 0, r7, c2, c0, 1 @ Translation Table BASE1
  107. mcr p15, 0, r8, c2, c0, 2 @ Translation Table Control
  108. mcr p15, 0, r10, c1, c0, 1 @ Auxiliary control register
  109. mov r0, #0 @ restore copro access controls
  110. mcr p15, 0, r11, c1, c0, 2 @ Co-processor access controls
  111. mcr p15, 0, r0, c7, c5, 4
  112. ldr r2, =resume_with_mmu
  113. mcr p15, 0, r9, c1, c0, 0 /* turn mmu back on */
  114. nop
  115. mov pc, r2 /* jump back */
  116. .end