aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2013-09-22 16:29:57 -0400
committerDaniel Lezcano <daniel.lezcano@linaro.org>2013-10-16 17:46:13 -0400
commit5ad945ea58f6cab7490dc149974ccb6514cc569a (patch)
tree806f516647e1e0676eb9b63e35e4e35e8fc93cde /arch/arm/mach-at91
parentac9f1cc2ce1a178696763444f2a2f8a0ec661772 (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')
-rw-r--r--arch/arm/mach-at91/at91rm9200.c3
-rw-r--r--arch/arm/mach-at91/at91sam9260.c3
-rw-r--r--arch/arm/mach-at91/at91sam9261.c3
-rw-r--r--arch/arm/mach-at91/at91sam9263.c3
-rw-r--r--arch/arm/mach-at91/at91sam9g45.c3
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c3
-rw-r--r--arch/arm/mach-at91/cpuidle.c29
-rw-r--r--arch/arm/mach-at91/pm.c27
-rw-r--r--arch/arm/mach-at91/pm.h4
9 files changed, 56 insertions, 22 deletions
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 4aad93d54d6f..0d234f2a04b3 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -27,6 +27,7 @@
27#include "generic.h" 27#include "generic.h"
28#include "clock.h" 28#include "clock.h"
29#include "sam9_smc.h" 29#include "sam9_smc.h"
30#include "pm.h"
30 31
31/* -------------------------------------------------------------------- 32/* --------------------------------------------------------------------
32 * Clocks 33 * Clocks
@@ -337,6 +338,8 @@ static void __init at91rm9200_initialize(void)
337 /* Initialize GPIO subsystem */ 338 /* Initialize GPIO subsystem */
338 at91_gpio_init(at91rm9200_gpio, 339 at91_gpio_init(at91rm9200_gpio,
339 cpu_is_at91rm9200_bga() ? AT91RM9200_BGA : AT91RM9200_PQFP); 340 cpu_is_at91rm9200_bga() ? AT91RM9200_BGA : AT91RM9200_PQFP);
341
342 at91_pm_set_standby(at91rm9200_standby);
340} 343}
341 344
342 345
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 5de6074b4f4f..ffe9ce70b53a 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -28,6 +28,7 @@
28#include "generic.h" 28#include "generic.h"
29#include "clock.h" 29#include "clock.h"
30#include "sam9_smc.h" 30#include "sam9_smc.h"
31#include "pm.h"
31 32
32/* -------------------------------------------------------------------- 33/* --------------------------------------------------------------------
33 * Clocks 34 * Clocks
@@ -351,6 +352,8 @@ static void __init at91sam9260_initialize(void)
351 352
352 /* Register GPIO subsystem */ 353 /* Register GPIO subsystem */
353 at91_gpio_init(at91sam9260_gpio, 3); 354 at91_gpio_init(at91sam9260_gpio, 3);
355
356 at91_pm_set_standby(at91sam9_standby);
354} 357}
355 358
356/* -------------------------------------------------------------------- 359/* --------------------------------------------------------------------
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 0e0793241ab7..1edbb6fd4636 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -27,6 +27,7 @@
27#include "generic.h" 27#include "generic.h"
28#include "clock.h" 28#include "clock.h"
29#include "sam9_smc.h" 29#include "sam9_smc.h"
30#include "pm.h"
30 31
31/* -------------------------------------------------------------------- 32/* --------------------------------------------------------------------
32 * Clocks 33 * Clocks
@@ -293,6 +294,8 @@ static void __init at91sam9261_initialize(void)
293 294
294 /* Register GPIO subsystem */ 295 /* Register GPIO subsystem */
295 at91_gpio_init(at91sam9261_gpio, 3); 296 at91_gpio_init(at91sam9261_gpio, 3);
297
298 at91_pm_set_sandby(at91sam9_standby);
296} 299}
297 300
298/* -------------------------------------------------------------------- 301/* --------------------------------------------------------------------
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 6ce7d1850893..8c81c890618c 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -26,6 +26,7 @@
26#include "generic.h" 26#include "generic.h"
27#include "clock.h" 27#include "clock.h"
28#include "sam9_smc.h" 28#include "sam9_smc.h"
29#include "pm.h"
29 30
30/* -------------------------------------------------------------------- 31/* --------------------------------------------------------------------
31 * Clocks 32 * Clocks
@@ -330,6 +331,8 @@ static void __init at91sam9263_initialize(void)
330 331
331 /* Register GPIO subsystem */ 332 /* Register GPIO subsystem */
332 at91_gpio_init(at91sam9263_gpio, 5); 333 at91_gpio_init(at91sam9263_gpio, 5);
334
335 at91_pm_set_standby(at91sam9263_standby);
333} 336}
334 337
335/* -------------------------------------------------------------------- 338/* --------------------------------------------------------------------
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 474ee04d24b9..8460f521c20b 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -26,6 +26,7 @@
26#include "generic.h" 26#include "generic.h"
27#include "clock.h" 27#include "clock.h"
28#include "sam9_smc.h" 28#include "sam9_smc.h"
29#include "pm.h"
29 30
30/* -------------------------------------------------------------------- 31/* --------------------------------------------------------------------
31 * Clocks 32 * Clocks
@@ -379,6 +380,8 @@ static void __init at91sam9g45_initialize(void)
379 380
380 /* Register GPIO subsystem */ 381 /* Register GPIO subsystem */
381 at91_gpio_init(at91sam9g45_gpio, 5); 382 at91_gpio_init(at91sam9g45_gpio, 5);
383
384 at91_pm_set_standby(at91sam9g45_standby);
382} 385}
383 386
384/* -------------------------------------------------------------------- 387/* --------------------------------------------------------------------
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index d4ec0d9a9872..c7986e4f4e0e 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -27,6 +27,7 @@
27#include "generic.h" 27#include "generic.h"
28#include "clock.h" 28#include "clock.h"
29#include "sam9_smc.h" 29#include "sam9_smc.h"
30#include "pm.h"
30 31
31/* -------------------------------------------------------------------- 32/* --------------------------------------------------------------------
32 * Clocks 33 * Clocks
@@ -296,6 +297,8 @@ static void __init at91sam9rl_initialize(void)
296 297
297 /* Register GPIO subsystem */ 298 /* Register GPIO subsystem */
298 at91_gpio_init(at91sam9rl_gpio, 4); 299 at91_gpio_init(at91sam9rl_gpio, 4);
300
301 at91_pm_set_standby(at91sam9_standby);
299} 302}
300 303
301/* -------------------------------------------------------------------- 304/* --------------------------------------------------------------------
diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
index 4ec6a6d9b9be..a0774370c6bc 100644
--- a/arch/arm/mach-at91/cpuidle.c
+++ b/arch/arm/mach-at91/cpuidle.c
@@ -21,26 +21,17 @@
21#include <linux/export.h> 21#include <linux/export.h>
22#include <asm/proc-fns.h> 22#include <asm/proc-fns.h>
23#include <asm/cpuidle.h> 23#include <asm/cpuidle.h>
24#include <mach/cpu.h>
25
26#include "pm.h"
27 24
28#define AT91_MAX_STATES 2 25#define AT91_MAX_STATES 2
29 26
27static void (*at91_standby)(void);
28
30/* Actual code that puts the SoC in different idle states */ 29/* Actual code that puts the SoC in different idle states */
31static int at91_enter_idle(struct cpuidle_device *dev, 30static int at91_enter_idle(struct cpuidle_device *dev,
32 struct cpuidle_driver *drv, 31 struct cpuidle_driver *drv,
33 int index) 32 int index)
34{ 33{
35 if (cpu_is_at91rm9200()) 34 at91_standby();
36 at91rm9200_standby();
37 else if (cpu_is_at91sam9g45())
38 at91sam9g45_standby();
39 else if (cpu_is_at91sam9263())
40 at91sam9263_standby();
41 else
42 at91sam9_standby();
43
44 return index; 35 return index;
45} 36}
46 37
@@ -60,9 +51,19 @@ static struct cpuidle_driver at91_idle_driver = {
60}; 51};
61 52
62/* Initialize CPU idle by registering the idle states */ 53/* Initialize CPU idle by registering the idle states */
63static int __init at91_init_cpuidle(void) 54static int at91_cpuidle_probe(struct platform_device *dev)
64{ 55{
56 at91_standby = (void *)(dev->dev.platform_data);
57
65 return cpuidle_register(&at91_idle_driver, NULL); 58 return cpuidle_register(&at91_idle_driver, NULL);
66} 59}
67 60
68device_initcall(at91_init_cpuidle); 61static struct platform_driver at91_cpuidle_driver = {
62 .driver = {
63 .name = "cpuidle-at91",
64 .owner = THIS_MODULE,
65 },
66 .probe = at91_cpuidle_probe,
67};
68
69module_platform_driver(at91_cpuidle_driver);
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
42static void (*at91_pm_standby)(void);
43
42static void __init show_reset_status(void) 44static 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
313static struct platform_device at91_cpuidle_device = {
314 .name = "cpuidle-at91",
315};
316
317void 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
317static int __init at91_pm_init(void) 325static 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
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index 2f5908f0b8c5..76dd1a749ebd 100644
--- a/arch/arm/mach-at91/pm.h
+++ b/arch/arm/mach-at91/pm.h
@@ -11,9 +11,13 @@
11#ifndef __ARCH_ARM_MACH_AT91_PM 11#ifndef __ARCH_ARM_MACH_AT91_PM
12#define __ARCH_ARM_MACH_AT91_PM 12#define __ARCH_ARM_MACH_AT91_PM
13 13
14#include <asm/proc-fns.h>
15
14#include <mach/at91_ramc.h> 16#include <mach/at91_ramc.h>
15#include <mach/at91rm9200_sdramc.h> 17#include <mach/at91rm9200_sdramc.h>
16 18
19extern void at91_pm_set_standby(void (*at91_standby)(void));
20
17/* 21/*
18 * The AT91RM9200 goes into self-refresh mode with this command, and will 22 * The AT91RM9200 goes into self-refresh mode with this command, and will
19 * terminate self-refresh automatically on the next SDRAM access. 23 * terminate self-refresh automatically on the next SDRAM access.