2 * SA11x0 Assembler Sleep/WakeUp Management Routines
4 * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License.
11 * 2001-02-06: Cliff Brake Initial code
13 * 2001-08-29: Nicolas Pitre Simplified.
15 * 2002-05-27: Nicolas Pitre Revisited, more cleanup and simplification.
16 * Storage is on the stack now.
19 #include <linux/linkage.h>
20 #include <asm/assembler.h>
21 #include <mach/hardware.h>
25 * sa1100_cpu_suspend()
27 * Causes sa11x0 to enter sleep state
31 ENTRY(sa1100_cpu_suspend)
32 stmfd sp!, {r4 - r12, lr} @ save registers on stack
34 ldr r3, =sa1100_cpu_resume @ return function
37 @ disable clock switching
38 mcr p15, 0, r1, c15, c2, 2
40 @ Adjust memory timing before lowering CPU clock
41 @ Clock speed adjustment without changing memory timing makes
42 @ CPU hang in some cases
45 orr r1, r1, #MDREFR_K1DB2
48 @ delay 90us and set CPU PLL to lowest speed
49 @ fixes resume problem on high speed SA1110
59 * SA1110 SDRAM controller workaround. register values:
68 * r7 = first MDREFR value
69 * r8 = second MDREFR value
72 * r11 = third MDREFR value
74 * r13 = PMCR value (1)
82 bic r3, r3, #FMsk(MSC_RT)
83 bic r3, r3, #FMsk(MSC_RT)<<16
86 bic r4, r4, #FMsk(MSC_RT)
87 bic r4, r4, #FMsk(MSC_RT)<<16
90 bic r5, r5, #FMsk(MSC_RT)
91 bic r5, r5, #FMsk(MSC_RT)<<16
96 bic r7, r7, #0x0000FF00
97 bic r7, r7, #0x000000F0
98 orr r8, r7, #MDREFR_SLFRSH
102 bic r10, r10, #(MDCNFG_DE0+MDCNFG_DE1)
103 bic r10, r10, #(MDCNFG_DE2+MDCNFG_DE3)
105 bic r11, r8, #MDREFR_SLFRSH
106 bic r11, r11, #MDREFR_E1PIN
112 b sa1110_sdram_controller_fix
115 sa1110_sdram_controller_fix:
117 @ Step 1 clear RT field of all MSCx registers
122 @ Step 2 clear DRI field in MDREFR
125 @ Step 3 set SLFRSH bit in MDREFR
128 @ Step 4 clear DE bis in MDCNFG
131 @ Step 5 clear DRAM refresh control register
134 @ Wow, now the hardware suspend request pins can be used, that makes them functional for
135 @ about 7 ns out of the entire time that the CPU is running!
137 @ Step 6 set force sleep bit in PMCR
141 20: b 20b @ loop waiting for sleep
144 * cpu_sa1100_resume()
146 * entry point from bootloader into kernel during resume
150 mcr p15, 0, r1, c15, c1, 2 @ enable clock switching
151 ldmfd sp!, {r4 - r12, pc} @ return to caller