Commit 50e4a7d0 authored by Jean Pihet's avatar Jean Pihet Committed by Kevin Hilman

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: default avatarJean Pihet <j-pihet@ti.com>
Signed-off-by: default avatarJ Keerthy <j-keerthy@ti.com>
Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent 1fcd3069
...@@ -289,9 +289,9 @@ static void sr_v1_disable(struct omap_sr *sr) ...@@ -289,9 +289,9 @@ static void sr_v1_disable(struct omap_sr *sr)
* Wait for SR to be disabled. * Wait for SR to be disabled.
* wait until ERRCONFIG.MCUDISACKINTST = 1. Typical latency is 1us. * wait until ERRCONFIG.MCUDISACKINTST = 1. Typical latency is 1us.
*/ */
omap_test_timeout((sr_read_reg(sr, ERRCONFIG_V1) & sr_test_cond_timeout((sr_read_reg(sr, ERRCONFIG_V1) &
ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT, ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT,
timeout); timeout);
if (timeout >= SR_DISABLE_TIMEOUT) if (timeout >= SR_DISABLE_TIMEOUT)
dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n",
...@@ -334,9 +334,9 @@ static void sr_v2_disable(struct omap_sr *sr) ...@@ -334,9 +334,9 @@ static void sr_v2_disable(struct omap_sr *sr)
* Wait for SR to be disabled. * Wait for SR to be disabled.
* wait until IRQSTATUS.MCUDISACKINTST = 1. Typical latency is 1us. * wait until IRQSTATUS.MCUDISACKINTST = 1. Typical latency is 1us.
*/ */
omap_test_timeout((sr_read_reg(sr, IRQSTATUS) & sr_test_cond_timeout((sr_read_reg(sr, IRQSTATUS) &
IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT, IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT,
timeout); timeout);
if (timeout >= SR_DISABLE_TIMEOUT) if (timeout >= SR_DISABLE_TIMEOUT)
dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n",
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h>
#include <plat/voltage.h> #include <plat/voltage.h>
/* /*
...@@ -167,6 +167,27 @@ struct omap_sr { ...@@ -167,6 +167,27 @@ struct omap_sr {
void __iomem *base; void __iomem *base;
}; };
/**
* test_cond_timeout - busy-loop, testing a condition
* @cond: condition to test until it evaluates to true
* @timeout: maximum number of microseconds in the timeout
* @index: loop index (integer)
*
* Loop waiting for @cond to become true or until at least @timeout
* microseconds have passed. To use, define some integer @index in the
* calling code. After running, if @index == @timeout, then the loop has
* timed out.
*
* Copied from omap_test_timeout */
#define sr_test_cond_timeout(cond, timeout, index) \
({ \
for (index = 0; index < timeout; index++) { \
if (cond) \
break; \
udelay(1); \
} \
})
/** /**
* struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass * struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass
* pmic specific info to smartreflex driver * pmic specific info to smartreflex driver
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment