summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mxs/system.c
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2012-01-27 12:44:29 -0200
committerShawn Guo <shawn.guo@linaro.org>2012-01-31 22:42:15 +0800
commit444a7c3bb897ec6a64b83d277102440c1dcc22a1 (patch)
treef6168d81c13b5e7641ca815bd5703fdee3adc5f5 /arch/arm/mach-mxs/system.c
parenta62407256bbcba8e3f62695a87534050ceec0e6f (diff)
downloadop-kernel-dev-444a7c3bb897ec6a64b83d277102440c1dcc22a1.zip
op-kernel-dev-444a7c3bb897ec6a64b83d277102440c1dcc22a1.tar.gz
ARM: mxs: Use a proper timeout mechanism
Introduce a function for checking the busy bits of CLKCTRL register that uses a proper timeout mechanism. Remove parts of code that use busy loops and replace them with the mxs_clkctrl_timeout() function. Tested on a mx28evk by performing audio playback. Suggested-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Diffstat (limited to 'arch/arm/mach-mxs/system.c')
-rw-r--r--arch/arm/mach-mxs/system.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/arm/mach-mxs/system.c b/arch/arm/mach-mxs/system.c
index 54f91ad..7aa5ac5 100644
--- a/arch/arm/mach-mxs/system.c
+++ b/arch/arm/mach-mxs/system.c
@@ -37,6 +37,8 @@
#define MXS_MODULE_CLKGATE (1 << 30)
#define MXS_MODULE_SFTRST (1 << 31)
+#define CLKCTRL_TIMEOUT 10 /* 10 ms */
+
static void __iomem *mxs_clkctrl_reset_addr;
/*
@@ -137,3 +139,17 @@ error:
return -ETIMEDOUT;
}
EXPORT_SYMBOL(mxs_reset_block);
+
+int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask)
+{
+ unsigned long timeout = jiffies + msecs_to_jiffies(CLKCTRL_TIMEOUT);
+ while (readl_relaxed(MXS_IO_ADDRESS(MXS_CLKCTRL_BASE_ADDR)
+ + reg_offset) & mask) {
+ if (time_after(jiffies, timeout)) {
+ pr_err("Timeout at CLKCTRL + 0x%x\n", reg_offset);
+ return -ETIMEDOUT;
+ }
+ }
+
+ return 0;
+}
OpenPOWER on IntegriCloud