aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-01-15 09:59:24 -0500
committerNicolas Ferre <nicolas.ferre@atmel.com>2015-01-16 12:07:24 -0500
commitf5598d346e36169f3eb4008c895300a39b100a0b (patch)
tree981190833d3f965d0cbcbc1376550168681aae39
parenteca6f17253f33313eeb3020d0634a60d10f650c4 (diff)
ARM: at91: pm: rework cpu detection
Store SoC differences in a struct to remove cpu_is_* usage. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
-rw-r--r--arch/arm/mach-at91/pm.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 9b15169a1c62..79aa793d1f00 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -17,6 +17,7 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/sysfs.h> 18#include <linux/sysfs.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/of.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
21#include <linux/io.h> 22#include <linux/io.h>
22#include <linux/clk/at91_pmc.h> 23#include <linux/clk/at91_pmc.h>
@@ -32,6 +33,11 @@
32#include "generic.h" 33#include "generic.h"
33#include "pm.h" 34#include "pm.h"
34 35
36static struct {
37 unsigned long uhp_udp_mask;
38 int memctrl;
39} at91_pm_data;
40
35static void (*at91_pm_standby)(void); 41static void (*at91_pm_standby)(void);
36 42
37static int at91_pm_valid_state(suspend_state_t state) 43static int at91_pm_valid_state(suspend_state_t state)
@@ -71,17 +77,9 @@ static int at91_pm_verify_clocks(void)
71 scsr = at91_pmc_read(AT91_PMC_SCSR); 77 scsr = at91_pmc_read(AT91_PMC_SCSR);
72 78
73 /* USB must not be using PLLB */ 79 /* USB must not be using PLLB */
74 if (cpu_is_at91rm9200()) { 80 if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
75 if ((scsr & (AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP)) != 0) { 81 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
76 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); 82 return 0;
77 return 0;
78 }
79 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()
80 || cpu_is_at91sam9g20() || cpu_is_at91sam9g10()) {
81 if ((scsr & (AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP)) != 0) {
82 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
83 return 0;
84 }
85 } 83 }
86 84
87 /* PCK0..PCK3 must be disabled, or configured to use clk32k */ 85 /* PCK0..PCK3 must be disabled, or configured to use clk32k */
@@ -149,18 +147,13 @@ static int at91_pm_enter(suspend_state_t state)
149 * turning off the main oscillator; reverse on wakeup. 147 * turning off the main oscillator; reverse on wakeup.
150 */ 148 */
151 if (slow_clock) { 149 if (slow_clock) {
152 int memctrl = AT91_MEMCTRL_SDRAMC;
153
154 if (cpu_is_at91rm9200())
155 memctrl = AT91_MEMCTRL_MC;
156 else if (cpu_is_at91sam9g45())
157 memctrl = AT91_MEMCTRL_DDRSDR;
158#ifdef CONFIG_AT91_SLOW_CLOCK 150#ifdef CONFIG_AT91_SLOW_CLOCK
159 /* copy slow_clock handler to SRAM, and call it */ 151 /* copy slow_clock handler to SRAM, and call it */
160 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz); 152 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
161#endif 153#endif
162 slow_clock(at91_pmc_base, at91_ramc_base[0], 154 slow_clock(at91_pmc_base, at91_ramc_base[0],
163 at91_ramc_base[1], memctrl); 155 at91_ramc_base[1],
156 at91_pm_data.memctrl);
164 break; 157 break;
165 } else { 158 } else {
166 pr_info("AT91: PM - no slow clock mode enabled ...\n"); 159 pr_info("AT91: PM - no slow clock mode enabled ...\n");
@@ -237,10 +230,29 @@ static int __init at91_pm_init(void)
237 230
238 pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : "")); 231 pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
239 232
240 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ 233 at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
241 if (cpu_is_at91rm9200()) 234
235 if (of_machine_is_compatible("atmel,at91rm9200")) {
236 /*
237 * AT91RM9200 SDRAM low-power mode cannot be used with
238 * self-refresh.
239 */
242 at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0); 240 at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
243 241
242 at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP |
243 AT91RM9200_PMC_UDP;
244 at91_pm_data.memctrl = AT91_MEMCTRL_MC;
245 } else if (of_machine_is_compatible("atmel,at91sam9260") ||
246 of_machine_is_compatible("atmel,at91sam9g20") ||
247 of_machine_is_compatible("atmel,at91sam9261") ||
248 of_machine_is_compatible("atmel,at91sam9g10") ||
249 of_machine_is_compatible("atmel,at91sam9263")) {
250 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP |
251 AT91SAM926x_PMC_UDP;
252 } else if (of_machine_is_compatible("atmel,at91sam9g45")) {
253 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
254 }
255
244 if (at91_cpuidle_device.dev.platform_data) 256 if (at91_cpuidle_device.dev.platform_data)
245 platform_device_register(&at91_cpuidle_device); 257 platform_device_register(&at91_cpuidle_device);
246 258