From 09db5f43f9f36440fcdcf6fbc21257338053bd1c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 5 Feb 2016 14:17:14 +0100 Subject: ARM: i.MX: ocotp: Fix error bit handling Instead of returning an error when a locked region is read, fill the result with 0xbadabada to indicate a locked region is read. This way a md -s /dev/imx-ocotp does not abort when it encounters locked regions. Signed-off-by: Sascha Hauer --- arch/arm/mach-imx/ocotp.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'arch/arm/mach-imx/ocotp.c') diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c index 70a89da0e6..a9df08c1b2 100644 --- a/arch/arm/mach-imx/ocotp.c +++ b/arch/arm/mach-imx/ocotp.c @@ -110,14 +110,9 @@ static int imx6_ocotp_wait_busy(struct ocotp_priv *priv, u32 flags) { uint64_t start = get_time_ns(); - while ((OCOTP_CTRL_BUSY | OCOTP_CTRL_ERROR | flags) & - readl(priv->base + OCOTP_CTRL)) { - if (is_timeout(start, MSECOND)) { - /* Clear ERROR bit */ - writel(OCOTP_CTRL_ERROR, priv->base + OCOTP_CTRL_CLR); + while (readl(priv->base + OCOTP_CTRL) & (OCOTP_CTRL_BUSY | flags)) + if (is_timeout(start, MSECOND)) return -ETIMEDOUT; - } - } return 0; } @@ -142,6 +137,8 @@ static int fuse_read_addr(struct ocotp_priv *priv, u32 addr, u32 *pdata) u32 ctrl_reg; int ret; + writel(OCOTP_CTRL_ERROR, priv->base + OCOTP_CTRL_CLR); + ctrl_reg = readl(priv->base + OCOTP_CTRL); ctrl_reg &= ~OCOTP_CTRL_ADDR_MASK; ctrl_reg &= ~OCOTP_CTRL_WR_UNLOCK_MASK; @@ -153,7 +150,10 @@ static int fuse_read_addr(struct ocotp_priv *priv, u32 addr, u32 *pdata) if (ret) return ret; - *pdata = readl(priv->base + OCOTP_READ_FUSE_DATA); + if (readl(priv->base + OCOTP_CTRL) & OCOTP_CTRL_ERROR) + *pdata = 0xbadabada; + else + *pdata = readl(priv->base + OCOTP_READ_FUSE_DATA); return 0; } @@ -175,11 +175,6 @@ int imx6_ocotp_read_one_u32(struct ocotp_priv *priv, u32 index, u32 *pdata) return ret; } - if (readl(priv->base + OCOTP_CTRL) & OCOTP_CTRL_ERROR) { - dev_err(priv->cdev.dev, "bad read status at fuse 0x%08x\n", index); - return -EFAULT; - } - return 0; } @@ -218,6 +213,8 @@ static int fuse_blow_addr(struct ocotp_priv *priv, u32 addr, u32 value) u32 ctrl_reg; int ret; + writel(OCOTP_CTRL_ERROR, priv->base + OCOTP_CTRL_CLR); + /* Control register */ ctrl_reg = readl(priv->base + OCOTP_CTRL); ctrl_reg &= ~OCOTP_CTRL_ADDR_MASK; -- cgit v1.2.3