aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-at91/setup.c')
-rw-r--r--arch/arm/mach-at91/setup.c200
1 files changed, 181 insertions, 19 deletions
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 8bdcc3cb6012..1083739e3065 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -9,6 +9,7 @@
9#include <linux/io.h> 9#include <linux/io.h>
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/pm.h> 11#include <linux/pm.h>
12#include <linux/of_address.h>
12 13
13#include <asm/mach/map.h> 14#include <asm/mach/map.h>
14 15
@@ -29,9 +30,12 @@ EXPORT_SYMBOL(at91_soc_initdata);
29void __init at91rm9200_set_type(int type) 30void __init at91rm9200_set_type(int type)
30{ 31{
31 if (type == ARCH_REVISON_9200_PQFP) 32 if (type == ARCH_REVISON_9200_PQFP)
32 at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA;
33 else
34 at91_soc_initdata.subtype = AT91_SOC_RM9200_PQFP; 33 at91_soc_initdata.subtype = AT91_SOC_RM9200_PQFP;
34 else
35 at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA;
36
37 pr_info("AT91: filled in soc subtype: %s\n",
38 at91_get_soc_subtype(&at91_soc_initdata));
35} 39}
36 40
37void __init at91_init_irq_default(void) 41void __init at91_init_irq_default(void)
@@ -48,6 +52,19 @@ void __init at91_init_interrupts(unsigned int *priority)
48 at91_gpio_irq_setup(); 52 at91_gpio_irq_setup();
49} 53}
50 54
55void __iomem *at91_ramc_base[2];
56
57void __init at91_ioremap_ramc(int id, u32 addr, u32 size)
58{
59 if (id < 0 || id > 1) {
60 pr_emerg("Wrong RAM controller id (%d), cannot continue\n", id);
61 BUG();
62 }
63 at91_ramc_base[id] = ioremap(addr, size);
64 if (!at91_ramc_base[id])
65 panic("Impossible to ioremap ramc.%d 0x%x\n", id, addr);
66}
67
51static struct map_desc sram_desc[2] __initdata; 68static struct map_desc sram_desc[2] __initdata;
52 69
53void __init at91_init_sram(int bank, unsigned long base, unsigned int length) 70void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
@@ -83,20 +100,6 @@ static void __init soc_detect(u32 dbgu_base)
83 socid = cidr & ~AT91_CIDR_VERSION; 100 socid = cidr & ~AT91_CIDR_VERSION;
84 101
85 switch (socid) { 102 switch (socid) {
86 case ARCH_ID_AT91CAP9: {
87#ifdef CONFIG_AT91_PMC_UNIT
88 u32 pmc_ver = at91_sys_read(AT91_PMC_VER);
89
90 if (pmc_ver == ARCH_REVISION_CAP9_B)
91 at91_soc_initdata.subtype = AT91_SOC_CAP9_REV_B;
92 else if (pmc_ver == ARCH_REVISION_CAP9_C)
93 at91_soc_initdata.subtype = AT91_SOC_CAP9_REV_C;
94#endif
95 at91_soc_initdata.type = AT91_SOC_CAP9;
96 at91_boot_soc = at91cap9_soc;
97 break;
98 }
99
100 case ARCH_ID_AT91RM9200: 103 case ARCH_ID_AT91RM9200:
101 at91_soc_initdata.type = AT91_SOC_RM9200; 104 at91_soc_initdata.type = AT91_SOC_RM9200;
102 at91_boot_soc = at91rm9200_soc; 105 at91_boot_soc = at91rm9200_soc;
@@ -197,7 +200,6 @@ static void __init soc_detect(u32 dbgu_base)
197 200
198static const char *soc_name[] = { 201static const char *soc_name[] = {
199 [AT91_SOC_RM9200] = "at91rm9200", 202 [AT91_SOC_RM9200] = "at91rm9200",
200 [AT91_SOC_CAP9] = "at91cap9",
201 [AT91_SOC_SAM9260] = "at91sam9260", 203 [AT91_SOC_SAM9260] = "at91sam9260",
202 [AT91_SOC_SAM9261] = "at91sam9261", 204 [AT91_SOC_SAM9261] = "at91sam9261",
203 [AT91_SOC_SAM9263] = "at91sam9263", 205 [AT91_SOC_SAM9263] = "at91sam9263",
@@ -218,8 +220,6 @@ EXPORT_SYMBOL(at91_get_soc_type);
218static const char *soc_subtype_name[] = { 220static const char *soc_subtype_name[] = {
219 [AT91_SOC_RM9200_BGA] = "at91rm9200 BGA", 221 [AT91_SOC_RM9200_BGA] = "at91rm9200 BGA",
220 [AT91_SOC_RM9200_PQFP] = "at91rm9200 PQFP", 222 [AT91_SOC_RM9200_PQFP] = "at91rm9200 PQFP",
221 [AT91_SOC_CAP9_REV_B] = "at91cap9 revB",
222 [AT91_SOC_CAP9_REV_C] = "at91cap9 revC",
223 [AT91_SOC_SAM9XE] = "at91sam9xe", 223 [AT91_SOC_SAM9XE] = "at91sam9xe",
224 [AT91_SOC_SAM9G45ES] = "at91sam9g45es", 224 [AT91_SOC_SAM9G45ES] = "at91sam9g45es",
225 [AT91_SOC_SAM9M10] = "at91sam9m10", 225 [AT91_SOC_SAM9M10] = "at91sam9m10",
@@ -281,6 +281,168 @@ void __init at91_ioremap_shdwc(u32 base_addr)
281 pm_power_off = at91sam9_poweroff; 281 pm_power_off = at91sam9_poweroff;
282} 282}
283 283
284void __iomem *at91_rstc_base;
285
286void __init at91_ioremap_rstc(u32 base_addr)
287{
288 at91_rstc_base = ioremap(base_addr, 16);
289 if (!at91_rstc_base)
290 panic("Impossible to ioremap at91_rstc_base\n");
291}
292
293void __iomem *at91_matrix_base;
294
295void __init at91_ioremap_matrix(u32 base_addr)
296{
297 at91_matrix_base = ioremap(base_addr, 512);
298 if (!at91_matrix_base)
299 panic("Impossible to ioremap at91_matrix_base\n");
300}
301
302#if defined(CONFIG_OF)
303static struct of_device_id rstc_ids[] = {
304 { .compatible = "atmel,at91sam9260-rstc", .data = at91sam9_alt_restart },
305 { .compatible = "atmel,at91sam9g45-rstc", .data = at91sam9g45_restart },
306 { /*sentinel*/ }
307};
308
309static void at91_dt_rstc(void)
310{
311 struct device_node *np;
312 const struct of_device_id *of_id;
313
314 np = of_find_matching_node(NULL, rstc_ids);
315 if (!np)
316 panic("unable to find compatible rstc node in dtb\n");
317
318 at91_rstc_base = of_iomap(np, 0);
319 if (!at91_rstc_base)
320 panic("unable to map rstc cpu registers\n");
321
322 of_id = of_match_node(rstc_ids, np);
323 if (!of_id)
324 panic("AT91: rtsc no restart function availlable\n");
325
326 arm_pm_restart = of_id->data;
327
328 of_node_put(np);
329}
330
331static struct of_device_id ramc_ids[] = {
332 { .compatible = "atmel,at91sam9260-sdramc" },
333 { .compatible = "atmel,at91sam9g45-ddramc" },
334 { /*sentinel*/ }
335};
336
337static void at91_dt_ramc(void)
338{
339 struct device_node *np;
340
341 np = of_find_matching_node(NULL, ramc_ids);
342 if (!np)
343 panic("unable to find compatible ram conroller node in dtb\n");
344
345 at91_ramc_base[0] = of_iomap(np, 0);
346 if (!at91_ramc_base[0])
347 panic("unable to map ramc[0] cpu registers\n");
348 /* the controller may have 2 banks */
349 at91_ramc_base[1] = of_iomap(np, 1);
350
351 of_node_put(np);
352}
353
354static struct of_device_id shdwc_ids[] = {
355 { .compatible = "atmel,at91sam9260-shdwc", },
356 { .compatible = "atmel,at91sam9rl-shdwc", },
357 { .compatible = "atmel,at91sam9x5-shdwc", },
358 { /*sentinel*/ }
359};
360
361static const char *shdwc_wakeup_modes[] = {
362 [AT91_SHDW_WKMODE0_NONE] = "none",
363 [AT91_SHDW_WKMODE0_HIGH] = "high",
364 [AT91_SHDW_WKMODE0_LOW] = "low",
365 [AT91_SHDW_WKMODE0_ANYLEVEL] = "any",
366};
367
368const int at91_dtget_shdwc_wakeup_mode(struct device_node *np)
369{
370 const char *pm;
371 int err, i;
372
373 err = of_property_read_string(np, "atmel,wakeup-mode", &pm);
374 if (err < 0)
375 return AT91_SHDW_WKMODE0_ANYLEVEL;
376
377 for (i = 0; i < ARRAY_SIZE(shdwc_wakeup_modes); i++)
378 if (!strcasecmp(pm, shdwc_wakeup_modes[i]))
379 return i;
380
381 return -ENODEV;
382}
383
384static void at91_dt_shdwc(void)
385{
386 struct device_node *np;
387 int wakeup_mode;
388 u32 reg;
389 u32 mode = 0;
390
391 np = of_find_matching_node(NULL, shdwc_ids);
392 if (!np) {
393 pr_debug("AT91: unable to find compatible shutdown (shdwc) conroller node in dtb\n");
394 return;
395 }
396
397 at91_shdwc_base = of_iomap(np, 0);
398 if (!at91_shdwc_base)
399 panic("AT91: unable to map shdwc cpu registers\n");
400
401 wakeup_mode = at91_dtget_shdwc_wakeup_mode(np);
402 if (wakeup_mode < 0) {
403 pr_warn("AT91: shdwc unknown wakeup mode\n");
404 goto end;
405 }
406
407 if (!of_property_read_u32(np, "atmel,wakeup-counter", &reg)) {
408 if (reg > AT91_SHDW_CPTWK0_MAX) {
409 pr_warn("AT91: shdwc wakeup conter 0x%x > 0x%x reduce it to 0x%x\n",
410 reg, AT91_SHDW_CPTWK0_MAX, AT91_SHDW_CPTWK0_MAX);
411 reg = AT91_SHDW_CPTWK0_MAX;
412 }
413 mode |= AT91_SHDW_CPTWK0_(reg);
414 }
415
416 if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
417 mode |= AT91_SHDW_RTCWKEN;
418
419 if (of_property_read_bool(np, "atmel,wakeup-rtt-timer"))
420 mode |= AT91_SHDW_RTTWKEN;
421
422 at91_shdwc_write(AT91_SHDW_MR, wakeup_mode | mode);
423
424end:
425 pm_power_off = at91sam9_poweroff;
426
427 of_node_put(np);
428}
429
430void __init at91_dt_initialize(void)
431{
432 at91_dt_rstc();
433 at91_dt_ramc();
434 at91_dt_shdwc();
435
436 /* Init clock subsystem */
437 at91_dt_clock_init();
438
439 /* Register the processor-specific clocks */
440 at91_boot_soc.register_clocks();
441
442 at91_boot_soc.init();
443}
444#endif
445
284void __init at91_initialize(unsigned long main_clock) 446void __init at91_initialize(unsigned long main_clock)
285{ 447{
286 at91_boot_soc.ioremap_registers(); 448 at91_boot_soc.ioremap_registers();