[ARM] 4489/1: pxa: split pxa_cpu_suspend to processor specific ones

1. split pxa_cpu_suspend to pxa25x_cpu_suspend and pxa27x_cpu_suspend
and make pxa25x_cpu_pm_enter() and pxa27x_cpu_pm_enter() to invoke
the corresponding _suspend functions, thus remove all those ugly
#ifdef .. #endif out of sleep.S

2. move the declarations of those suspend functions to pm.h

note: this is not a clean enough solution until all the pxa25x and
pxa27x specific part is further removed out of sleep.S, sleep.S is
supposed to contain generic code only

Signed-off-by: eric miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Eric Miao and committed by Russell King b750a093 711be5cc

+80 -46
+1 -4
arch/arm/mach-pxa/pxa25x.c
··· 180 181 static void pxa25x_cpu_pm_enter(suspend_state_t state) 182 { 183 - extern void pxa_cpu_suspend(unsigned int); 184 - extern void pxa_cpu_resume(void); 185 - 186 CKEN = 0; 187 188 switch (state) { 189 case PM_SUSPEND_MEM: 190 /* set resume return address */ 191 PSPR = virt_to_phys(pxa_cpu_resume); 192 - pxa_cpu_suspend(PWRMODE_SLEEP); 193 break; 194 } 195 }
··· 180 181 static void pxa25x_cpu_pm_enter(suspend_state_t state) 182 { 183 CKEN = 0; 184 185 switch (state) { 186 case PM_SUSPEND_MEM: 187 /* set resume return address */ 188 PSPR = virt_to_phys(pxa_cpu_resume); 189 + pxa25x_cpu_suspend(PWRMODE_SLEEP); 190 break; 191 } 192 }
+1 -3
arch/arm/mach-pxa/pxa27x.c
··· 223 void pxa27x_cpu_pm_enter(suspend_state_t state) 224 { 225 extern void pxa_cpu_standby(void); 226 - extern void pxa_cpu_suspend(unsigned int); 227 - extern void pxa_cpu_resume(void); 228 229 if (state == PM_SUSPEND_STANDBY) 230 CKEN = (1 << CKEN_MEMC) | (1 << CKEN_OSTIMER) | ··· 243 case PM_SUSPEND_MEM: 244 /* set resume return address */ 245 PSPR = virt_to_phys(pxa_cpu_resume); 246 - pxa_cpu_suspend(PWRMODE_SLEEP); 247 break; 248 } 249 }
··· 223 void pxa27x_cpu_pm_enter(suspend_state_t state) 224 { 225 extern void pxa_cpu_standby(void); 226 227 if (state == PM_SUSPEND_STANDBY) 228 CKEN = (1 << CKEN_MEMC) | (1 << CKEN_OSTIMER) | ··· 245 case PM_SUSPEND_MEM: 246 /* set resume return address */ 247 PSPR = virt_to_phys(pxa_cpu_resume); 248 + pxa27x_cpu_suspend(PWRMODE_SLEEP); 249 break; 250 } 251 }
+73 -39
arch/arm/mach-pxa/sleep.S
··· 17 18 #include <asm/arch/pxa-regs.h> 19 20 - #ifdef CONFIG_PXA27x // workaround for Errata 50 21 #define MDREFR_KDIV 0x200a4000 // all banks 22 #define CCCR_SLEEP 0x00000107 // L=7 2N=2 A=0 PPDIS=0 CPDIS=0 23 - #endif 24 25 .text 26 27 - /* 28 - * pxa_cpu_suspend() 29 - * 30 - * Forces CPU into sleep state. 31 - * 32 - * r0 = value for PWRMODE M field for desired sleep state 33 - */ 34 - 35 - ENTRY(pxa_cpu_suspend) 36 - 37 - #ifndef CONFIG_IWMMXT 38 - mra r2, r3, acc0 39 - #endif 40 - stmfd sp!, {r2 - r12, lr} @ save registers on stack 41 - 42 @ get coprocessor registers 43 mrc p14, 0, r3, c6, c0, 0 @ clock configuration, for turbo mode 44 mrc p15, 0, r4, c15, c1, 0 @ CP access reg ··· 38 mov r10, sp 39 stmfd sp!, {r3 - r10} 40 41 - mov r5, r0 @ save sleep mode 42 @ preserve phys address of stack 43 mov r0, sp 44 bl sleep_phys_sp 45 ldr r1, =sleep_save_sp 46 str r0, [r1] 47 48 @ clean data cache 49 bl xscale_flush_kern_cache_all ··· 88 @ enable SDRAM self-refresh mode 89 orr r5, r5, #MDREFR_SLFRSH 90 91 - #ifdef CONFIG_PXA27x 92 @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50) 93 ldr r6, =MDREFR_KDIV 94 orr r5, r5, r6 95 - #endif 96 97 - #ifdef CONFIG_PXA25x 98 @ Intel PXA255 Specification Update notes problems 99 @ about suspending with PXBus operating above 133MHz 100 @ (see Errata 31, GPIO output signals, ... unpredictable in sleep ··· 168 mov r0, #0 169 mcr p14, 0, r0, c6, c0, 0 170 orr r0, r0, #2 @ initiate change bit 171 - #endif 172 - #ifdef CONFIG_PXA27x 173 - @ Intel PXA270 Specification Update notes problems sleeping 174 - @ with core operating above 91 MHz 175 - @ (see Errata 50, ...processor does not exit from sleep...) 176 - 177 - ldr r6, =CCCR 178 - ldr r8, [r6] @ keep original value for resume 179 - 180 - ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value 181 - mov r0, #0x2 @ prepare value for CLKCFG 182 - #endif 183 - 184 - @ align execution to a cache line 185 - b 1f 186 187 .ltorg 188 .align 5 189 - 1: 190 191 @ All needed values are now in registers. 192 @ These last instructions should be in cache 193 194 - #if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x) 195 @ initiate the frequency change... 196 str r7, [r6] 197 mcr p14, 0, r0, c6, c0, 0 ··· 190 mov r0, #42 191 10: subs r0, r0, #1 192 bne 10b 193 - #endif 194 195 @ Do not reorder... 196 @ Intel PXA270 Specification Update notes problems performing
··· 17 18 #include <asm/arch/pxa-regs.h> 19 20 #define MDREFR_KDIV 0x200a4000 // all banks 21 #define CCCR_SLEEP 0x00000107 // L=7 2N=2 A=0 PPDIS=0 CPDIS=0 22 23 .text 24 25 + pxa_cpu_save_cp: 26 @ get coprocessor registers 27 mrc p14, 0, r3, c6, c0, 0 @ clock configuration, for turbo mode 28 mrc p15, 0, r4, c15, c1, 0 @ CP access reg ··· 54 mov r10, sp 55 stmfd sp!, {r3 - r10} 56 57 + mov pc, lr 58 + 59 + pxa_cpu_save_sp: 60 @ preserve phys address of stack 61 mov r0, sp 62 + mov r2, lr 63 bl sleep_phys_sp 64 ldr r1, =sleep_save_sp 65 str r0, [r1] 66 + mov pc, r2 67 + 68 + /* 69 + * pxa27x_cpu_suspend() 70 + * 71 + * Forces CPU into sleep state. 72 + * 73 + * r0 = value for PWRMODE M field for desired sleep state 74 + */ 75 + 76 + ENTRY(pxa27x_cpu_suspend) 77 + 78 + #ifndef CONFIG_IWMMXT 79 + mra r2, r3, acc0 80 + #endif 81 + stmfd sp!, {r2 - r12, lr} @ save registers on stack 82 + 83 + bl pxa_cpu_save_cp 84 + 85 + mov r5, r0 @ save sleep mode 86 + bl pxa_cpu_save_sp 87 88 @ clean data cache 89 bl xscale_flush_kern_cache_all ··· 80 @ enable SDRAM self-refresh mode 81 orr r5, r5, #MDREFR_SLFRSH 82 83 @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50) 84 ldr r6, =MDREFR_KDIV 85 orr r5, r5, r6 86 87 + @ Intel PXA270 Specification Update notes problems sleeping 88 + @ with core operating above 91 MHz 89 + @ (see Errata 50, ...processor does not exit from sleep...) 90 + 91 + ldr r6, =CCCR 92 + ldr r8, [r6] @ keep original value for resume 93 + 94 + ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value 95 + mov r0, #0x2 @ prepare value for CLKCFG 96 + 97 + @ align execution to a cache line 98 + b pxa_cpu_do_suspend 99 + 100 + /* 101 + * pxa27x_cpu_suspend() 102 + * 103 + * Forces CPU into sleep state. 104 + * 105 + * r0 = value for PWRMODE M field for desired sleep state 106 + */ 107 + 108 + ENTRY(pxa25x_cpu_suspend) 109 + stmfd sp!, {r2 - r12, lr} @ save registers on stack 110 + 111 + bl pxa_cpu_save_cp 112 + 113 + mov r5, r0 @ save sleep mode 114 + bl pxa_cpu_save_sp 115 + 116 + @ clean data cache 117 + bl xscale_flush_kern_cache_all 118 + 119 + @ prepare value for sleep mode 120 + mov r1, r5 @ sleep mode 121 + 122 + @ prepare pointer to physical address 0 (virtual mapping in generic.c) 123 + mov r2, #UNCACHED_PHYS_0 124 + 125 + @ prepare SDRAM refresh settings 126 + ldr r4, =MDREFR 127 + ldr r5, [r4] 128 + 129 + @ enable SDRAM self-refresh mode 130 + orr r5, r5, #MDREFR_SLFRSH 131 + 132 @ Intel PXA255 Specification Update notes problems 133 @ about suspending with PXBus operating above 133MHz 134 @ (see Errata 31, GPIO output signals, ... unpredictable in sleep ··· 118 mov r0, #0 119 mcr p14, 0, r0, c6, c0, 0 120 orr r0, r0, #2 @ initiate change bit 121 + b pxa_cpu_do_suspend 122 123 .ltorg 124 .align 5 125 + pxa_cpu_do_suspend: 126 127 @ All needed values are now in registers. 128 @ These last instructions should be in cache 129 130 @ initiate the frequency change... 131 str r7, [r6] 132 mcr p14, 0, r0, c6, c0, 0 ··· 155 mov r0, #42 156 10: subs r0, r0, #1 157 bne 10b 158 159 @ Do not reorder... 160 @ Intel PXA270 Specification Update notes problems performing
+5
include/asm-arm/arch-pxa/pm.h
··· 17 18 extern struct pxa_cpu_pm_fns *pxa_cpu_pm_fns; 19 20 extern int pxa_pm_enter(suspend_state_t state);
··· 17 18 extern struct pxa_cpu_pm_fns *pxa_cpu_pm_fns; 19 20 + /* sleep.S */ 21 + extern void pxa25x_cpu_suspend(unsigned int); 22 + extern void pxa27x_cpu_suspend(unsigned int); 23 + extern void pxa_cpu_resume(void); 24 + 25 extern int pxa_pm_enter(suspend_state_t state);