aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/pm.c
diff options
context:
space:
mode:
authorAndrew Victor <linux@maxim.org.za>2008-04-02 16:52:19 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-04-04 04:52:23 -0400
commit565ac44593d17bdfc9f595614b56bb335a9b8d6f (patch)
tree42438439fc8116a5f1a07e919f5695435e6b6c63 /arch/arm/mach-at91/pm.c
parentf5d0f4574fe1584891b5167fb0ba42974af13e49 (diff)
[ARM] 4907/1: [AT91] SAM9/CAP9 reset reason
The Reset controller on the SAM9/CAP9 processors will store the reason for the last system reset. On startup, display this information (wakeup signal, RTT alarm, watchdog reset, user reset, etc) Based on patch from David Brownell. Signed-off-by: Andrew Victor <linux@maxim.org.za> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-at91/pm.c')
-rw-r--r--arch/arm/mach-at91/pm.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 77d9669810ed..39733b6992aa 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -83,6 +83,79 @@ static inline void sdram_selfrefresh_enable(void)
83#endif 83#endif
84 84
85 85
86/*
87 * Show the reason for the previous system reset.
88 */
89#if defined(AT91_SHDWC)
90
91#include <asm/arch/at91_rstc.h>
92#include <asm/arch/at91_shdwc.h>
93
94static void __init show_reset_status(void)
95{
96 static char reset[] __initdata = "reset";
97
98 static char general[] __initdata = "general";
99 static char wakeup[] __initdata = "wakeup";
100 static char watchdog[] __initdata = "watchdog";
101 static char software[] __initdata = "software";
102 static char user[] __initdata = "user";
103 static char unknown[] __initdata = "unknown";
104
105 static char signal[] __initdata = "signal";
106 static char rtc[] __initdata = "rtc";
107 static char rtt[] __initdata = "rtt";
108 static char restore[] __initdata = "power-restored";
109
110 char *reason, *r2 = reset;
111 u32 reset_type, wake_type;
112
113 reset_type = at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP;
114 wake_type = at91_sys_read(AT91_SHDW_SR);
115
116 switch (reset_type) {
117 case AT91_RSTC_RSTTYP_GENERAL:
118 reason = general;
119 break;
120 case AT91_RSTC_RSTTYP_WAKEUP:
121 /* board-specific code enabled the wakeup sources */
122 reason = wakeup;
123
124 /* "wakeup signal" */
125 if (wake_type & AT91_SHDW_WAKEUP0)
126 r2 = signal;
127 else {
128 r2 = reason;
129 if (wake_type & AT91_SHDW_RTTWK) /* rtt wakeup */
130 reason = rtt;
131 else if (wake_type & AT91_SHDW_RTCWK) /* rtc wakeup */
132 reason = rtc;
133 else if (wake_type == 0) /* power-restored wakeup */
134 reason = restore;
135 else /* unknown wakeup */
136 reason = unknown;
137 }
138 break;
139 case AT91_RSTC_RSTTYP_WATCHDOG:
140 reason = watchdog;
141 break;
142 case AT91_RSTC_RSTTYP_SOFTWARE:
143 reason = software;
144 break;
145 case AT91_RSTC_RSTTYP_USER:
146 reason = user;
147 break;
148 default:
149 reason = unknown;
150 break;
151 }
152 pr_info("AT91: Starting after %s %s\n", reason, r2);
153}
154#else
155static void __init show_reset_status(void) {}
156#endif
157
158
86static int at91_pm_valid_state(suspend_state_t state) 159static int at91_pm_valid_state(suspend_state_t state)
87{ 160{
88 switch (state) { 161 switch (state) {
@@ -294,6 +367,7 @@ static int __init at91_pm_init(void)
294 367
295 suspend_set_ops(&at91_pm_ops); 368 suspend_set_ops(&at91_pm_ops);
296 369
370 show_reset_status();
297 return 0; 371 return 0;
298} 372}
299arch_initcall(at91_pm_init); 373arch_initcall(at91_pm_init);