linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] mmc: esdhc i.MX: Fix version register read
Date: Mon, 24 Sep 2012 09:22:24 +0200	[thread overview]
Message-ID: <1348471345-30785-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1348471345-30785-1-git-send-email-s.hauer@pengutronix.de>

The i.MX ESDHC controller version register is a mess:

- i.MX25 has a v1 controller which identifies itself as v2
- i.MX6Q has a v3 controller which identifies itself as v4
- i.MX35,51,53 have v2 controllers which identify themselves correctly

Additionally on i.MX the register is located at offset 0xfc instead of
0xfe. The i.MX6 had a quirk around it which converted v4 into v3. Instead
of reading the real version register, all other SoCs used to return
the value from 0xfe which contains 0x0 for all SoCs, so all controllers
except i.MX6q were identified as version v1.

This patch fixes this by returning the version based on the devtype
data leaving the useless version register untouched.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index e23f813..4fe7312 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -237,15 +237,20 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
 
 static u16 esdhc_readw_le(struct sdhci_host *host, int reg)
 {
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct pltfm_imx_data *imx_data = pltfm_host->priv;
+
 	if (unlikely(reg == SDHCI_HOST_VERSION)) {
-		u16 val = readw(host->ioaddr + (reg ^ 2));
-		/*
-		 * uSDHC supports SDHCI v3.0, but it's encoded as value
-		 * 0x3 in host controller version register, which violates
-		 * SDHCI_SPEC_300 definition.  Work it around here.
-		 */
-		if ((val & SDHCI_SPEC_VER_MASK) == 3)
-			return --val;
+		switch (imx_data->devtype) {
+		case IMX25_ESDHC:
+			return SDHCI_SPEC_100;
+		case IMX35_ESDHC:
+		case IMX51_ESDHC:
+		case IMX53_ESDHC:
+			return SDHCI_SPEC_200;
+		case IMX6Q_USDHC:
+			return SDHCI_SPEC_300;
+		}
 	}
 
 	return readw(host->ioaddr + reg);
-- 
1.7.10.4

  parent reply	other threads:[~2012-09-24  7:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-24  7:22 [PATCH] mmc: sdhci / i.MX esdhc buswidth patches Sascha Hauer
2012-09-24  7:22 ` [PATCH 1/3] mmc: sdhci: rename platform_8bit_width to platform_bus_width Sascha Hauer
2012-09-25  2:35   ` Jaehoon Chung
2012-09-25  6:15     ` Sascha Hauer
2012-09-25  7:28       ` Jaehoon Chung
2012-09-24  7:22 ` Sascha Hauer [this message]
2012-09-25  6:41   ` [PATCH 2/3] mmc: esdhc i.MX: Fix version register read Shawn Guo
2012-12-25 13:00   ` Shawn Guo
2012-09-24  7:22 ` [PATCH 3/3] mmc: esdhc i.MX: Support 8bit mode Sascha Hauer
2012-09-25  7:15   ` Shawn Guo
2012-09-25  7:27     ` Sascha Hauer
2012-09-25  7:33       ` Shawn Guo
2012-09-25  7:38         ` Sascha Hauer
2012-09-25  7:45           ` Shawn Guo
2012-09-25  8:05             ` Sascha Hauer
2012-09-25  8:50               ` Shawn Guo
2012-09-25  9:45                 ` Sascha Hauer
2012-09-25  7:52           ` Chris Ball
2012-09-25  7:53             ` Shawn Guo
2012-09-25  8:00               ` Chris Ball
2012-12-26  2:56                 ` Shawn Guo
2012-09-25  6:44 ` [PATCH] mmc: sdhci / i.MX esdhc buswidth patches Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348471345-30785-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).