diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2013-09-22 16:29:57 -0400 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2013-10-16 17:46:13 -0400 |
commit | 5ad945ea58f6cab7490dc149974ccb6514cc569a (patch) | |
tree | 806f516647e1e0676eb9b63e35e4e35e8fc93cde /arch/arm/mach-at91/pm.c | |
parent | ac9f1cc2ce1a178696763444f2a2f8a0ec661772 (diff) |
ARM: at91: cpuidle: Convert to platform driver
Using the platform driver model is a good way to separate the cpuidle specific
code from the low level pm code. It allows to remove the dependency between
these two components.
The platform_device is located in the pm code and a 'set' function has been
added to set the standby function from the AT91_SOC_START initialization
function. Each SoC with a cpuidle driver will set the standby function in the
platform_data field at init time. Then pm code will register the cpuidle
platform device.
The cpuidle driver will register the platform_driver and use the device's
platform_data as a standby callback in the idle path.
The at91_pm_enter function contains a { if then else } based on cpu_is_xx
similar to what was in cpuidle. This is considered dangerous when adding a new
SoC. Like the cpuidle driver, a standby ops is defined and assigned when the
SoC init function specifies what is its standby function and reused in the
at91_pm_enter's 'case' block.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Diffstat (limited to 'arch/arm/mach-at91/pm.c')
-rw-r--r-- | arch/arm/mach-at91/pm.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 15afb5d9271f..9986542e8060 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c | |||
@@ -39,6 +39,8 @@ | |||
39 | #include "at91_rstc.h" | 39 | #include "at91_rstc.h" |
40 | #include "at91_shdwc.h" | 40 | #include "at91_shdwc.h" |
41 | 41 | ||
42 | static void (*at91_pm_standby)(void); | ||
43 | |||
42 | static void __init show_reset_status(void) | 44 | static void __init show_reset_status(void) |
43 | { | 45 | { |
44 | static char reset[] __initdata = "reset"; | 46 | static char reset[] __initdata = "reset"; |
@@ -266,14 +268,8 @@ static int at91_pm_enter(suspend_state_t state) | |||
266 | * For ARM 926 based chips, this requirement is weaker | 268 | * For ARM 926 based chips, this requirement is weaker |
267 | * as at91sam9 can access a RAM in self-refresh mode. | 269 | * as at91sam9 can access a RAM in self-refresh mode. |
268 | */ | 270 | */ |
269 | if (cpu_is_at91rm9200()) | 271 | if (at91_pm_standby) |
270 | at91rm9200_standby(); | 272 | at91_pm_standby(); |
271 | else if (cpu_is_at91sam9g45()) | ||
272 | at91sam9g45_standby(); | ||
273 | else if (cpu_is_at91sam9263()) | ||
274 | at91sam9263_standby(); | ||
275 | else | ||
276 | at91sam9_standby(); | ||
277 | break; | 273 | break; |
278 | 274 | ||
279 | case PM_SUSPEND_ON: | 275 | case PM_SUSPEND_ON: |
@@ -314,6 +310,18 @@ static const struct platform_suspend_ops at91_pm_ops = { | |||
314 | .end = at91_pm_end, | 310 | .end = at91_pm_end, |
315 | }; | 311 | }; |
316 | 312 | ||
313 | static struct platform_device at91_cpuidle_device = { | ||
314 | .name = "cpuidle-at91", | ||
315 | }; | ||
316 | |||
317 | void at91_pm_set_standby(void (*at91_standby)(void)) | ||
318 | { | ||
319 | if (at91_standby) { | ||
320 | at91_cpuidle_device.dev.platform_data = at91_standby; | ||
321 | at91_pm_standby = at91_standby; | ||
322 | } | ||
323 | } | ||
324 | |||
317 | static int __init at91_pm_init(void) | 325 | static int __init at91_pm_init(void) |
318 | { | 326 | { |
319 | #ifdef CONFIG_AT91_SLOW_CLOCK | 327 | #ifdef CONFIG_AT91_SLOW_CLOCK |
@@ -325,6 +333,9 @@ static int __init at91_pm_init(void) | |||
325 | /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ | 333 | /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ |
326 | if (cpu_is_at91rm9200()) | 334 | if (cpu_is_at91rm9200()) |
327 | at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0); | 335 | at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0); |
336 | |||
337 | if (at91_cpuidle_device.dev.platform_data) | ||
338 | platform_device_register(&at91_cpuidle_device); | ||
328 | 339 | ||
329 | suspend_set_ops(&at91_pm_ops); | 340 | suspend_set_ops(&at91_pm_ops); |
330 | 341 | ||