aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/pm.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-01-27 11:38:46 -0500
committerNicolas Ferre <nicolas.ferre@atmel.com>2015-02-02 05:01:29 -0500
commit827de1f123ba0880033d1b5299e116470e19bafb (patch)
tree202bca915b75331c525075d28e346bceb356f6ab /arch/arm/mach-at91/pm.c
parentcac0172389688b861d269eb4f1fee679d21a1372 (diff)
ARM: at91: remove at91_dt_initialize and machine init_early()
Move the ramc initialization to pm.c as it is the only user left. This allows us to get rid of at91_dt_initialize() that was the only one called by the init_early() function pointer of struct machine_desc. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> [nicolas.ferre@atmel.com: adapt patch to newer series] Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Diffstat (limited to 'arch/arm/mach-at91/pm.c')
-rw-r--r--arch/arm/mach-at91/pm.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 87c1fd8aa1b6..25bb93db8208 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -20,6 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/of_address.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/io.h> 25#include <linux/io.h>
25#include <linux/clk/at91_pmc.h> 26#include <linux/clk/at91_pmc.h>
@@ -41,6 +42,7 @@ static struct {
41} at91_pm_data; 42} at91_pm_data;
42 43
43static void (*at91_pm_standby)(void); 44static void (*at91_pm_standby)(void);
45void __iomem *at91_ramc_base[2];
44 46
45static int at91_pm_valid_state(suspend_state_t state) 47static int at91_pm_valid_state(suspend_state_t state)
46{ 48{
@@ -224,6 +226,43 @@ void at91_pm_set_standby(void (*at91_standby)(void))
224 } 226 }
225} 227}
226 228
229static struct of_device_id ramc_ids[] = {
230 { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby },
231 { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby },
232 { .compatible = "atmel,at91sam9g45-ddramc", .data = at91_ddr_standby },
233 { .compatible = "atmel,sama5d3-ddramc", .data = at91_ddr_standby },
234 { /*sentinel*/ }
235};
236
237static void at91_dt_ramc(void)
238{
239 struct device_node *np;
240 const struct of_device_id *of_id;
241 int idx = 0;
242 const void *standby = NULL;
243
244 for_each_matching_node_and_match(np, ramc_ids, &of_id) {
245 at91_ramc_base[idx] = of_iomap(np, 0);
246 if (!at91_ramc_base[idx])
247 panic(pr_fmt("unable to map ramc[%d] cpu registers\n"), idx);
248
249 if (!standby)
250 standby = of_id->data;
251
252 idx++;
253 }
254
255 if (!idx)
256 panic(pr_fmt("unable to find compatible ram controller node in dtb\n"));
257
258 if (!standby) {
259 pr_warn("ramc no standby function available\n");
260 return;
261 }
262
263 at91_pm_set_standby(standby);
264}
265
227#ifdef CONFIG_AT91_SLOW_CLOCK 266#ifdef CONFIG_AT91_SLOW_CLOCK
228static void __init at91_pm_sram_init(void) 267static void __init at91_pm_sram_init(void)
229{ 268{
@@ -282,6 +321,8 @@ static void __init at91_pm_init(void)
282 321
283void __init at91_rm9200_pm_init(void) 322void __init at91_rm9200_pm_init(void)
284{ 323{
324 at91_dt_ramc();
325
285 /* 326 /*
286 * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. 327 * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh.
287 */ 328 */
@@ -295,6 +336,7 @@ void __init at91_rm9200_pm_init(void)
295 336
296void __init at91_sam9260_pm_init(void) 337void __init at91_sam9260_pm_init(void)
297{ 338{
339 at91_dt_ramc();
298 at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC; 340 at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
299 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP; 341 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
300 return at91_pm_init(); 342 return at91_pm_init();
@@ -302,6 +344,7 @@ void __init at91_sam9260_pm_init(void)
302 344
303void __init at91_sam9g45_pm_init(void) 345void __init at91_sam9g45_pm_init(void)
304{ 346{
347 at91_dt_ramc();
305 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP; 348 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP;
306 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR; 349 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
307 return at91_pm_init(); 350 return at91_pm_init();
@@ -309,6 +352,7 @@ void __init at91_sam9g45_pm_init(void)
309 352
310void __init at91_sam9x5_pm_init(void) 353void __init at91_sam9x5_pm_init(void)
311{ 354{
355 at91_dt_ramc();
312 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP; 356 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
313 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR; 357 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
314 return at91_pm_init(); 358 return at91_pm_init();