diff options
author | Jean Pihet <j-pihet@ti.com> | 2012-04-24 01:26:40 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@ti.com> | 2012-05-31 19:03:44 -0400 |
commit | 50e4a7d0b26c86628300edf4625cc5ff16a7a227 (patch) | |
tree | 80e493531abd6e27886a2a53fb0192c769168761 | |
parent | 1fcd3069d4944ad0532f41fbc4957ba24552a92f (diff) |
ARM: OMAP2+: SmartReflex: introduce a busy loop condition test macro
Now that omap_test_timeout is only accessible from mach-omap2/,
introduce a similar function for SR.
This change makes the SmartReflex implementation ready for the move
to drivers/.
Signed-off-by: Jean Pihet <j-pihet@ti.com>
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
-rw-r--r-- | arch/arm/mach-omap2/smartreflex.c | 12 | ||||
-rw-r--r-- | include/linux/power/smartreflex.h | 23 |
2 files changed, 28 insertions, 7 deletions
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c index d8592771838f..acef08d837cc 100644 --- a/arch/arm/mach-omap2/smartreflex.c +++ b/arch/arm/mach-omap2/smartreflex.c | |||
@@ -289,9 +289,9 @@ static void sr_v1_disable(struct omap_sr *sr) | |||
289 | * Wait for SR to be disabled. | 289 | * Wait for SR to be disabled. |
290 | * wait until ERRCONFIG.MCUDISACKINTST = 1. Typical latency is 1us. | 290 | * wait until ERRCONFIG.MCUDISACKINTST = 1. Typical latency is 1us. |
291 | */ | 291 | */ |
292 | omap_test_timeout((sr_read_reg(sr, ERRCONFIG_V1) & | 292 | sr_test_cond_timeout((sr_read_reg(sr, ERRCONFIG_V1) & |
293 | ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT, | 293 | ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT, |
294 | timeout); | 294 | timeout); |
295 | 295 | ||
296 | if (timeout >= SR_DISABLE_TIMEOUT) | 296 | if (timeout >= SR_DISABLE_TIMEOUT) |
297 | dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", | 297 | dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", |
@@ -334,9 +334,9 @@ static void sr_v2_disable(struct omap_sr *sr) | |||
334 | * Wait for SR to be disabled. | 334 | * Wait for SR to be disabled. |
335 | * wait until IRQSTATUS.MCUDISACKINTST = 1. Typical latency is 1us. | 335 | * wait until IRQSTATUS.MCUDISACKINTST = 1. Typical latency is 1us. |
336 | */ | 336 | */ |
337 | omap_test_timeout((sr_read_reg(sr, IRQSTATUS) & | 337 | sr_test_cond_timeout((sr_read_reg(sr, IRQSTATUS) & |
338 | IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT, | 338 | IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT, |
339 | timeout); | 339 | timeout); |
340 | 340 | ||
341 | if (timeout >= SR_DISABLE_TIMEOUT) | 341 | if (timeout >= SR_DISABLE_TIMEOUT) |
342 | dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", | 342 | dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", |
diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h index 884eaeea96be..78b795ea2709 100644 --- a/include/linux/power/smartreflex.h +++ b/include/linux/power/smartreflex.h | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/types.h> | 23 | #include <linux/types.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | 25 | #include <linux/delay.h> | |
26 | #include <plat/voltage.h> | 26 | #include <plat/voltage.h> |
27 | 27 | ||
28 | /* | 28 | /* |
@@ -168,6 +168,27 @@ struct omap_sr { | |||
168 | }; | 168 | }; |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * test_cond_timeout - busy-loop, testing a condition | ||
172 | * @cond: condition to test until it evaluates to true | ||
173 | * @timeout: maximum number of microseconds in the timeout | ||
174 | * @index: loop index (integer) | ||
175 | * | ||
176 | * Loop waiting for @cond to become true or until at least @timeout | ||
177 | * microseconds have passed. To use, define some integer @index in the | ||
178 | * calling code. After running, if @index == @timeout, then the loop has | ||
179 | * timed out. | ||
180 | * | ||
181 | * Copied from omap_test_timeout */ | ||
182 | #define sr_test_cond_timeout(cond, timeout, index) \ | ||
183 | ({ \ | ||
184 | for (index = 0; index < timeout; index++) { \ | ||
185 | if (cond) \ | ||
186 | break; \ | ||
187 | udelay(1); \ | ||
188 | } \ | ||
189 | }) | ||
190 | |||
191 | /** | ||
171 | * struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass | 192 | * struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass |
172 | * pmic specific info to smartreflex driver | 193 | * pmic specific info to smartreflex driver |
173 | * | 194 | * |