summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mxs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-11-16 14:02:36 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-16 14:02:36 +0100
commit3ff1015d247f754a4c06c2fb66a01668fe810f17 (patch)
treef358965902d83cd073c00f2476250e917427d564 /arch/arm/mach-mxs
parent9749c2f16f61048a66a98a95b6a1e88d4f491cf0 (diff)
parentdf1e09fb061384cb51405a55dcf454c7341f34b7 (diff)
downloadbarebox-3ff1015d247f754a4c06c2fb66a01668fe810f17.tar.gz
barebox-3ff1015d247f754a4c06c2fb66a01668fe810f17.tar.xz
Merge branch 'for-next/mxs'
Diffstat (limited to 'arch/arm/mach-mxs')
-rw-r--r--arch/arm/mach-mxs/common.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/arch/arm/mach-mxs/common.c b/arch/arm/mach-mxs/common.c
index 3730633c71..122d88362b 100644
--- a/arch/arm/mach-mxs/common.c
+++ b/arch/arm/mach-mxs/common.c
@@ -1,8 +1,26 @@
+/*
+ * Freescale i.MXS common code
+ *
+ * Copyright (C) 2012 Wolfram Sang <w.sang@pengutronix.de>
+ *
+ * Based on code from LTIB:
+ * Copyright (C) 2010 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
#include <common.h>
#include <io.h>
+#include <errno.h>
+#include <clock.h>
#include <mach/mxs.h>
#include <mach/imx-regs.h>
+#define MXS_IP_RESET_TIMEOUT (10 * MSECOND)
+
#define MXS_BLOCK_SFTRST (1 << 31)
#define MXS_BLOCK_CLKGATE (1 << 30)
@@ -10,7 +28,9 @@ int mxs_reset_block(void __iomem *reg, int just_enable)
{
/* Clear SFTRST */
writel(MXS_BLOCK_SFTRST, reg + BIT_CLR);
- mdelay(1);
+
+ if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_SFTRST)))
+ goto timeout;
/* Clear CLKGATE */
writel(MXS_BLOCK_CLKGATE, reg + BIT_CLR);
@@ -18,16 +38,27 @@ int mxs_reset_block(void __iomem *reg, int just_enable)
if (!just_enable) {
/* Set SFTRST */
writel(MXS_BLOCK_SFTRST, reg + BIT_SET);
- mdelay(1);
+
+ /* Wait for CLKGATE being set */
+ if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, readl(reg) & MXS_BLOCK_CLKGATE))
+ goto timeout;
}
/* Clear SFTRST */
writel(MXS_BLOCK_SFTRST, reg + BIT_CLR);
- mdelay(1);
+
+ if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_SFTRST)))
+ goto timeout;
/* Clear CLKGATE */
writel(MXS_BLOCK_CLKGATE, reg + BIT_CLR);
- mdelay(1);
+
+ if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_CLKGATE)))
+ goto timeout;
return 0;
+
+timeout:
+ printf("MXS: Timeout resetting block via register 0x%p\n", reg);
+ return -ETIMEDOUT;
}