sleep.S 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. * r1 = v:p offset
  30. */
  31. ENTRY(s3c_cpu_save)
  32. stmfd sp!, { r4 - r12, lr }
  33. ldr r3, =resume_with_mmu
  34. bl cpu_suspend
  35. @@ call final suspend code
  36. ldr r0, =pm_cpu_sleep
  37. ldr pc, [r0]
  38. @@ return to the caller, after the MMU is turned on.
  39. @@ restore the last bits of the stack and return.
  40. resume_with_mmu:
  41. ldmfd sp!, { r4 - r12, pc } @ return, from sp from s3c_cpu_save
  42. /* Sleep magic, the word before the resume entry point so that the
  43. * bootloader can check for a resumeable image. */
  44. .word 0x2bedf00d
  45. /* s3c_cpu_reusme
  46. *
  47. * This is the entry point, stored by whatever method the bootloader
  48. * requires to get the kernel runnign again. This code expects to be
  49. * entered with no caches live and the MMU disabled. It will then
  50. * restore the MMU and other basic CP registers saved and restart
  51. * the kernel C code to finish the resume code.
  52. */
  53. ENTRY(s3c_cpu_resume)
  54. msr cpsr_c, #PSR_I_BIT | PSR_F_BIT | SVC_MODE
  55. ldr r2, =LL_UART /* for debug */
  56. #ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK
  57. /* Initialise the GPIO state if we are debugging via the SMDK LEDs,
  58. * as the uboot version supplied resets these to inputs during the
  59. * resume checks.
  60. */
  61. ldr r3, =S3C64XX_PA_GPIO
  62. ldr r0, [ r3, #S3C64XX_GPNCON ]
  63. bic r0, r0, #(S3C64XX_GPN_CONMASK(12) | S3C64XX_GPN_CONMASK(13) | \
  64. S3C64XX_GPN_CONMASK(14) | S3C64XX_GPN_CONMASK(15))
  65. orr r0, r0, #(S3C64XX_GPN_OUTPUT(12) | S3C64XX_GPN_OUTPUT(13) | \
  66. S3C64XX_GPN_OUTPUT(14) | S3C64XX_GPN_OUTPUT(15))
  67. str r0, [ r3, #S3C64XX_GPNCON ]
  68. ldr r0, [ r3, #S3C64XX_GPNDAT ]
  69. bic r0, r0, #0xf << 12 @ GPN12..15
  70. orr r0, r0, #1 << 15 @ GPN15
  71. str r0, [ r3, #S3C64XX_GPNDAT ]
  72. #endif
  73. b cpu_resume