diff options
Diffstat (limited to 'arch/arm/mach-at91/pm.c')
-rw-r--r-- | arch/arm/mach-at91/pm.c | 104 |
1 files changed, 20 insertions, 84 deletions
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index e95554532987..4073ab7f38f3 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c | |||
@@ -34,79 +34,8 @@ | |||
34 | #include "pm.h" | 34 | #include "pm.h" |
35 | #include "gpio.h" | 35 | #include "gpio.h" |
36 | 36 | ||
37 | /* | ||
38 | * Show the reason for the previous system reset. | ||
39 | */ | ||
40 | |||
41 | #include "at91_rstc.h" | ||
42 | #include "at91_shdwc.h" | ||
43 | |||
44 | static void (*at91_pm_standby)(void); | 37 | static void (*at91_pm_standby)(void); |
45 | 38 | ||
46 | static void __init show_reset_status(void) | ||
47 | { | ||
48 | static char reset[] __initdata = "reset"; | ||
49 | |||
50 | static char general[] __initdata = "general"; | ||
51 | static char wakeup[] __initdata = "wakeup"; | ||
52 | static char watchdog[] __initdata = "watchdog"; | ||
53 | static char software[] __initdata = "software"; | ||
54 | static char user[] __initdata = "user"; | ||
55 | static char unknown[] __initdata = "unknown"; | ||
56 | |||
57 | static char signal[] __initdata = "signal"; | ||
58 | static char rtc[] __initdata = "rtc"; | ||
59 | static char rtt[] __initdata = "rtt"; | ||
60 | static char restore[] __initdata = "power-restored"; | ||
61 | |||
62 | char *reason, *r2 = reset; | ||
63 | u32 reset_type, wake_type; | ||
64 | |||
65 | if (!at91_shdwc_base || !at91_rstc_base) | ||
66 | return; | ||
67 | |||
68 | reset_type = at91_rstc_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP; | ||
69 | wake_type = at91_shdwc_read(AT91_SHDW_SR); | ||
70 | |||
71 | switch (reset_type) { | ||
72 | case AT91_RSTC_RSTTYP_GENERAL: | ||
73 | reason = general; | ||
74 | break; | ||
75 | case AT91_RSTC_RSTTYP_WAKEUP: | ||
76 | /* board-specific code enabled the wakeup sources */ | ||
77 | reason = wakeup; | ||
78 | |||
79 | /* "wakeup signal" */ | ||
80 | if (wake_type & AT91_SHDW_WAKEUP0) | ||
81 | r2 = signal; | ||
82 | else { | ||
83 | r2 = reason; | ||
84 | if (wake_type & AT91_SHDW_RTTWK) /* rtt wakeup */ | ||
85 | reason = rtt; | ||
86 | else if (wake_type & AT91_SHDW_RTCWK) /* rtc wakeup */ | ||
87 | reason = rtc; | ||
88 | else if (wake_type == 0) /* power-restored wakeup */ | ||
89 | reason = restore; | ||
90 | else /* unknown wakeup */ | ||
91 | reason = unknown; | ||
92 | } | ||
93 | break; | ||
94 | case AT91_RSTC_RSTTYP_WATCHDOG: | ||
95 | reason = watchdog; | ||
96 | break; | ||
97 | case AT91_RSTC_RSTTYP_SOFTWARE: | ||
98 | reason = software; | ||
99 | break; | ||
100 | case AT91_RSTC_RSTTYP_USER: | ||
101 | reason = user; | ||
102 | break; | ||
103 | default: | ||
104 | reason = unknown; | ||
105 | break; | ||
106 | } | ||
107 | pr_info("AT91: Starting after %s %s\n", reason, r2); | ||
108 | } | ||
109 | |||
110 | static int at91_pm_valid_state(suspend_state_t state) | 39 | static int at91_pm_valid_state(suspend_state_t state) |
111 | { | 40 | { |
112 | switch (state) { | 41 | switch (state) { |
@@ -206,16 +135,19 @@ static int at91_pm_enter(suspend_state_t state) | |||
206 | at91_pinctrl_gpio_suspend(); | 135 | at91_pinctrl_gpio_suspend(); |
207 | else | 136 | else |
208 | at91_gpio_suspend(); | 137 | at91_gpio_suspend(); |
209 | at91_irq_suspend(); | ||
210 | 138 | ||
211 | pr_debug("AT91: PM - wake mask %08x, pm state %d\n", | 139 | if (IS_ENABLED(CONFIG_OLD_IRQ_AT91) && at91_aic_base) { |
212 | /* remember all the always-wake irqs */ | 140 | at91_irq_suspend(); |
213 | (at91_pmc_read(AT91_PMC_PCSR) | 141 | |
214 | | (1 << AT91_ID_FIQ) | 142 | pr_debug("AT91: PM - wake mask %08x, pm state %d\n", |
215 | | (1 << AT91_ID_SYS) | 143 | /* remember all the always-wake irqs */ |
216 | | (at91_get_extern_irq())) | 144 | (at91_pmc_read(AT91_PMC_PCSR) |
217 | & at91_aic_read(AT91_AIC_IMR), | 145 | | (1 << AT91_ID_FIQ) |
218 | state); | 146 | | (1 << AT91_ID_SYS) |
147 | | (at91_get_extern_irq())) | ||
148 | & at91_aic_read(AT91_AIC_IMR), | ||
149 | state); | ||
150 | } | ||
219 | 151 | ||
220 | switch (state) { | 152 | switch (state) { |
221 | /* | 153 | /* |
@@ -280,12 +212,17 @@ static int at91_pm_enter(suspend_state_t state) | |||
280 | goto error; | 212 | goto error; |
281 | } | 213 | } |
282 | 214 | ||
283 | pr_debug("AT91: PM - wakeup %08x\n", | 215 | if (IS_ENABLED(CONFIG_OLD_IRQ_AT91) && at91_aic_base) |
284 | at91_aic_read(AT91_AIC_IPR) & at91_aic_read(AT91_AIC_IMR)); | 216 | pr_debug("AT91: PM - wakeup %08x\n", |
217 | at91_aic_read(AT91_AIC_IPR) & | ||
218 | at91_aic_read(AT91_AIC_IMR)); | ||
285 | 219 | ||
286 | error: | 220 | error: |
287 | target_state = PM_SUSPEND_ON; | 221 | target_state = PM_SUSPEND_ON; |
288 | at91_irq_resume(); | 222 | |
223 | if (IS_ENABLED(CONFIG_OLD_IRQ_AT91) && at91_aic_base) | ||
224 | at91_irq_resume(); | ||
225 | |||
289 | if (of_have_populated_dt()) | 226 | if (of_have_populated_dt()) |
290 | at91_pinctrl_gpio_resume(); | 227 | at91_pinctrl_gpio_resume(); |
291 | else | 228 | else |
@@ -338,7 +275,6 @@ static int __init at91_pm_init(void) | |||
338 | 275 | ||
339 | suspend_set_ops(&at91_pm_ops); | 276 | suspend_set_ops(&at91_pm_ops); |
340 | 277 | ||
341 | show_reset_status(); | ||
342 | return 0; | 278 | return 0; |
343 | } | 279 | } |
344 | arch_initcall(at91_pm_init); | 280 | arch_initcall(at91_pm_init); |