linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dong Aisheng <b29396@freescale.com>
To: linux-mmc@vger.kernel.org
Cc: cjb@laptop.org, anton@enomsg.org, shawn.guo@linaro.org,
	linux-arm-kernel@lists.infradead.org, s.hauer@pengutronix.de,
	b29396@freescale.com
Subject: [PATCH 3/8] sdhci: sdhci-esdhc-imx: support real clock on and off for imx6q
Date: Wed, 4 Sep 2013 20:54:12 +0800	[thread overview]
Message-ID: <1378299257-2980-4-git-send-email-b29396@freescale.com> (raw)
In-Reply-To: <1378299257-2980-1-git-send-email-b29396@freescale.com>

The signal voltage switch follow requires to shutdown and output
clock in a specific sequence according to standard host controller
v3.0 spec. In that timing, the card must really receive clock or not.

However, for i.MX6Q, the uSDHC will not output clock even the clock
is enabled until there is command or data in transfer on the bus,
which will then cause singal voltage switch always to fail.

For i.MX6Q, we clear ESDHC_VENDOR_SPEC_FRC_SDCLK_ON bit to let
controller to gate off clock automatically and set that bit
to force clock output if clock is on.

This is required by SD3.0 support.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |    3 ---
 drivers/mmc/host/sdhci-esdhc.h     |   29 ++++++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 1dd5ba8..3118a82 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -31,9 +31,6 @@
 #include "sdhci-esdhc.h"
 
 #define	ESDHC_CTRL_D3CD			0x08
-/* VENDOR SPEC register */
-#define ESDHC_VENDOR_SPEC		0xc0
-#define  ESDHC_VENDOR_SPEC_SDIO_QUIRK	(1 << 1)
 #define ESDHC_WTMK_LVL			0x44
 #define ESDHC_MIX_CTRL			0x48
 #define  ESDHC_MIX_CTRL_AC23EN		(1 << 7)
diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
index a2a0642..86fcd5b 100644
--- a/drivers/mmc/host/sdhci-esdhc.h
+++ b/drivers/mmc/host/sdhci-esdhc.h
@@ -14,6 +14,8 @@
 #ifndef _DRIVERS_MMC_SDHCI_ESDHC_H
 #define _DRIVERS_MMC_SDHCI_ESDHC_H
 
+#include <linux/of.h>
+
 /*
  * Ops and quirks for the Freescale eSDHC controller.
  */
@@ -33,6 +35,12 @@
 #define ESDHC_CLOCK_HCKEN	0x00000002
 #define ESDHC_CLOCK_IPGEN	0x00000001
 
+/* VENDOR SPEC register */
+#define ESDHC_VENDOR_SPEC		0xc0
+#define  ESDHC_VENDOR_SPEC_SDIO_QUIRK	(1 << 1)
+#define  ESDHC_VENDOR_SPEC_VSELECT	(1 << 1)
+#define  ESDHC_VENDOR_SPEC_FRC_SDCLK_ON (1 << 8)
+
 /* pltfm-specific */
 #define ESDHC_HOST_CONTROL_LE	0x20
 
@@ -52,12 +60,20 @@
 static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock,
 				   unsigned int host_clock)
 {
+	struct device *dev;
 	int pre_div = 2;
 	int div = 1;
-	u32 temp;
-
-	if (clock == 0)
+	u32 temp, val;
+
+	dev = mmc_dev(host->mmc);
+	if (clock == 0) {
+		if (of_device_is_compatible(dev->of_node, "fsl,imx6q-usdhc")) {
+			val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
+			writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
+				host->ioaddr + ESDHC_VENDOR_SPEC);
+		}
 		goto out;
+	}
 
 	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
 	temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
@@ -81,6 +97,13 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock,
 		| (div << ESDHC_DIVIDER_SHIFT)
 		| (pre_div << ESDHC_PREDIV_SHIFT));
 	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+
+	if (of_device_is_compatible(dev->of_node, "fsl,imx6q-usdhc")) {
+		val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
+		writel(val | ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
+			host->ioaddr + ESDHC_VENDOR_SPEC);
+	}
+
 	mdelay(1);
 out:
 	host->clock = clock;
-- 
1.7.1



  parent reply	other threads:[~2013-09-04 13:01 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04 12:54 [PATCH 0/8] mmc: sdhci-esdhc-imx: add SD3.0 support Dong Aisheng
2013-09-04 12:54 ` [PATCH 1/8] mmc: sdhci: add hooks for platform specific tuning Dong Aisheng
2013-09-05  3:14   ` Shawn Guo
2013-09-05 14:53     ` Dong Aisheng
2013-09-04 12:54 ` [PATCH 2/8] mmc: sdhci: allow platform access of sdhci_send_command Dong Aisheng
2013-09-04 12:54 ` Dong Aisheng [this message]
2013-09-05  4:32   ` [PATCH 3/8] sdhci: sdhci-esdhc-imx: support real clock on and off for imx6q Shawn Guo
2013-09-05 14:59     ` Dong Aisheng
2013-09-04 12:54 ` [PATCH 4/8] sdhci: sdhci-esdhci-imx: add sd3.0 clock tuning support Dong Aisheng
2013-09-05  6:00   ` Shawn Guo
2013-09-05 15:02     ` Dong Aisheng
2013-09-05  7:33   ` Ulf Hansson
2013-09-05 17:52     ` Dong Aisheng
2013-09-16  7:48       ` Ulf Hansson
2013-09-04 12:54 ` [PATCH 5/8] sdhci: sdhci-esdhc-imx: change pinctrl state according to uhs mode Dong Aisheng
2013-09-05  6:34   ` Shawn Guo
2013-09-05 15:06     ` Dong Aisheng
2013-09-05  7:38   ` Ulf Hansson
2013-09-05 16:04     ` Dong Aisheng
2013-09-13 14:01       ` Ulf Hansson
2013-09-13 16:38         ` Dong Aisheng
2013-09-05 18:40   ` Matt Sealey
2013-09-11  9:26     ` Dong Aisheng
2013-09-27  0:28       ` Matt Sealey
2013-09-04 12:54 ` [PATCH 6/8] mmc: sdhci-esdhc: correct pre_div for imx6q Dong Aisheng
2013-09-04 12:54 ` [PATCH 7/8] mmc: sdhci-esdhc: set actual_clock in clock setting Dong Aisheng
2013-09-04 12:54 ` [PATCH 8/8] ARM: dts: imx6qdl: add uhs pinctrl state for usdhc3 Dong Aisheng
2013-09-05  6:43   ` Shawn Guo
2013-09-05 15:09     ` Dong Aisheng
2013-09-05  8:03   ` Sascha Hauer
2013-09-05 15:29     ` Dong Aisheng
2013-09-05  7:42 ` [PATCH 0/8] mmc: sdhci-esdhc-imx: add SD3.0 support Ulf Hansson
2013-09-05 18:01   ` Dong Aisheng

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=1378299257-2980-4-git-send-email-b29396@freescale.com \
    --to=b29396@freescale.com \
    --cc=anton@enomsg.org \
    --cc=cjb@laptop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawn.guo@linaro.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).