diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-03-02 08:01:00 -0500 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-03-15 11:38:02 -0400 |
commit | 82015c4eae2ac67cfed8e98f8d9a4ee77a2d26ca (patch) | |
tree | 4b1d99e45c92d21adeee3e665f31a3c4c80702c9 /arch | |
parent | a7776ec625c8ca90d050953946a5b72eaf41c21c (diff) |
ARM: at91: add Shutdown Controller (SHDWC) DT support
Use a string to specific the wakeup mode to make it more readable.
Add the Real-time Clock Wake-up support too for sam9g45 and sam9x5.
Add AT91_SHDW_CPTWK0_MAX to specific the Max of the Wakeup Counter.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/boot/dts/at91sam9g20.dtsi | 5 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9g45.dtsi | 5 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9x5.dtsi | 5 | ||||
-rw-r--r-- | arch/arm/mach-at91/include/mach/at91_shdwc.h | 4 | ||||
-rw-r--r-- | arch/arm/mach-at91/setup.c | 77 |
5 files changed, 95 insertions, 1 deletions
diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi index 0a1df8d9bfb6..9a0647bb387f 100644 --- a/arch/arm/boot/dts/at91sam9g20.dtsi +++ b/arch/arm/boot/dts/at91sam9g20.dtsi | |||
@@ -74,6 +74,11 @@ | |||
74 | reg = <0xfffffd00 0x10>; | 74 | reg = <0xfffffd00 0x10>; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | shdwc@fffffd10 { | ||
78 | compatible = "atmel,at91sam9260-shdwc"; | ||
79 | reg = <0xfffffd10 0x10>; | ||
80 | }; | ||
81 | |||
77 | pit: timer@fffffd30 { | 82 | pit: timer@fffffd30 { |
78 | compatible = "atmel,at91sam9260-pit"; | 83 | compatible = "atmel,at91sam9260-pit"; |
79 | reg = <0xfffffd30 0xf>; | 84 | reg = <0xfffffd30 0xf>; |
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi index 587a1913c062..8908f078c307 100644 --- a/arch/arm/boot/dts/at91sam9g45.dtsi +++ b/arch/arm/boot/dts/at91sam9g45.dtsi | |||
@@ -83,6 +83,11 @@ | |||
83 | }; | 83 | }; |
84 | 84 | ||
85 | 85 | ||
86 | shdwc@fffffd10 { | ||
87 | compatible = "atmel,at91sam9rl-shdwc"; | ||
88 | reg = <0xfffffd10 0x10>; | ||
89 | }; | ||
90 | |||
86 | tcb0: timer@fff7c000 { | 91 | tcb0: timer@fff7c000 { |
87 | compatible = "atmel,at91rm9200-tcb"; | 92 | compatible = "atmel,at91rm9200-tcb"; |
88 | reg = <0xfff7c000 0x100>; | 93 | reg = <0xfff7c000 0x100>; |
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index 73c46e3dffab..20155ccbbe14 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi | |||
@@ -73,6 +73,11 @@ | |||
73 | reg = <0xfffffe00 0x10>; | 73 | reg = <0xfffffe00 0x10>; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | shdwc@fffffe10 { | ||
77 | compatible = "atmel,at91sam9x5-shdwc"; | ||
78 | reg = <0xfffffe10 0x10>; | ||
79 | }; | ||
80 | |||
76 | pit: timer@fffffe30 { | 81 | pit: timer@fffffe30 { |
77 | compatible = "atmel,at91sam9260-pit"; | 82 | compatible = "atmel,at91sam9260-pit"; |
78 | reg = <0xfffffe30 0xf>; | 83 | reg = <0xfffffe30 0xf>; |
diff --git a/arch/arm/mach-at91/include/mach/at91_shdwc.h b/arch/arm/mach-at91/include/mach/at91_shdwc.h index 1d4fe822c77a..60478ea8bd46 100644 --- a/arch/arm/mach-at91/include/mach/at91_shdwc.h +++ b/arch/arm/mach-at91/include/mach/at91_shdwc.h | |||
@@ -36,9 +36,11 @@ extern void __iomem *at91_shdwc_base; | |||
36 | #define AT91_SHDW_WKMODE0_HIGH 1 | 36 | #define AT91_SHDW_WKMODE0_HIGH 1 |
37 | #define AT91_SHDW_WKMODE0_LOW 2 | 37 | #define AT91_SHDW_WKMODE0_LOW 2 |
38 | #define AT91_SHDW_WKMODE0_ANYLEVEL 3 | 38 | #define AT91_SHDW_WKMODE0_ANYLEVEL 3 |
39 | #define AT91_SHDW_CPTWK0 (0xf << 4) /* Counter On Wake Up 0 */ | 39 | #define AT91_SHDW_CPTWK0_MAX 0xf /* Maximum Counter On Wake Up 0 */ |
40 | #define AT91_SHDW_CPTWK0 (AT91_SHDW_CPTWK0_MAX << 4) /* Counter On Wake Up 0 */ | ||
40 | #define AT91_SHDW_CPTWK0_(x) ((x) << 4) | 41 | #define AT91_SHDW_CPTWK0_(x) ((x) << 4) |
41 | #define AT91_SHDW_RTTWKEN (1 << 16) /* Real Time Timer Wake-up Enable */ | 42 | #define AT91_SHDW_RTTWKEN (1 << 16) /* Real Time Timer Wake-up Enable */ |
43 | #define AT91_SHDW_RTCWKEN (1 << 17) /* Real Time Clock Wake-up Enable */ | ||
42 | 44 | ||
43 | #define AT91_SHDW_SR 0x08 /* Shut Down Status Register */ | 45 | #define AT91_SHDW_SR 0x08 /* Shut Down Status Register */ |
44 | #define AT91_SHDW_WAKEUP0 (1 << 0) /* Wake-up 0 Status */ | 46 | #define AT91_SHDW_WAKEUP0 (1 << 0) /* Wake-up 0 Status */ |
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index 46d0a56ba825..1083739e3065 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c | |||
@@ -351,10 +351,87 @@ static void at91_dt_ramc(void) | |||
351 | of_node_put(np); | 351 | of_node_put(np); |
352 | } | 352 | } |
353 | 353 | ||
354 | static 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 | |||
361 | static 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 | |||
368 | const 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 | |||
384 | static 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", ®)) { | ||
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 | |||
424 | end: | ||
425 | pm_power_off = at91sam9_poweroff; | ||
426 | |||
427 | of_node_put(np); | ||
428 | } | ||
429 | |||
354 | void __init at91_dt_initialize(void) | 430 | void __init at91_dt_initialize(void) |
355 | { | 431 | { |
356 | at91_dt_rstc(); | 432 | at91_dt_rstc(); |
357 | at91_dt_ramc(); | 433 | at91_dt_ramc(); |
434 | at91_dt_shdwc(); | ||
358 | 435 | ||
359 | /* Init clock subsystem */ | 436 | /* Init clock subsystem */ |
360 | at91_dt_clock_init(); | 437 | at91_dt_clock_init(); |