diff options
author | Robert Lee <rob.lee@linaro.org> | 2012-03-20 16:22:44 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2012-03-21 02:00:25 -0400 |
commit | b334648db0ff2d07b00d81cf033c6eddff277680 (patch) | |
tree | b7628cf7bc7b395bd0bd378b5a996041822693c7 /arch/arm/mach-kirkwood/cpuidle.c | |
parent | 7e348b9012522fa0efd854d20d210d5e57fcedd1 (diff) |
ARM: kirkwood: 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/arm/mach-kirkwood/cpuidle.c')
-rw-r--r-- | arch/arm/mach-kirkwood/cpuidle.c | 72 |
1 files changed, 21 insertions, 51 deletions
diff --git a/arch/arm/mach-kirkwood/cpuidle.c b/arch/arm/mach-kirkwood/cpuidle.c index 7088180b018b..0f1710941878 100644 --- a/arch/arm/mach-kirkwood/cpuidle.c +++ b/arch/arm/mach-kirkwood/cpuidle.c | |||
@@ -20,77 +20,47 @@ | |||
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
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 <mach/kirkwood.h> | 24 | #include <mach/kirkwood.h> |
24 | 25 | ||
25 | #define KIRKWOOD_MAX_STATES 2 | 26 | #define KIRKWOOD_MAX_STATES 2 |
26 | 27 | ||
27 | static struct cpuidle_driver kirkwood_idle_driver = { | ||
28 | .name = "kirkwood_idle", | ||
29 | .owner = THIS_MODULE, | ||
30 | }; | ||
31 | |||
32 | static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device); | ||
33 | |||
34 | /* Actual code that puts the SoC in different idle states */ | 28 | /* Actual code that puts the SoC in different idle states */ |
35 | static int kirkwood_enter_idle(struct cpuidle_device *dev, | 29 | static int kirkwood_enter_idle(struct cpuidle_device *dev, |
36 | struct cpuidle_driver *drv, | 30 | struct cpuidle_driver *drv, |
37 | int index) | 31 | int index) |
38 | { | 32 | { |
39 | struct timeval before, after; | 33 | writel(0x7, DDR_OPERATION_BASE); |
40 | int idle_time; | 34 | cpu_do_idle(); |
41 | |||
42 | local_irq_disable(); | ||
43 | do_gettimeofday(&before); | ||
44 | if (index == 0) | ||
45 | /* Wait for interrupt state */ | ||
46 | cpu_do_idle(); | ||
47 | else if (index == 1) { | ||
48 | /* | ||
49 | * Following write will put DDR in self refresh. | ||
50 | * Note that we have 256 cycles before DDR puts it | ||
51 | * self in self-refresh, so the wait-for-interrupt | ||
52 | * call afterwards won't get the DDR from self refresh | ||
53 | * mode. | ||
54 | */ | ||
55 | writel(0x7, DDR_OPERATION_BASE); | ||
56 | cpu_do_idle(); | ||
57 | } | ||
58 | do_gettimeofday(&after); | ||
59 | local_irq_enable(); | ||
60 | idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + | ||
61 | (after.tv_usec - before.tv_usec); | ||
62 | |||
63 | /* Update last residency */ | ||
64 | dev->last_residency = idle_time; | ||
65 | 35 | ||
66 | return index; | 36 | return index; |
67 | } | 37 | } |
68 | 38 | ||
39 | static struct cpuidle_driver kirkwood_idle_driver = { | ||
40 | .name = "kirkwood_idle", | ||
41 | .owner = THIS_MODULE, | ||
42 | .en_core_tk_irqen = 1, | ||
43 | .states[0] = ARM_CPUIDLE_WFI_STATE, | ||
44 | .states[1] = { | ||
45 | .enter = kirkwood_enter_idle, | ||
46 | .exit_latency = 10, | ||
47 | .target_residency = 100000, | ||
48 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
49 | .name = "DDR SR", | ||
50 | .desc = "WFI and DDR Self Refresh", | ||
51 | }, | ||
52 | .state_count = KIRKWOOD_MAX_STATES, | ||
53 | }; | ||
54 | |||
55 | static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device); | ||
56 | |||
69 | /* Initialize CPU idle by registering the idle states */ | 57 | /* Initialize CPU idle by registering the idle states */ |
70 | static int kirkwood_init_cpuidle(void) | 58 | static int kirkwood_init_cpuidle(void) |
71 | { | 59 | { |
72 | struct cpuidle_device *device; | 60 | struct cpuidle_device *device; |
73 | struct cpuidle_driver *driver = &kirkwood_idle_driver; | ||
74 | 61 | ||
75 | device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id()); | 62 | device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id()); |
76 | device->state_count = KIRKWOOD_MAX_STATES; | 63 | device->state_count = KIRKWOOD_MAX_STATES; |
77 | driver->state_count = KIRKWOOD_MAX_STATES; | ||
78 | |||
79 | /* Wait for interrupt state */ | ||
80 | driver->states[0].enter = kirkwood_enter_idle; | ||
81 | driver->states[0].exit_latency = 1; | ||
82 | driver->states[0].target_residency = 10000; | ||
83 | driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID; | ||
84 | strcpy(driver->states[0].name, "WFI"); | ||
85 | strcpy(driver->states[0].desc, "Wait for interrupt"); | ||
86 | |||
87 | /* Wait for interrupt and DDR self refresh state */ | ||
88 | driver->states[1].enter = kirkwood_enter_idle; | ||
89 | driver->states[1].exit_latency = 10; | ||
90 | driver->states[1].target_residency = 10000; | ||
91 | driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID; | ||
92 | strcpy(driver->states[1].name, "DDR SR"); | ||
93 | strcpy(driver->states[1].desc, "WFI and DDR Self Refresh"); | ||
94 | 64 | ||
95 | cpuidle_register_driver(&kirkwood_idle_driver); | 65 | cpuidle_register_driver(&kirkwood_idle_driver); |
96 | if (cpuidle_register_device(device)) { | 66 | if (cpuidle_register_device(device)) { |