diff options
author | Robert Lee <rob.lee@linaro.org> | 2012-03-20 16:22:43 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2012-03-21 02:00:11 -0400 |
commit | 7e348b9012522fa0efd854d20d210d5e57fcedd1 (patch) | |
tree | 88b594543a03919efa8804a8ce10d00ecabfc028 /arch | |
parent | e1689795a784a7c41ac4cf9032794986b095a133 (diff) |
ARM: at91: Consolidate time keeping and irq enable
Enable core cpuidle timekeeping and irq enabling and remove that
handling from this code.
Signed-off-by: Robert Lee <rob.lee@linaro.org>
Reviewed-by: Kevin Hilman <khilman@ti.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Jean Pihet <j-pihet@ti.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-at91/cpuidle.c | 67 |
1 files changed, 24 insertions, 43 deletions
diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c index a851e6c98421..d40b3f317f7f 100644 --- a/arch/arm/mach-at91/cpuidle.c +++ b/arch/arm/mach-at91/cpuidle.c | |||
@@ -17,9 +17,10 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/cpuidle.h> | 19 | #include <linux/cpuidle.h> |
20 | #include <asm/proc-fns.h> | ||
21 | #include <linux/io.h> | 20 | #include <linux/io.h> |
22 | #include <linux/export.h> | 21 | #include <linux/export.h> |
22 | #include <asm/proc-fns.h> | ||
23 | #include <asm/cpuidle.h> | ||
23 | 24 | ||
24 | #include "pm.h" | 25 | #include "pm.h" |
25 | 26 | ||
@@ -27,66 +28,46 @@ | |||
27 | 28 | ||
28 | static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device); | 29 | static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device); |
29 | 30 | ||
30 | static struct cpuidle_driver at91_idle_driver = { | ||
31 | .name = "at91_idle", | ||
32 | .owner = THIS_MODULE, | ||
33 | }; | ||
34 | |||
35 | /* Actual code that puts the SoC in different idle states */ | 31 | /* Actual code that puts the SoC in different idle states */ |
36 | static int at91_enter_idle(struct cpuidle_device *dev, | 32 | static int at91_enter_idle(struct cpuidle_device *dev, |
37 | struct cpuidle_driver *drv, | 33 | struct cpuidle_driver *drv, |
38 | int index) | 34 | int index) |
39 | { | 35 | { |
40 | struct timeval before, after; | ||
41 | int idle_time; | ||
42 | u32 saved_lpr; | 36 | u32 saved_lpr; |
43 | 37 | ||
44 | local_irq_disable(); | 38 | __asm__("b 1f; .align 5; 1:\n" |
45 | do_gettimeofday(&before); | 39 | " mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */ |
46 | if (index == 0) | 40 | |
47 | /* Wait for interrupt state */ | 41 | saved_lpr = sdram_selfrefresh_enable(); |
48 | cpu_do_idle(); | 42 | cpu_do_idle(); |
49 | else if (index == 1) { | 43 | sdram_selfrefresh_disable(saved_lpr); |
50 | asm("b 1f; .align 5; 1:"); | ||
51 | asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */ | ||
52 | saved_lpr = sdram_selfrefresh_enable(); | ||
53 | cpu_do_idle(); | ||
54 | sdram_selfrefresh_disable(saved_lpr); | ||
55 | } | ||
56 | do_gettimeofday(&after); | ||
57 | local_irq_enable(); | ||
58 | idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + | ||
59 | (after.tv_usec - before.tv_usec); | ||
60 | 44 | ||
61 | dev->last_residency = idle_time; | ||
62 | return index; | 45 | return index; |
63 | } | 46 | } |
64 | 47 | ||
48 | static struct cpuidle_driver at91_idle_driver = { | ||
49 | .name = "at91_idle", | ||
50 | .owner = THIS_MODULE, | ||
51 | .en_core_tk_irqen = 1, | ||
52 | .states[0] = ARM_CPUIDLE_WFI_STATE, | ||
53 | .states[1] = { | ||
54 | .enter = at91_enter_idle, | ||
55 | .exit_latency = 10, | ||
56 | .target_residency = 100000, | ||
57 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
58 | .name = "RAM_SR", | ||
59 | .desc = "WFI and DDR Self Refresh", | ||
60 | }, | ||
61 | .state_count = AT91_MAX_STATES, | ||
62 | }; | ||
63 | |||
65 | /* Initialize CPU idle by registering the idle states */ | 64 | /* Initialize CPU idle by registering the idle states */ |
66 | static int at91_init_cpuidle(void) | 65 | static int at91_init_cpuidle(void) |
67 | { | 66 | { |
68 | struct cpuidle_device *device; | 67 | struct cpuidle_device *device; |
69 | struct cpuidle_driver *driver = &at91_idle_driver; | ||
70 | 68 | ||
71 | device = &per_cpu(at91_cpuidle_device, smp_processor_id()); | 69 | device = &per_cpu(at91_cpuidle_device, smp_processor_id()); |
72 | device->state_count = AT91_MAX_STATES; | 70 | device->state_count = AT91_MAX_STATES; |
73 | driver->state_count = AT91_MAX_STATES; | ||
74 | |||
75 | /* Wait for interrupt state */ | ||
76 | driver->states[0].enter = at91_enter_idle; | ||
77 | driver->states[0].exit_latency = 1; | ||
78 | driver->states[0].target_residency = 10000; | ||
79 | driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID; | ||
80 | strcpy(driver->states[0].name, "WFI"); | ||
81 | strcpy(driver->states[0].desc, "Wait for interrupt"); | ||
82 | |||
83 | /* Wait for interrupt and RAM self refresh state */ | ||
84 | driver->states[1].enter = at91_enter_idle; | ||
85 | driver->states[1].exit_latency = 10; | ||
86 | driver->states[1].target_residency = 10000; | ||
87 | driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID; | ||
88 | strcpy(driver->states[1].name, "RAM_SR"); | ||
89 | strcpy(driver->states[1].desc, "WFI and RAM Self Refresh"); | ||
90 | 71 | ||
91 | cpuidle_register_driver(&at91_idle_driver); | 72 | cpuidle_register_driver(&at91_idle_driver); |
92 | 73 | ||