diff options
author | Jean Pihet <j-pihet@ti.com> | 2011-02-02 10:38:06 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-02-04 09:26:08 -0500 |
commit | b6338bdc8305b27688a7feb8689e4ccfd42f0292 (patch) | |
tree | 2854dda3c50899b00cb7b302b06d2ba6fd03cdb2 /arch/arm | |
parent | 5756e9dd0de6d5c307773f8f734c0684b3098fdd (diff) |
ARM: 6649/1: omap: use fncpy to copy the PM code functions to SRAM
The new fncpy API is better suited* for copying some
code to SRAM at runtime. This patch changes the ad-hoc
code to the more generic fncpy API.
*: 1. fncpy ensures that the thumb mode bit is propagated,
2. fncpy provides the security of type safety between the
original function and the sram function pointer.
Tested OK on OMAP3 in low power modes (RET/OFF)
using omap2plus_defconfig with !CONFIG_THUMB2_KERNEL.
Compile tested on OMAP1/2 using omap1_defconfig.
Boot tested on OMAP1 & OMAP2
Tested OK with suspend/resume on OMAP2420/n810
Boots fine on osk5912 and n800
Signed-off-by: Jean Pihet <j-pihet@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Dave Martin <dave.martin@linaro.org>
Tested-by: Kevin Hilman <khilman@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-omap1/pm.h | 6 | ||||
-rw-r--r-- | arch/arm/mach-omap1/sleep.S | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap1/sram.S | 1 | ||||
-rw-r--r-- | arch/arm/mach-omap2/pm.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/sleep24xx.S | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/sleep34xx.S | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/sram242x.S | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/sram243x.S | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/sram34xx.S | 1 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/sram.h | 14 | ||||
-rw-r--r-- | arch/arm/plat-omap/sram.c | 14 |
11 files changed, 41 insertions, 10 deletions
diff --git a/arch/arm/mach-omap1/pm.h b/arch/arm/mach-omap1/pm.h index 56a647986ae9..cd926dcb5e7f 100644 --- a/arch/arm/mach-omap1/pm.h +++ b/arch/arm/mach-omap1/pm.h | |||
@@ -123,9 +123,9 @@ extern void allow_idle_sleep(void); | |||
123 | extern void omap1_pm_idle(void); | 123 | extern void omap1_pm_idle(void); |
124 | extern void omap1_pm_suspend(void); | 124 | extern void omap1_pm_suspend(void); |
125 | 125 | ||
126 | extern void omap7xx_cpu_suspend(unsigned short, unsigned short); | 126 | extern void omap7xx_cpu_suspend(unsigned long, unsigned long); |
127 | extern void omap1510_cpu_suspend(unsigned short, unsigned short); | 127 | extern void omap1510_cpu_suspend(unsigned long, unsigned long); |
128 | extern void omap1610_cpu_suspend(unsigned short, unsigned short); | 128 | extern void omap1610_cpu_suspend(unsigned long, unsigned long); |
129 | extern void omap7xx_idle_loop_suspend(void); | 129 | extern void omap7xx_idle_loop_suspend(void); |
130 | extern void omap1510_idle_loop_suspend(void); | 130 | extern void omap1510_idle_loop_suspend(void); |
131 | extern void omap1610_idle_loop_suspend(void); | 131 | extern void omap1610_idle_loop_suspend(void); |
diff --git a/arch/arm/mach-omap1/sleep.S b/arch/arm/mach-omap1/sleep.S index ef771ce8b030..c875bdc902c5 100644 --- a/arch/arm/mach-omap1/sleep.S +++ b/arch/arm/mach-omap1/sleep.S | |||
@@ -58,6 +58,7 @@ | |||
58 | */ | 58 | */ |
59 | 59 | ||
60 | #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) | 60 | #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) |
61 | .align 3 | ||
61 | ENTRY(omap7xx_cpu_suspend) | 62 | ENTRY(omap7xx_cpu_suspend) |
62 | 63 | ||
63 | @ save registers on stack | 64 | @ save registers on stack |
@@ -137,6 +138,7 @@ ENTRY(omap7xx_cpu_suspend_sz) | |||
137 | #endif /* CONFIG_ARCH_OMAP730 || CONFIG_ARCH_OMAP850 */ | 138 | #endif /* CONFIG_ARCH_OMAP730 || CONFIG_ARCH_OMAP850 */ |
138 | 139 | ||
139 | #ifdef CONFIG_ARCH_OMAP15XX | 140 | #ifdef CONFIG_ARCH_OMAP15XX |
141 | .align 3 | ||
140 | ENTRY(omap1510_cpu_suspend) | 142 | ENTRY(omap1510_cpu_suspend) |
141 | 143 | ||
142 | @ save registers on stack | 144 | @ save registers on stack |
@@ -211,6 +213,7 @@ ENTRY(omap1510_cpu_suspend_sz) | |||
211 | #endif /* CONFIG_ARCH_OMAP15XX */ | 213 | #endif /* CONFIG_ARCH_OMAP15XX */ |
212 | 214 | ||
213 | #if defined(CONFIG_ARCH_OMAP16XX) | 215 | #if defined(CONFIG_ARCH_OMAP16XX) |
216 | .align 3 | ||
214 | ENTRY(omap1610_cpu_suspend) | 217 | ENTRY(omap1610_cpu_suspend) |
215 | 218 | ||
216 | @ save registers on stack | 219 | @ save registers on stack |
diff --git a/arch/arm/mach-omap1/sram.S b/arch/arm/mach-omap1/sram.S index 7724e520d07c..692587d07ea5 100644 --- a/arch/arm/mach-omap1/sram.S +++ b/arch/arm/mach-omap1/sram.S | |||
@@ -18,6 +18,7 @@ | |||
18 | /* | 18 | /* |
19 | * Reprograms ULPD and CKCTL. | 19 | * Reprograms ULPD and CKCTL. |
20 | */ | 20 | */ |
21 | .align 3 | ||
21 | ENTRY(omap1_sram_reprogram_clock) | 22 | ENTRY(omap1_sram_reprogram_clock) |
22 | stmfd sp!, {r0 - r12, lr} @ save registers on stack | 23 | stmfd sp!, {r0 - r12, lr} @ save registers on stack |
23 | 24 | ||
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h index 1c1b0ab5b978..39580e6060e8 100644 --- a/arch/arm/mach-omap2/pm.h +++ b/arch/arm/mach-omap2/pm.h | |||
@@ -92,7 +92,7 @@ extern void omap24xx_idle_loop_suspend(void); | |||
92 | extern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem *sdrc_dlla_ctrl, | 92 | extern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem *sdrc_dlla_ctrl, |
93 | void __iomem *sdrc_power); | 93 | void __iomem *sdrc_power); |
94 | extern void omap34xx_cpu_suspend(u32 *addr, int save_state); | 94 | extern void omap34xx_cpu_suspend(u32 *addr, int save_state); |
95 | extern void save_secure_ram_context(u32 *addr); | 95 | extern int save_secure_ram_context(u32 *addr); |
96 | extern void omap3_save_scratchpad_contents(void); | 96 | extern void omap3_save_scratchpad_contents(void); |
97 | 97 | ||
98 | extern unsigned int omap24xx_idle_loop_suspend_sz; | 98 | extern unsigned int omap24xx_idle_loop_suspend_sz; |
diff --git a/arch/arm/mach-omap2/sleep24xx.S b/arch/arm/mach-omap2/sleep24xx.S index c7780cc8d919..b5071a47ec39 100644 --- a/arch/arm/mach-omap2/sleep24xx.S +++ b/arch/arm/mach-omap2/sleep24xx.S | |||
@@ -47,6 +47,7 @@ | |||
47 | * Note: This code get's copied to internal SRAM at boot. When the OMAP | 47 | * Note: This code get's copied to internal SRAM at boot. When the OMAP |
48 | * wakes up it continues execution at the point it went to sleep. | 48 | * wakes up it continues execution at the point it went to sleep. |
49 | */ | 49 | */ |
50 | .align 3 | ||
50 | ENTRY(omap24xx_idle_loop_suspend) | 51 | ENTRY(omap24xx_idle_loop_suspend) |
51 | stmfd sp!, {r0, lr} @ save registers on stack | 52 | stmfd sp!, {r0, lr} @ save registers on stack |
52 | mov r0, #0 @ clear for mcr setup | 53 | mov r0, #0 @ clear for mcr setup |
@@ -82,6 +83,7 @@ ENTRY(omap24xx_idle_loop_suspend_sz) | |||
82 | * The DLL load value is not kept in RETENTION or OFF. It needs to be restored | 83 | * The DLL load value is not kept in RETENTION or OFF. It needs to be restored |
83 | * at wake | 84 | * at wake |
84 | */ | 85 | */ |
86 | .align 3 | ||
85 | ENTRY(omap24xx_cpu_suspend) | 87 | ENTRY(omap24xx_cpu_suspend) |
86 | stmfd sp!, {r0 - r12, lr} @ save registers on stack | 88 | stmfd sp!, {r0 - r12, lr} @ save registers on stack |
87 | mov r3, #0x0 @ clear for mcr call | 89 | mov r3, #0x0 @ clear for mcr call |
diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S index 98d8232808b8..951a0be66cf7 100644 --- a/arch/arm/mach-omap2/sleep34xx.S +++ b/arch/arm/mach-omap2/sleep34xx.S | |||
@@ -118,6 +118,7 @@ ENTRY(enable_omap3630_toggle_l2_on_restore) | |||
118 | 118 | ||
119 | .text | 119 | .text |
120 | /* Function to call rom code to save secure ram context */ | 120 | /* Function to call rom code to save secure ram context */ |
121 | .align 3 | ||
121 | ENTRY(save_secure_ram_context) | 122 | ENTRY(save_secure_ram_context) |
122 | stmfd sp!, {r1-r12, lr} @ save registers on stack | 123 | stmfd sp!, {r1-r12, lr} @ save registers on stack |
123 | adr r3, api_params @ r3 points to parameters | 124 | adr r3, api_params @ r3 points to parameters |
@@ -169,6 +170,7 @@ ENTRY(save_secure_ram_context_sz) | |||
169 | * depending on the low power mode (non-OFF vs OFF modes), | 170 | * depending on the low power mode (non-OFF vs OFF modes), |
170 | * cf. 'Resume path for xxx mode' comments. | 171 | * cf. 'Resume path for xxx mode' comments. |
171 | */ | 172 | */ |
173 | .align 3 | ||
172 | ENTRY(omap34xx_cpu_suspend) | 174 | ENTRY(omap34xx_cpu_suspend) |
173 | stmfd sp!, {r0-r12, lr} @ save registers on stack | 175 | stmfd sp!, {r0-r12, lr} @ save registers on stack |
174 | 176 | ||
diff --git a/arch/arm/mach-omap2/sram242x.S b/arch/arm/mach-omap2/sram242x.S index 055310cc77de..ff9b9dbcb30e 100644 --- a/arch/arm/mach-omap2/sram242x.S +++ b/arch/arm/mach-omap2/sram242x.S | |||
@@ -39,6 +39,7 @@ | |||
39 | 39 | ||
40 | .text | 40 | .text |
41 | 41 | ||
42 | .align 3 | ||
42 | ENTRY(omap242x_sram_ddr_init) | 43 | ENTRY(omap242x_sram_ddr_init) |
43 | stmfd sp!, {r0 - r12, lr} @ save registers on stack | 44 | stmfd sp!, {r0 - r12, lr} @ save registers on stack |
44 | 45 | ||
@@ -143,6 +144,7 @@ ENTRY(omap242x_sram_ddr_init_sz) | |||
143 | * r0 = [PRCM_FULL | PRCM_HALF] r1 = SDRC_DLLA_CTRL value r2 = [DDR | SDR] | 144 | * r0 = [PRCM_FULL | PRCM_HALF] r1 = SDRC_DLLA_CTRL value r2 = [DDR | SDR] |
144 | * PRCM_FULL = 2, PRCM_HALF = 1, DDR = 1, SDR = 0 | 145 | * PRCM_FULL = 2, PRCM_HALF = 1, DDR = 1, SDR = 0 |
145 | */ | 146 | */ |
147 | .align 3 | ||
146 | ENTRY(omap242x_sram_reprogram_sdrc) | 148 | ENTRY(omap242x_sram_reprogram_sdrc) |
147 | stmfd sp!, {r0 - r10, lr} @ save registers on stack | 149 | stmfd sp!, {r0 - r10, lr} @ save registers on stack |
148 | mov r3, #0x0 @ clear for mrc call | 150 | mov r3, #0x0 @ clear for mrc call |
@@ -238,6 +240,7 @@ ENTRY(omap242x_sram_reprogram_sdrc_sz) | |||
238 | /* | 240 | /* |
239 | * Set dividers and pll. Also recalculate DLL value for DDR and unlock mode. | 241 | * Set dividers and pll. Also recalculate DLL value for DDR and unlock mode. |
240 | */ | 242 | */ |
243 | .align 3 | ||
241 | ENTRY(omap242x_sram_set_prcm) | 244 | ENTRY(omap242x_sram_set_prcm) |
242 | stmfd sp!, {r0-r12, lr} @ regs to stack | 245 | stmfd sp!, {r0-r12, lr} @ regs to stack |
243 | adr r4, pbegin @ addr of preload start | 246 | adr r4, pbegin @ addr of preload start |
diff --git a/arch/arm/mach-omap2/sram243x.S b/arch/arm/mach-omap2/sram243x.S index f9007580aea3..76730209fa0e 100644 --- a/arch/arm/mach-omap2/sram243x.S +++ b/arch/arm/mach-omap2/sram243x.S | |||
@@ -39,6 +39,7 @@ | |||
39 | 39 | ||
40 | .text | 40 | .text |
41 | 41 | ||
42 | .align 3 | ||
42 | ENTRY(omap243x_sram_ddr_init) | 43 | ENTRY(omap243x_sram_ddr_init) |
43 | stmfd sp!, {r0 - r12, lr} @ save registers on stack | 44 | stmfd sp!, {r0 - r12, lr} @ save registers on stack |
44 | 45 | ||
@@ -143,6 +144,7 @@ ENTRY(omap243x_sram_ddr_init_sz) | |||
143 | * r0 = [PRCM_FULL | PRCM_HALF] r1 = SDRC_DLLA_CTRL value r2 = [DDR | SDR] | 144 | * r0 = [PRCM_FULL | PRCM_HALF] r1 = SDRC_DLLA_CTRL value r2 = [DDR | SDR] |
144 | * PRCM_FULL = 2, PRCM_HALF = 1, DDR = 1, SDR = 0 | 145 | * PRCM_FULL = 2, PRCM_HALF = 1, DDR = 1, SDR = 0 |
145 | */ | 146 | */ |
147 | .align 3 | ||
146 | ENTRY(omap243x_sram_reprogram_sdrc) | 148 | ENTRY(omap243x_sram_reprogram_sdrc) |
147 | stmfd sp!, {r0 - r10, lr} @ save registers on stack | 149 | stmfd sp!, {r0 - r10, lr} @ save registers on stack |
148 | mov r3, #0x0 @ clear for mrc call | 150 | mov r3, #0x0 @ clear for mrc call |
@@ -238,6 +240,7 @@ ENTRY(omap243x_sram_reprogram_sdrc_sz) | |||
238 | /* | 240 | /* |
239 | * Set dividers and pll. Also recalculate DLL value for DDR and unlock mode. | 241 | * Set dividers and pll. Also recalculate DLL value for DDR and unlock mode. |
240 | */ | 242 | */ |
243 | .align 3 | ||
241 | ENTRY(omap243x_sram_set_prcm) | 244 | ENTRY(omap243x_sram_set_prcm) |
242 | stmfd sp!, {r0-r12, lr} @ regs to stack | 245 | stmfd sp!, {r0-r12, lr} @ regs to stack |
243 | adr r4, pbegin @ addr of preload start | 246 | adr r4, pbegin @ addr of preload start |
diff --git a/arch/arm/mach-omap2/sram34xx.S b/arch/arm/mach-omap2/sram34xx.S index 7f893a29d500..25011ca2145d 100644 --- a/arch/arm/mach-omap2/sram34xx.S +++ b/arch/arm/mach-omap2/sram34xx.S | |||
@@ -111,6 +111,7 @@ | |||
111 | * since it will cause the ARM MMU to attempt to walk the page tables. | 111 | * since it will cause the ARM MMU to attempt to walk the page tables. |
112 | * These crashes may be intermittent. | 112 | * These crashes may be intermittent. |
113 | */ | 113 | */ |
114 | .align 3 | ||
114 | ENTRY(omap3_sram_configure_core_dpll) | 115 | ENTRY(omap3_sram_configure_core_dpll) |
115 | stmfd sp!, {r1-r12, lr} @ store regs to stack | 116 | stmfd sp!, {r1-r12, lr} @ store regs to stack |
116 | 117 | ||
diff --git a/arch/arm/plat-omap/include/plat/sram.h b/arch/arm/plat-omap/include/plat/sram.h index 9967d5e855c7..f500fc34d065 100644 --- a/arch/arm/plat-omap/include/plat/sram.h +++ b/arch/arm/plat-omap/include/plat/sram.h | |||
@@ -12,7 +12,19 @@ | |||
12 | #define __ARCH_ARM_OMAP_SRAM_H | 12 | #define __ARCH_ARM_OMAP_SRAM_H |
13 | 13 | ||
14 | #ifndef __ASSEMBLY__ | 14 | #ifndef __ASSEMBLY__ |
15 | extern void * omap_sram_push(void * start, unsigned long size); | 15 | #include <asm/fncpy.h> |
16 | |||
17 | extern void *omap_sram_push_address(unsigned long size); | ||
18 | |||
19 | /* Macro to push a function to the internal SRAM, using the fncpy API */ | ||
20 | #define omap_sram_push(funcp, size) ({ \ | ||
21 | typeof(&(funcp)) _res = NULL; \ | ||
22 | void *_sram_address = omap_sram_push_address(size); \ | ||
23 | if (_sram_address) \ | ||
24 | _res = fncpy(_sram_address, &(funcp), size); \ | ||
25 | _res; \ | ||
26 | }) | ||
27 | |||
16 | extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl); | 28 | extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl); |
17 | 29 | ||
18 | extern void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl, | 30 | extern void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl, |
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c index e26e50487d60..68fcc7dc56e7 100644 --- a/arch/arm/plat-omap/sram.c +++ b/arch/arm/plat-omap/sram.c | |||
@@ -242,7 +242,14 @@ static void __init omap_map_sram(void) | |||
242 | omap_sram_size - SRAM_BOOTLOADER_SZ); | 242 | omap_sram_size - SRAM_BOOTLOADER_SZ); |
243 | } | 243 | } |
244 | 244 | ||
245 | void * omap_sram_push(void * start, unsigned long size) | 245 | /* |
246 | * Memory allocator for SRAM: calculates the new ceiling address | ||
247 | * for pushing a function using the fncpy API. | ||
248 | * | ||
249 | * Note that fncpy requires the returned address to be aligned | ||
250 | * to an 8-byte boundary. | ||
251 | */ | ||
252 | void *omap_sram_push_address(unsigned long size) | ||
246 | { | 253 | { |
247 | if (size > (omap_sram_ceil - (omap_sram_base + SRAM_BOOTLOADER_SZ))) { | 254 | if (size > (omap_sram_ceil - (omap_sram_base + SRAM_BOOTLOADER_SZ))) { |
248 | printk(KERN_ERR "Not enough space in SRAM\n"); | 255 | printk(KERN_ERR "Not enough space in SRAM\n"); |
@@ -250,10 +257,7 @@ void * omap_sram_push(void * start, unsigned long size) | |||
250 | } | 257 | } |
251 | 258 | ||
252 | omap_sram_ceil -= size; | 259 | omap_sram_ceil -= size; |
253 | omap_sram_ceil = ROUND_DOWN(omap_sram_ceil, sizeof(void *)); | 260 | omap_sram_ceil = ROUND_DOWN(omap_sram_ceil, FNCPY_ALIGN); |
254 | memcpy((void *)omap_sram_ceil, start, size); | ||
255 | flush_icache_range((unsigned long)omap_sram_ceil, | ||
256 | (unsigned long)(omap_sram_ceil + size)); | ||
257 | 261 | ||
258 | return (void *)omap_sram_ceil; | 262 | return (void *)omap_sram_ceil; |
259 | } | 263 | } |