aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-03-16 18:44:37 -0400
committerNicolas Ferre <nicolas.ferre@atmel.com>2015-04-05 15:59:51 -0400
commita18d0699dd18ba5661c321ebd67e6056656b6765 (patch)
tree131281f6c0a20c7dc7d7d6296193ff19ed66b152
parent176a1b3dadf08835b9435bed4957daa066702a39 (diff)
ARM: at91/pm: move the standby functions to pm.c
The standby functions are now only used in pm.c, move them there. Also, they are not inlined as a pointer to those functions is passed to the cpuidle driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
-rw-r--r--arch/arm/mach-at91/pm.c89
-rw-r--r--arch/arm/mach-at91/pm.h92
2 files changed, 89 insertions, 92 deletions
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index ac947cdd506c..0a71c69618f8 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -216,6 +216,95 @@ static void at91_pm_set_standby(void (*at91_standby)(void))
216 at91_cpuidle_device.dev.platform_data = at91_standby; 216 at91_cpuidle_device.dev.platform_data = at91_standby;
217} 217}
218 218
219/*
220 * The AT91RM9200 goes into self-refresh mode with this command, and will
221 * terminate self-refresh automatically on the next SDRAM access.
222 *
223 * Self-refresh mode is exited as soon as a memory access is made, but we don't
224 * know for sure when that happens. However, we need to restore the low-power
225 * mode if it was enabled before going idle. Restoring low-power mode while
226 * still in self-refresh is "not recommended", but seems to work.
227 */
228static void at91rm9200_standby(void)
229{
230 u32 lpr = at91_ramc_read(0, AT91RM9200_SDRAMC_LPR);
231
232 asm volatile(
233 "b 1f\n\t"
234 ".align 5\n\t"
235 "1: mcr p15, 0, %0, c7, c10, 4\n\t"
236 " str %0, [%1, %2]\n\t"
237 " str %3, [%1, %4]\n\t"
238 " mcr p15, 0, %0, c7, c0, 4\n\t"
239 " str %5, [%1, %2]"
240 :
241 : "r" (0), "r" (at91_ramc_base[0]), "r" (AT91RM9200_SDRAMC_LPR),
242 "r" (1), "r" (AT91RM9200_SDRAMC_SRR),
243 "r" (lpr));
244}
245
246/* We manage both DDRAM/SDRAM controllers, we need more than one value to
247 * remember.
248 */
249static void at91_ddr_standby(void)
250{
251 /* Those two values allow us to delay self-refresh activation
252 * to the maximum. */
253 u32 lpr0, lpr1 = 0;
254 u32 saved_lpr0, saved_lpr1 = 0;
255
256 if (at91_ramc_base[1]) {
257 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
258 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
259 lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
260 }
261
262 saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
263 lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
264 lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
265
266 /* self-refresh mode now */
267 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
268 if (at91_ramc_base[1])
269 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
270
271 cpu_do_idle();
272
273 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
274 if (at91_ramc_base[1])
275 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
276}
277
278/* We manage both DDRAM/SDRAM controllers, we need more than one value to
279 * remember.
280 */
281static void at91sam9_sdram_standby(void)
282{
283 u32 lpr0, lpr1 = 0;
284 u32 saved_lpr0, saved_lpr1 = 0;
285
286 if (at91_ramc_base[1]) {
287 saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR);
288 lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB;
289 lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
290 }
291
292 saved_lpr0 = at91_ramc_read(0, AT91_SDRAMC_LPR);
293 lpr0 = saved_lpr0 & ~AT91_SDRAMC_LPCB;
294 lpr0 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
295
296 /* self-refresh mode now */
297 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0);
298 if (at91_ramc_base[1])
299 at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1);
300
301 cpu_do_idle();
302
303 at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr0);
304 if (at91_ramc_base[1])
305 at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1);
306}
307
219static const struct of_device_id ramc_ids[] __initconst = { 308static const struct of_device_id ramc_ids[] __initconst = {
220 { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby }, 309 { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby },
221 { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby }, 310 { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby },
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index dcacfa1ad3fa..3223967d3460 100644
--- a/arch/arm/mach-at91/pm.h
+++ b/arch/arm/mach-at91/pm.h
@@ -23,96 +23,4 @@
23 23
24#define AT91_PM_SLOW_CLOCK 0x01 24#define AT91_PM_SLOW_CLOCK 0x01
25 25
26/*
27 * The AT91RM9200 goes into self-refresh mode with this command, and will
28 * terminate self-refresh automatically on the next SDRAM access.
29 *
30 * Self-refresh mode is exited as soon as a memory access is made, but we don't
31 * know for sure when that happens. However, we need to restore the low-power
32 * mode if it was enabled before going idle. Restoring low-power mode while
33 * still in self-refresh is "not recommended", but seems to work.
34 */
35
36#ifndef __ASSEMBLY__
37static inline void at91rm9200_standby(void)
38{
39 u32 lpr = at91_ramc_read(0, AT91RM9200_SDRAMC_LPR);
40
41 asm volatile(
42 "b 1f\n\t"
43 ".align 5\n\t"
44 "1: mcr p15, 0, %0, c7, c10, 4\n\t"
45 " str %0, [%1, %2]\n\t"
46 " str %3, [%1, %4]\n\t"
47 " mcr p15, 0, %0, c7, c0, 4\n\t"
48 " str %5, [%1, %2]"
49 :
50 : "r" (0), "r" (at91_ramc_base[0]), "r" (AT91RM9200_SDRAMC_LPR),
51 "r" (1), "r" (AT91RM9200_SDRAMC_SRR),
52 "r" (lpr));
53}
54
55/* We manage both DDRAM/SDRAM controllers, we need more than one value to
56 * remember.
57 */
58static inline void at91_ddr_standby(void)
59{
60 /* Those two values allow us to delay self-refresh activation
61 * to the maximum. */
62 u32 lpr0, lpr1 = 0;
63 u32 saved_lpr0, saved_lpr1 = 0;
64
65 if (at91_ramc_base[1]) {
66 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
67 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
68 lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
69 }
70
71 saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
72 lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
73 lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
74
75 /* self-refresh mode now */
76 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
77 if (at91_ramc_base[1])
78 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
79
80 cpu_do_idle();
81
82 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
83 if (at91_ramc_base[1])
84 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
85}
86
87/* We manage both DDRAM/SDRAM controllers, we need more than one value to
88 * remember.
89 */
90static inline void at91sam9_sdram_standby(void)
91{
92 u32 lpr0, lpr1 = 0;
93 u32 saved_lpr0, saved_lpr1 = 0;
94
95 if (at91_ramc_base[1]) {
96 saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR);
97 lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB;
98 lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
99 }
100
101 saved_lpr0 = at91_ramc_read(0, AT91_SDRAMC_LPR);
102 lpr0 = saved_lpr0 & ~AT91_SDRAMC_LPCB;
103 lpr0 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
104
105 /* self-refresh mode now */
106 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0);
107 if (at91_ramc_base[1])
108 at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1);
109
110 cpu_do_idle();
111
112 at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr0);
113 if (at91_ramc_base[1])
114 at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1);
115}
116
117#endif
118#endif 26#endif