blob: f06270198bf1267fbcc0f28d88a18f6b13b1ad8a [file] [log] [blame]
Andrew Victor907d6de2006-06-20 19:30:19 +01001/*
Andrew Victor9d041262007-02-05 11:42:07 +01002 * arch/arm/mach-at91/pm.c
Andrew Victor907d6de2006-06-20 19:30:19 +01003 * AT91 Power Management
4 *
5 * Copyright (C) 2005 David Brownell
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
Russell King2f8163b2011-07-26 10:53:52 +010013#include <linux/gpio.h>
Rafael J. Wysocki95d9ffb2007-10-18 03:04:39 -070014#include <linux/suspend.h>
Andrew Victor907d6de2006-06-20 19:30:19 +010015#include <linux/sched.h>
16#include <linux/proc_fs.h>
Alexandre Bellonid2e46792015-01-15 15:59:25 +010017#include <linux/genalloc.h>
Andrew Victor907d6de2006-06-20 19:30:19 +010018#include <linux/interrupt.h>
19#include <linux/sysfs.h>
20#include <linux/module.h>
Alexandre Bellonif5598d32015-01-15 15:59:24 +010021#include <linux/of.h>
Alexandre Bellonid2e46792015-01-15 15:59:25 +010022#include <linux/of_platform.h>
Alexandre Belloni827de1f2015-01-27 17:38:46 +010023#include <linux/of_address.h>
Andrew Victor907d6de2006-06-20 19:30:19 +010024#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010025#include <linux/io.h>
Boris BREZILLON2edb90a2013-10-11 09:37:45 +020026#include <linux/clk/at91_pmc.h>
Andrew Victor907d6de2006-06-20 19:30:19 +010027
Andrew Victor907d6de2006-06-20 19:30:19 +010028#include <asm/irq.h>
Arun Sharma600634972011-07-26 16:09:06 -070029#include <linux/atomic.h>
Andrew Victor907d6de2006-06-20 19:30:19 +010030#include <asm/mach/time.h>
31#include <asm/mach/irq.h>
Wenyou Yangd94e6882015-03-09 11:49:01 +080032#include <asm/fncpy.h>
Wenyou Yang385acc02015-03-09 11:54:26 +080033#include <asm/cacheflush.h>
Alexandre Bellonifbc7edc2015-09-30 01:58:40 +020034#include <asm/system_misc.h>
Andrew Victor907d6de2006-06-20 19:30:19 +010035
Andrew Victor907d6de2006-06-20 19:30:19 +010036#include "generic.h"
Albin Tonnerre1ea60cf2009-11-01 18:40:50 +010037#include "pm.h"
Andrew Victor907d6de2006-06-20 19:30:19 +010038
Alexandre Belloni5737b732015-09-30 01:31:34 +020039static void __iomem *pmc;
40
Alexandre Belloni23b84082015-03-13 22:57:23 +010041/*
42 * FIXME: this is needed to communicate between the pinctrl driver and
43 * the PM implementation in the machine. Possibly part of the PM
44 * implementation should be moved down into the pinctrl driver and get
45 * called as part of the generic suspend/resume path.
46 */
Ludovic Desroches84235362015-12-01 11:44:40 +010047#ifdef CONFIG_PINCTRL_AT91
Alexandre Belloni23b84082015-03-13 22:57:23 +010048extern void at91_pinctrl_gpio_suspend(void);
49extern void at91_pinctrl_gpio_resume(void);
Ludovic Desroches84235362015-12-01 11:44:40 +010050#endif
Alexandre Belloni23b84082015-03-13 22:57:23 +010051
Alexandre Bellonif5598d32015-01-15 15:59:24 +010052static struct {
53 unsigned long uhp_udp_mask;
54 int memctrl;
55} at91_pm_data;
56
Alexandre Belloni827de1f2015-01-27 17:38:46 +010057void __iomem *at91_ramc_base[2];
Daniel Lezcano5ad945e2013-09-22 22:29:57 +020058
Andrew Victor907d6de2006-06-20 19:30:19 +010059static int at91_pm_valid_state(suspend_state_t state)
60{
61 switch (state) {
62 case PM_SUSPEND_ON:
63 case PM_SUSPEND_STANDBY:
64 case PM_SUSPEND_MEM:
65 return 1;
66
67 default:
68 return 0;
69 }
70}
71
72
73static suspend_state_t target_state;
74
75/*
76 * Called after processes are frozen, but before we shutdown devices.
77 */
Rafael J. Wysockic697eec2008-01-08 00:04:17 +010078static int at91_pm_begin(suspend_state_t state)
Andrew Victor907d6de2006-06-20 19:30:19 +010079{
80 target_state = state;
81 return 0;
82}
83
84/*
85 * Verify that all the clocks are correct before entering
86 * slow-clock mode.
87 */
88static int at91_pm_verify_clocks(void)
89{
90 unsigned long scsr;
91 int i;
92
Alexandre Belloni5737b732015-09-30 01:31:34 +020093 scsr = readl(pmc + AT91_PMC_SCSR);
Andrew Victor907d6de2006-06-20 19:30:19 +010094
95 /* USB must not be using PLLB */
Alexandre Bellonif5598d32015-01-15 15:59:24 +010096 if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
97 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
98 return 0;
Andrew Victor907d6de2006-06-20 19:30:19 +010099 }
100
Andrew Victor907d6de2006-06-20 19:30:19 +0100101 /* PCK0..PCK3 must be disabled, or configured to use clk32k */
102 for (i = 0; i < 4; i++) {
103 u32 css;
104
105 if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
106 continue;
Alexandre Belloni5737b732015-09-30 01:31:34 +0200107 css = readl(pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
Andrew Victor907d6de2006-06-20 19:30:19 +0100108 if (css != AT91_PMC_CSS_SLOW) {
Ryan Mallon7f96b1c2009-04-01 20:33:30 +0100109 pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
Andrew Victor907d6de2006-06-20 19:30:19 +0100110 return 0;
111 }
112 }
Andrew Victor907d6de2006-06-20 19:30:19 +0100113
114 return 1;
115}
116
117/*
118 * Call this from platform driver suspend() to see how deeply to suspend.
119 * For example, some controllers (like OHCI) need one of the PLL clocks
120 * in order to act as a wakeup source, and those are not available when
121 * going into slow clock mode.
122 *
123 * REVISIT: generalize as clk_will_be_available(clk)? Other platforms have
124 * the very same problem (but not using at91 main_clk), and it'd be better
125 * to add one generic API rather than lots of platform-specific ones.
126 */
127int at91_suspend_entering_slow_clock(void)
128{
129 return (target_state == PM_SUSPEND_MEM);
130}
131EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
132
Wenyou Yang5726a8b2015-03-09 11:51:09 +0800133static void (*at91_suspend_sram_fn)(void __iomem *pmc, void __iomem *ramc0,
Jean-Christophe PLAGNIOL-VILLARDfb7e1972012-02-22 17:50:55 +0100134 void __iomem *ramc1, int memctrl);
Andrew Victor907d6de2006-06-20 19:30:19 +0100135
Wenyou Yang5726a8b2015-03-09 11:51:09 +0800136extern void at91_pm_suspend_in_sram(void __iomem *pmc, void __iomem *ramc0,
Jean-Christophe PLAGNIOL-VILLARDfb7e1972012-02-22 17:50:55 +0100137 void __iomem *ramc1, int memctrl);
Wenyou Yang5726a8b2015-03-09 11:51:09 +0800138extern u32 at91_pm_suspend_in_sram_sz;
Andrew Victorf5d0f452008-04-02 21:50:16 +0100139
Wenyou Yang23be4be2015-03-09 11:49:46 +0800140static void at91_pm_suspend(suspend_state_t state)
141{
142 unsigned int pm_data = at91_pm_data.memctrl;
143
144 pm_data |= (state == PM_SUSPEND_MEM) ?
145 AT91_PM_MODE(AT91_PM_SLOW_CLOCK) : 0;
146
Wenyou Yang385acc02015-03-09 11:54:26 +0800147 flush_cache_all();
148 outer_disable();
149
Alexandre Belloni5737b732015-09-30 01:31:34 +0200150 at91_suspend_sram_fn(pmc, at91_ramc_base[0],
151 at91_ramc_base[1], pm_data);
Wenyou Yang385acc02015-03-09 11:54:26 +0800152
153 outer_resume();
Wenyou Yang23be4be2015-03-09 11:49:46 +0800154}
155
Andrew Victor907d6de2006-06-20 19:30:19 +0100156static int at91_pm_enter(suspend_state_t state)
157{
Ludovic Desroches84235362015-12-01 11:44:40 +0100158#ifdef CONFIG_PINCTRL_AT91
Arnd Bergmann85c4b312014-12-02 12:08:27 +0100159 at91_pinctrl_gpio_suspend();
Ludovic Desroches84235362015-12-01 11:44:40 +0100160#endif
Andrew Victor907d6de2006-06-20 19:30:19 +0100161 switch (state) {
Wenyou Yang23be4be2015-03-09 11:49:46 +0800162 /*
163 * Suspend-to-RAM is like STANDBY plus slow clock mode, so
164 * drivers must suspend more deeply, the master clock switches
165 * to the clk32k and turns off the main oscillator
166 */
167 case PM_SUSPEND_MEM:
Andrew Victor907d6de2006-06-20 19:30:19 +0100168 /*
Wenyou Yang23be4be2015-03-09 11:49:46 +0800169 * Ensure that clocks are in a valid state.
Andrew Victor907d6de2006-06-20 19:30:19 +0100170 */
Wenyou Yang23be4be2015-03-09 11:49:46 +0800171 if (!at91_pm_verify_clocks())
Andrew Victor907d6de2006-06-20 19:30:19 +0100172 goto error;
Wenyou Yang23be4be2015-03-09 11:49:46 +0800173
174 at91_pm_suspend(state);
175
176 break;
177
178 /*
179 * STANDBY mode has *all* drivers suspended; ignores irqs not
180 * marked as 'wakeup' event sources; and reduces DRAM power.
181 * But otherwise it's identical to PM_SUSPEND_ON: cpu idle, and
182 * nothing fancy done with main or cpu clocks.
183 */
184 case PM_SUSPEND_STANDBY:
185 at91_pm_suspend(state);
186 break;
187
188 case PM_SUSPEND_ON:
189 cpu_do_idle();
190 break;
191
192 default:
193 pr_debug("AT91: PM - bogus suspend state %d\n", state);
194 goto error;
Andrew Victor907d6de2006-06-20 19:30:19 +0100195 }
196
Andrew Victor907d6de2006-06-20 19:30:19 +0100197error:
198 target_state = PM_SUSPEND_ON;
Boris BREZILLON07192602014-07-10 19:14:20 +0200199
Ludovic Desroches84235362015-12-01 11:44:40 +0100200#ifdef CONFIG_PINCTRL_AT91
Arnd Bergmann85c4b312014-12-02 12:08:27 +0100201 at91_pinctrl_gpio_resume();
Ludovic Desroches84235362015-12-01 11:44:40 +0100202#endif
Andrew Victor907d6de2006-06-20 19:30:19 +0100203 return 0;
204}
205
Rafael J. Wysockic697eec2008-01-08 00:04:17 +0100206/*
207 * Called right prior to thawing processes.
208 */
209static void at91_pm_end(void)
210{
211 target_state = PM_SUSPEND_ON;
212}
213
Andrew Victor907d6de2006-06-20 19:30:19 +0100214
Lionel Debroux2f55ac02010-11-16 14:14:02 +0100215static const struct platform_suspend_ops at91_pm_ops = {
Rafael J. Wysockic697eec2008-01-08 00:04:17 +0100216 .valid = at91_pm_valid_state,
217 .begin = at91_pm_begin,
218 .enter = at91_pm_enter,
219 .end = at91_pm_end,
Andrew Victor907d6de2006-06-20 19:30:19 +0100220};
221
Daniel Lezcano5ad945e2013-09-22 22:29:57 +0200222static struct platform_device at91_cpuidle_device = {
223 .name = "cpuidle-at91",
224};
225
Wenyou Yang047794e2015-03-04 09:44:45 +0800226static void at91_pm_set_standby(void (*at91_standby)(void))
Daniel Lezcano5ad945e2013-09-22 22:29:57 +0200227{
Wenyou Yange32d9952015-03-09 11:51:49 +0800228 if (at91_standby)
Daniel Lezcano5ad945e2013-09-22 22:29:57 +0200229 at91_cpuidle_device.dev.platform_data = at91_standby;
Daniel Lezcano5ad945e2013-09-22 22:29:57 +0200230}
231
Alexandre Bellonia18d0692015-03-16 23:44:37 +0100232/*
233 * The AT91RM9200 goes into self-refresh mode with this command, and will
234 * terminate self-refresh automatically on the next SDRAM access.
235 *
236 * Self-refresh mode is exited as soon as a memory access is made, but we don't
237 * know for sure when that happens. However, we need to restore the low-power
238 * mode if it was enabled before going idle. Restoring low-power mode while
239 * still in self-refresh is "not recommended", but seems to work.
240 */
241static void at91rm9200_standby(void)
242{
Alexandre Bellonid7d45f22015-03-16 15:14:50 +0100243 u32 lpr = at91_ramc_read(0, AT91_MC_SDRAMC_LPR);
Alexandre Bellonia18d0692015-03-16 23:44:37 +0100244
245 asm volatile(
246 "b 1f\n\t"
247 ".align 5\n\t"
248 "1: mcr p15, 0, %0, c7, c10, 4\n\t"
249 " str %0, [%1, %2]\n\t"
250 " str %3, [%1, %4]\n\t"
251 " mcr p15, 0, %0, c7, c0, 4\n\t"
252 " str %5, [%1, %2]"
253 :
Alexandre Bellonid7d45f22015-03-16 15:14:50 +0100254 : "r" (0), "r" (at91_ramc_base[0]), "r" (AT91_MC_SDRAMC_LPR),
255 "r" (1), "r" (AT91_MC_SDRAMC_SRR),
Alexandre Bellonia18d0692015-03-16 23:44:37 +0100256 "r" (lpr));
257}
258
259/* We manage both DDRAM/SDRAM controllers, we need more than one value to
260 * remember.
261 */
262static void at91_ddr_standby(void)
263{
264 /* Those two values allow us to delay self-refresh activation
265 * to the maximum. */
266 u32 lpr0, lpr1 = 0;
267 u32 saved_lpr0, saved_lpr1 = 0;
268
269 if (at91_ramc_base[1]) {
270 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
271 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
272 lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
273 }
274
275 saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
276 lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
277 lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
278
279 /* self-refresh mode now */
280 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
281 if (at91_ramc_base[1])
282 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
283
284 cpu_do_idle();
285
286 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
287 if (at91_ramc_base[1])
288 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
289}
290
291/* We manage both DDRAM/SDRAM controllers, we need more than one value to
292 * remember.
293 */
294static void at91sam9_sdram_standby(void)
295{
296 u32 lpr0, lpr1 = 0;
297 u32 saved_lpr0, saved_lpr1 = 0;
298
299 if (at91_ramc_base[1]) {
300 saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR);
301 lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB;
302 lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
303 }
304
305 saved_lpr0 = at91_ramc_read(0, AT91_SDRAMC_LPR);
306 lpr0 = saved_lpr0 & ~AT91_SDRAMC_LPCB;
307 lpr0 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
308
309 /* self-refresh mode now */
310 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0);
311 if (at91_ramc_base[1])
312 at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1);
313
314 cpu_do_idle();
315
316 at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr0);
317 if (at91_ramc_base[1])
318 at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1);
319}
320
Nicolas Pitre19c233b2015-07-27 18:27:52 -0400321static const struct of_device_id const ramc_ids[] __initconst = {
Alexandre Belloni827de1f2015-01-27 17:38:46 +0100322 { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby },
323 { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby },
324 { .compatible = "atmel,at91sam9g45-ddramc", .data = at91_ddr_standby },
325 { .compatible = "atmel,sama5d3-ddramc", .data = at91_ddr_standby },
326 { /*sentinel*/ }
327};
328
Uwe Kleine-König444d2d32015-02-18 21:19:56 +0100329static __init void at91_dt_ramc(void)
Alexandre Belloni827de1f2015-01-27 17:38:46 +0100330{
331 struct device_node *np;
332 const struct of_device_id *of_id;
333 int idx = 0;
334 const void *standby = NULL;
335
336 for_each_matching_node_and_match(np, ramc_ids, &of_id) {
337 at91_ramc_base[idx] = of_iomap(np, 0);
338 if (!at91_ramc_base[idx])
339 panic(pr_fmt("unable to map ramc[%d] cpu registers\n"), idx);
340
341 if (!standby)
342 standby = of_id->data;
343
344 idx++;
345 }
346
347 if (!idx)
348 panic(pr_fmt("unable to find compatible ram controller node in dtb\n"));
349
350 if (!standby) {
351 pr_warn("ramc no standby function available\n");
352 return;
353 }
354
355 at91_pm_set_standby(standby);
356}
357
Alexandre Bellonifbc7edc2015-09-30 01:58:40 +0200358void at91rm9200_idle(void)
359{
360 /*
361 * Disable the processor clock. The processor will be automatically
362 * re-enabled by an interrupt or by a reset.
363 */
364 writel(AT91_PMC_PCK, pmc + AT91_PMC_SCDR);
365}
366
367void at91sam9_idle(void)
368{
369 writel(AT91_PMC_PCK, pmc + AT91_PMC_SCDR);
370 cpu_do_idle();
371}
372
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100373static void __init at91_pm_sram_init(void)
374{
375 struct gen_pool *sram_pool;
376 phys_addr_t sram_pbase;
377 unsigned long sram_base;
378 struct device_node *node;
Alexandre Belloni4a031f72015-03-03 08:38:07 +0100379 struct platform_device *pdev = NULL;
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100380
Alexandre Belloni4a031f72015-03-03 08:38:07 +0100381 for_each_compatible_node(node, NULL, "mmio-sram") {
382 pdev = of_find_device_by_node(node);
383 if (pdev) {
384 of_node_put(node);
385 break;
386 }
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100387 }
388
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100389 if (!pdev) {
390 pr_warn("%s: failed to find sram device!\n", __func__);
Alexandre Belloni4a031f72015-03-03 08:38:07 +0100391 return;
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100392 }
393
Vladimir Zapolskiy73858172015-09-04 15:47:43 -0700394 sram_pool = gen_pool_get(&pdev->dev, NULL);
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100395 if (!sram_pool) {
396 pr_warn("%s: sram pool unavailable!\n", __func__);
Alexandre Belloni4a031f72015-03-03 08:38:07 +0100397 return;
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100398 }
399
Wenyou Yang5726a8b2015-03-09 11:51:09 +0800400 sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100401 if (!sram_base) {
Wenyou Yang5726a8b2015-03-09 11:51:09 +0800402 pr_warn("%s: unable to alloc sram!\n", __func__);
Alexandre Belloni4a031f72015-03-03 08:38:07 +0100403 return;
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100404 }
405
406 sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
Wenyou Yang5726a8b2015-03-09 11:51:09 +0800407 at91_suspend_sram_fn = __arm_ioremap_exec(sram_pbase,
408 at91_pm_suspend_in_sram_sz, false);
409 if (!at91_suspend_sram_fn) {
Wenyou Yangd94e6882015-03-09 11:49:01 +0800410 pr_warn("SRAM: Could not map\n");
411 return;
412 }
413
Wenyou Yang5726a8b2015-03-09 11:51:09 +0800414 /* Copy the pm suspend handler to SRAM */
415 at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
416 &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100417}
Alexandre Bellonid2e46792015-01-15 15:59:25 +0100418
Alexandre Belloni5737b732015-09-30 01:31:34 +0200419static const struct of_device_id atmel_pmc_ids[] __initconst = {
420 { .compatible = "atmel,at91rm9200-pmc" },
421 { .compatible = "atmel,at91sam9260-pmc" },
422 { .compatible = "atmel,at91sam9g45-pmc" },
423 { .compatible = "atmel,at91sam9n12-pmc" },
424 { .compatible = "atmel,at91sam9x5-pmc" },
425 { .compatible = "atmel,sama5d3-pmc" },
426 { .compatible = "atmel,sama5d2-pmc" },
427 { /* sentinel */ },
428};
429
Alexandre Bellonifbc7edc2015-09-30 01:58:40 +0200430static void __init at91_pm_init(void (*pm_idle)(void))
Andrew Victor907d6de2006-06-20 19:30:19 +0100431{
Alexandre Belloni5737b732015-09-30 01:31:34 +0200432 struct device_node *pmc_np;
Andrew Victorf5d0f452008-04-02 21:50:16 +0100433
Daniel Lezcano5ad945e2013-09-22 22:29:57 +0200434 if (at91_cpuidle_device.dev.platform_data)
435 platform_device_register(&at91_cpuidle_device);
Andrew Victor907d6de2006-06-20 19:30:19 +0100436
Alexandre Belloni5737b732015-09-30 01:31:34 +0200437 pmc_np = of_find_matching_node(NULL, atmel_pmc_ids);
438 pmc = of_iomap(pmc_np, 0);
439 if (!pmc) {
440 pr_err("AT91: PM not supported, PMC not found\n");
441 return;
442 }
443
Alexandre Bellonifbc7edc2015-09-30 01:58:40 +0200444 if (pm_idle)
445 arm_pm_idle = pm_idle;
446
Alexandre Belloni5737b732015-09-30 01:31:34 +0200447 at91_pm_sram_init();
448
Wenyou Yang5726a8b2015-03-09 11:51:09 +0800449 if (at91_suspend_sram_fn)
Wenyou Yangd94e6882015-03-09 11:49:01 +0800450 suspend_set_ops(&at91_pm_ops);
451 else
452 pr_info("AT91: PM not supported, due to no SRAM allocated\n");
Andrew Victor907d6de2006-06-20 19:30:19 +0100453}
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100454
Nicolas Ferread3fc3e2015-01-27 18:41:33 +0100455void __init at91rm9200_pm_init(void)
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100456{
Alexandre Belloni827de1f2015-01-27 17:38:46 +0100457 at91_dt_ramc();
458
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100459 /*
460 * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh.
461 */
Alexandre Bellonid7d45f22015-03-16 15:14:50 +0100462 at91_ramc_write(0, AT91_MC_SDRAMC_LPR, 0);
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100463
464 at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP;
465 at91_pm_data.memctrl = AT91_MEMCTRL_MC;
466
Alexandre Bellonifbc7edc2015-09-30 01:58:40 +0200467 at91_pm_init(at91rm9200_idle);
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100468}
469
Nicolas Ferread3fc3e2015-01-27 18:41:33 +0100470void __init at91sam9260_pm_init(void)
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100471{
Alexandre Belloni827de1f2015-01-27 17:38:46 +0100472 at91_dt_ramc();
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100473 at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
474 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
Alexandre Bellonifbc7edc2015-09-30 01:58:40 +0200475 at91_pm_init(at91sam9_idle);
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100476}
477
Nicolas Ferread3fc3e2015-01-27 18:41:33 +0100478void __init at91sam9g45_pm_init(void)
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100479{
Alexandre Belloni827de1f2015-01-27 17:38:46 +0100480 at91_dt_ramc();
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100481 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP;
482 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
Alexandre Bellonifbc7edc2015-09-30 01:58:40 +0200483 at91_pm_init(at91sam9_idle);
Alexandre Belloni4db0ba22015-01-15 15:59:27 +0100484}
Nicolas Ferrebf022802015-01-22 16:54:50 +0100485
Nicolas Ferread3fc3e2015-01-27 18:41:33 +0100486void __init at91sam9x5_pm_init(void)
Nicolas Ferrebf022802015-01-22 16:54:50 +0100487{
Alexandre Belloni827de1f2015-01-27 17:38:46 +0100488 at91_dt_ramc();
Nicolas Ferrebf022802015-01-22 16:54:50 +0100489 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
490 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
Alexandre Bellonifbc7edc2015-09-30 01:58:40 +0200491 at91_pm_init(at91sam9_idle);
492}
493
494void __init sama5_pm_init(void)
495{
496 at91_dt_ramc();
497 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
498 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
499 at91_pm_init(NULL);
Nicolas Ferrebf022802015-01-22 16:54:50 +0100500}