Commit ccc12b32dc8c8e88a5b35f8df34ec7c80f2e10b0
Committed by
Sascha Hauer
1 parent
2da50e6284
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
ARM: imx: Add imx5 cpuidle
Add cpuidle driver for imx5 platform. Signed-off-by: Robert Lee <rob.lee@linaro.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Showing 1 changed file with 41 additions and 2 deletions Side-by-side Diff
arch/arm/mach-imx/pm-imx5.c
... | ... | @@ -12,10 +12,12 @@ |
12 | 12 | #include <linux/clk.h> |
13 | 13 | #include <linux/io.h> |
14 | 14 | #include <linux/err.h> |
15 | +#include <linux/export.h> | |
15 | 16 | #include <asm/cacheflush.h> |
16 | 17 | #include <asm/system_misc.h> |
17 | 18 | #include <asm/tlbflush.h> |
18 | 19 | #include <mach/common.h> |
20 | +#include <mach/cpuidle.h> | |
19 | 21 | #include <mach/hardware.h> |
20 | 22 | #include "crm-regs-imx5.h" |
21 | 23 | |
22 | 24 | |
23 | 25 | |
24 | 26 | |
... | ... | @@ -134,12 +136,48 @@ |
134 | 136 | .enter = mx5_suspend_enter, |
135 | 137 | }; |
136 | 138 | |
137 | -static void imx5_pm_idle(void) | |
139 | +static inline int imx5_cpu_do_idle(void) | |
138 | 140 | { |
139 | - if (likely(!tzic_enable_wake())) | |
141 | + int ret = tzic_enable_wake(); | |
142 | + | |
143 | + if (likely(!ret)) | |
140 | 144 | cpu_do_idle(); |
145 | + | |
146 | + return ret; | |
141 | 147 | } |
142 | 148 | |
149 | +static void imx5_pm_idle(void) | |
150 | +{ | |
151 | + imx5_cpu_do_idle(); | |
152 | +} | |
153 | + | |
154 | +static int imx5_cpuidle_enter(struct cpuidle_device *dev, | |
155 | + struct cpuidle_driver *drv, int idx) | |
156 | +{ | |
157 | + int ret; | |
158 | + | |
159 | + ret = imx5_cpu_do_idle(); | |
160 | + if (ret < 0) | |
161 | + return ret; | |
162 | + | |
163 | + return idx; | |
164 | +} | |
165 | + | |
166 | +static struct cpuidle_driver imx5_cpuidle_driver = { | |
167 | + .name = "imx5_cpuidle", | |
168 | + .owner = THIS_MODULE, | |
169 | + .en_core_tk_irqen = 1, | |
170 | + .states[0] = { | |
171 | + .enter = imx5_cpuidle_enter, | |
172 | + .exit_latency = 2, | |
173 | + .target_residency = 1, | |
174 | + .flags = CPUIDLE_FLAG_TIME_VALID, | |
175 | + .name = "IMX5 SRPG", | |
176 | + .desc = "CPU state retained,powered off", | |
177 | + }, | |
178 | + .state_count = 1, | |
179 | +}; | |
180 | + | |
143 | 181 | static int __init imx5_pm_common_init(void) |
144 | 182 | { |
145 | 183 | int ret; |
... | ... | @@ -157,6 +195,7 @@ |
157 | 195 | /* Set the registers to the default cpu idle state. */ |
158 | 196 | mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE); |
159 | 197 | |
198 | + imx_cpuidle_init(&imx5_cpuidle_driver); | |
160 | 199 | return 0; |
161 | 200 | } |
162 | 201 |