Ben Dooks | 3501c9a | 2010-01-26 10:45:40 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/plat-s3c64xx/sleep.S |
Ben Dooks | bd117bd | 2009-03-10 18:19:35 +0000 | [diff] [blame] | 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 | |
| 15 | #include <linux/linkage.h> |
| 16 | #include <asm/assembler.h> |
| 17 | #include <mach/map.h> |
| 18 | |
| 19 | #undef S3C64XX_VA_GPIO |
| 20 | #define S3C64XX_VA_GPIO (0x0) |
| 21 | |
Ben Dooks | 3501c9a | 2010-01-26 10:45:40 +0900 | [diff] [blame] | 22 | #include <mach/regs-gpio.h> |
Ben Dooks | bd117bd | 2009-03-10 18:19:35 +0000 | [diff] [blame] | 23 | |
| 24 | #define LL_UART (S3C_PA_UART + (0x400 * CONFIG_S3C_LOWLEVEL_UART_PORT)) |
| 25 | |
| 26 | .text |
| 27 | |
| 28 | /* s3c_cpu_save |
| 29 | * |
| 30 | * Save enough processor state to allow the restart of the pm.c |
| 31 | * code after resume. |
| 32 | * |
| 33 | * entry: |
Russell King | 2e2f3d3 | 2011-02-06 17:39:31 +0000 | [diff] [blame] | 34 | * r1 = v:p offset |
Ben Dooks | bd117bd | 2009-03-10 18:19:35 +0000 | [diff] [blame] | 35 | */ |
| 36 | |
| 37 | ENTRY(s3c_cpu_save) |
| 38 | stmfd sp!, { r4 - r12, lr } |
Russell King | 2e2f3d3 | 2011-02-06 17:39:31 +0000 | [diff] [blame] | 39 | ldr r3, =resume_with_mmu |
| 40 | bl cpu_suspend |
Ben Dooks | bd117bd | 2009-03-10 18:19:35 +0000 | [diff] [blame] | 41 | |
| 42 | @@ call final suspend code |
| 43 | ldr r0, =pm_cpu_sleep |
| 44 | ldr pc, [r0] |
| 45 | |
| 46 | @@ return to the caller, after the MMU is turned on. |
| 47 | @@ restore the last bits of the stack and return. |
| 48 | resume_with_mmu: |
| 49 | ldmfd sp!, { r4 - r12, pc } @ return, from sp from s3c_cpu_save |
| 50 | |
Ben Dooks | bd117bd | 2009-03-10 18:19:35 +0000 | [diff] [blame] | 51 | /* Sleep magic, the word before the resume entry point so that the |
| 52 | * bootloader can check for a resumeable image. */ |
| 53 | |
| 54 | .word 0x2bedf00d |
| 55 | |
| 56 | /* s3c_cpu_reusme |
| 57 | * |
| 58 | * This is the entry point, stored by whatever method the bootloader |
| 59 | * requires to get the kernel runnign again. This code expects to be |
| 60 | * entered with no caches live and the MMU disabled. It will then |
| 61 | * restore the MMU and other basic CP registers saved and restart |
| 62 | * the kernel C code to finish the resume code. |
| 63 | */ |
| 64 | |
| 65 | ENTRY(s3c_cpu_resume) |
| 66 | msr cpsr_c, #PSR_I_BIT | PSR_F_BIT | SVC_MODE |
| 67 | ldr r2, =LL_UART /* for debug */ |
| 68 | |
| 69 | #ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK |
Joonyoung Shim | 3185847 | 2011-05-06 09:37:17 +0900 | [diff] [blame] | 70 | |
| 71 | #define S3C64XX_GPNCON (S3C64XX_GPN_BASE + 0x00) |
| 72 | #define S3C64XX_GPNDAT (S3C64XX_GPN_BASE + 0x04) |
| 73 | |
| 74 | #define S3C64XX_GPN_CONMASK(__gpio) (0x3 << ((__gpio) * 2)) |
| 75 | #define S3C64XX_GPN_OUTPUT(__gpio) (0x1 << ((__gpio) * 2)) |
| 76 | |
Ben Dooks | bd117bd | 2009-03-10 18:19:35 +0000 | [diff] [blame] | 77 | /* Initialise the GPIO state if we are debugging via the SMDK LEDs, |
| 78 | * as the uboot version supplied resets these to inputs during the |
| 79 | * resume checks. |
| 80 | */ |
| 81 | |
| 82 | ldr r3, =S3C64XX_PA_GPIO |
| 83 | ldr r0, [ r3, #S3C64XX_GPNCON ] |
| 84 | bic r0, r0, #(S3C64XX_GPN_CONMASK(12) | S3C64XX_GPN_CONMASK(13) | \ |
| 85 | S3C64XX_GPN_CONMASK(14) | S3C64XX_GPN_CONMASK(15)) |
| 86 | orr r0, r0, #(S3C64XX_GPN_OUTPUT(12) | S3C64XX_GPN_OUTPUT(13) | \ |
| 87 | S3C64XX_GPN_OUTPUT(14) | S3C64XX_GPN_OUTPUT(15)) |
| 88 | str r0, [ r3, #S3C64XX_GPNCON ] |
| 89 | |
| 90 | ldr r0, [ r3, #S3C64XX_GPNDAT ] |
| 91 | bic r0, r0, #0xf << 12 @ GPN12..15 |
| 92 | orr r0, r0, #1 << 15 @ GPN15 |
| 93 | str r0, [ r3, #S3C64XX_GPNDAT ] |
| 94 | #endif |
Russell King | 2e2f3d3 | 2011-02-06 17:39:31 +0000 | [diff] [blame] | 95 | b cpu_resume |