aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/pm.h
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2012-01-24 18:56:08 -0500
committerNicolas Ferre <nicolas.ferre@atmel.com>2012-02-03 07:42:19 -0500
commit00482a4078f4ff0dd0638e7f2fd83e34cc402ff7 (patch)
tree71bf0730b78d686385c7a44696dcb21a5f08c8bf /arch/arm/mach-at91/pm.h
parentb59160f6c017bfe33d3483ed9a6120701644af8a (diff)
ARM: at91: implement the standby function for pm/cpuidle
This patch groups the self-refresh on/cpu_do_idle/self-refresh off into a single 'standby' function. The standby routine for rm9200 has been turned into an asm routine to have a better control of the self refresh and to prevent a memory access when running this code. Draining the write buffer is done automatically when switching for the self refresh on sam9, so the instruction is added to the rm9200 only. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Diffstat (limited to 'arch/arm/mach-at91/pm.h')
-rw-r--r--arch/arm/mach-at91/pm.h53
1 files changed, 30 insertions, 23 deletions
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index 38f9a13ee794..bba9ce1aaaec 100644
--- a/arch/arm/mach-at91/pm.h
+++ b/arch/arm/mach-at91/pm.h
@@ -24,17 +24,25 @@
24 * still in self-refresh is "not recommended", but seems to work. 24 * still in self-refresh is "not recommended", but seems to work.
25 */ 25 */
26 26
27static inline u32 sdram_selfrefresh_enable(void) 27static inline void at91rm9200_standby(void)
28{ 28{
29 u32 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR); 29 u32 lpr = at91_sys_read(AT91_SDRAMC_LPR);
30 30
31 at91_sys_write(AT91_SDRAMC_LPR, 0); 31 asm volatile(
32 at91_sys_write(AT91_SDRAMC_SRR, 1); 32 "b 1f\n\t"
33 return saved_lpr; 33 ".align 5\n\t"
34 "1: mcr p15, 0, %0, c7, c10, 4\n\t"
35 " str %0, [%1, %2]\n\t"
36 " str %3, [%1, %4]\n\t"
37 " mcr p15, 0, %0, c7, c0, 4\n\t"
38 " str %5, [%1, %2]"
39 :
40 : "r" (0), "r" (AT91_BASE_SYS), "r" (AT91_SDRAMC_LPR),
41 "r" (1), "r" (AT91_SDRAMC_SRR),
42 "r" (lpr));
34} 43}
35 44
36#define sdram_selfrefresh_disable(saved_lpr) \ 45#define at91_standby at91rm9200_standby
37 at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
38 46
39#elif defined(CONFIG_ARCH_AT91SAM9G45) 47#elif defined(CONFIG_ARCH_AT91SAM9G45)
40#include <mach/at91sam9_ddrsdr.h> 48#include <mach/at91sam9_ddrsdr.h>
@@ -42,14 +50,12 @@ static inline u32 sdram_selfrefresh_enable(void)
42/* We manage both DDRAM/SDRAM controllers, we need more than one value to 50/* We manage both DDRAM/SDRAM controllers, we need more than one value to
43 * remember. 51 * remember.
44 */ 52 */
45static u32 saved_lpr1; 53static inline void at91sam9g45_standby(void)
46
47static inline u32 sdram_selfrefresh_enable(void)
48{ 54{
49 /* Those tow values allow us to delay self-refresh activation 55 /* Those two values allow us to delay self-refresh activation
50 * to the maximum. */ 56 * to the maximum. */
51 u32 lpr0, lpr1; 57 u32 lpr0, lpr1;
52 u32 saved_lpr0; 58 u32 saved_lpr0, saved_lpr1;
53 59
54 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); 60 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
55 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; 61 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
@@ -63,14 +69,13 @@ static inline u32 sdram_selfrefresh_enable(void)
63 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0); 69 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
64 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1); 70 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
65 71
66 return saved_lpr0; 72 cpu_do_idle();
73
74 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
75 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
67} 76}
68 77
69#define sdram_selfrefresh_disable(saved_lpr0) \ 78#define at91_standby at91sam9g45_standby
70 do { \
71 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \
72 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \
73 } while (0)
74 79
75#else 80#else
76#include <mach/at91sam9_sdramc.h> 81#include <mach/at91sam9_sdramc.h>
@@ -83,7 +88,7 @@ static inline u32 sdram_selfrefresh_enable(void)
83#warning Assuming EB1 SDRAM controller is *NOT* used 88#warning Assuming EB1 SDRAM controller is *NOT* used
84#endif 89#endif
85 90
86static inline u32 sdram_selfrefresh_enable(void) 91static inline void at91sam9_standby(void)
87{ 92{
88 u32 saved_lpr, lpr; 93 u32 saved_lpr, lpr;
89 94
@@ -92,11 +97,13 @@ static inline u32 sdram_selfrefresh_enable(void)
92 lpr = saved_lpr & ~AT91_SDRAMC_LPCB; 97 lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
93 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | 98 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr |
94 AT91_SDRAMC_LPCB_SELF_REFRESH); 99 AT91_SDRAMC_LPCB_SELF_REFRESH);
95 return saved_lpr; 100
101 cpu_do_idle();
102
103 at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr);
96} 104}
97 105
98#define sdram_selfrefresh_disable(saved_lpr) \ 106#define at91_standby at91sam9_standby
99 at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr)
100 107
101#endif 108#endif
102 109