All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ziyuan Xu <xzy.xu@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 26/33] mmc: sdhci: add support for UHS timing
Date: Mon, 15 May 2017 14:07:20 +0800	[thread overview]
Message-ID: <1494828447-24332-26-git-send-email-xzy.xu@rock-chips.com> (raw)
In-Reply-To: <1494828447-24332-1-git-send-email-xzy.xu@rock-chips.com>

To support UHS speed mode, controller should enable 1.8V signaling and
select one of UHS modes.

Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
---

 drivers/mmc/sdhci.c | 40 ++++++++++++++++++++++++++++++++++++++++
 include/mmc.h       |  1 +
 include/sdhci.h     | 17 +++++++++++++++++
 3 files changed, 58 insertions(+)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index ad86278..8f4a2a1 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -426,6 +426,39 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
 	sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
 }
 
+static void sdhci_set_uhs_signaling(struct sdhci_host *host)
+{
+	u16 ctrl_2;
+	u32 timing = host->mmc->timing;
+
+	ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
+	/* Select Bus Speed Mode for host */
+	ctrl_2 &= ~SDHCI_CTRL_UHS_MASK;
+
+	if ((timing != MMC_TIMING_LEGACY) &&
+	    (timing != MMC_TIMING_MMC_HS) &&
+	    (timing != MMC_TIMING_SD_HS))
+		ctrl_2 |= SDHCI_CTRL_VDD_180;
+
+	if ((timing == MMC_TIMING_MMC_HS200) ||
+	    (timing == MMC_TIMING_UHS_SDR104))
+		ctrl_2 |= SDHCI_CTRL_UHS_SDR104 | SDHCI_CTRL_DRV_TYPE_A;
+	else if (timing == MMC_TIMING_UHS_SDR12)
+		ctrl_2 |= SDHCI_CTRL_UHS_SDR12;
+	else if (timing == MMC_TIMING_UHS_SDR25)
+		ctrl_2 |= SDHCI_CTRL_UHS_SDR25;
+	else if (timing == MMC_TIMING_UHS_SDR50)
+		ctrl_2 |= SDHCI_CTRL_UHS_SDR50;
+	else if ((timing == MMC_TIMING_UHS_DDR50) ||
+		 (timing == MMC_TIMING_MMC_DDR52))
+		ctrl_2 |= SDHCI_CTRL_UHS_DDR50;
+	else if (timing == MMC_TIMING_MMC_HS400 ||
+		 timing == MMC_TIMING_MMC_HS400ES)
+		ctrl_2 |= SDHCI_CTRL_HS400 | SDHCI_CTRL_DRV_TYPE_A;
+
+	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
+}
+
 #ifdef CONFIG_DM_MMC_OPS
 static bool sdhci_card_busy(struct udevice *dev)
 {
@@ -485,6 +518,13 @@ static int sdhci_set_ios(struct mmc *mmc)
 
 	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
+	if ((mmc->timing != MMC_TIMING_LEGACY) &&
+	    (mmc->timing != MMC_TIMING_MMC_HS) &&
+	    (mmc->timing != MMC_TIMING_SD_HS))
+		sdhci_set_power(host, MMC_VDD_165_195_SHIFT);
+
+	sdhci_set_uhs_signaling(host);
+
 	/* If available, call the driver specific "post" set_ios() function */
 	if (host->ops && host->ops->set_ios_post)
 		host->ops->set_ios_post(host);
diff --git a/include/mmc.h b/include/mmc.h
index 05bf39d..b5817f3 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -138,6 +138,7 @@
 
 #define MMC_STATE_PRG		(7 << 9)
 
+#define MMC_VDD_165_195_SHIFT	7
 #define MMC_VDD_165_195		0x00000080	/* VDD voltage 1.65 - 1.95 */
 #define MMC_VDD_20_21		0x00000100	/* VDD voltage 2.0 ~ 2.1 */
 #define MMC_VDD_21_22		0x00000200	/* VDD voltage 2.1 ~ 2.2 */
diff --git a/include/sdhci.h b/include/sdhci.h
index 75432db..449ada1 100644
--- a/include/sdhci.h
+++ b/include/sdhci.h
@@ -147,6 +147,23 @@
 #define SDHCI_ACMD12_ERR	0x3C
 
 /* 3E-3F reserved */
+#define SDHCI_HOST_CONTROL2		0x3E
+#define SDHCI_CTRL_UHS_MASK		0x0007
+#define SDHCI_CTRL_UHS_SDR12		0x0000
+#define SDHCI_CTRL_UHS_SDR25		0x0001
+#define SDHCI_CTRL_UHS_SDR50		0x0002
+#define SDHCI_CTRL_UHS_SDR104		0x0003
+#define SDHCI_CTRL_UHS_DDR50		0x0004
+#define SDHCI_CTRL_HS400		0x0005
+#define SDHCI_CTRL_VDD_180		0x0008
+#define SDHCI_CTRL_DRV_TYPE_MASK	0x0030
+#define SDHCI_CTRL_DRV_TYPE_B		0x0000
+#define SDHCI_CTRL_DRV_TYPE_A		0x0010
+#define SDHCI_CTRL_DRV_TYPE_C		0x0020
+#define SDHCI_CTRL_DRV_TYPE_D		0x0030
+#define SDHCI_CTRL_EXEC_TUNING		0x0040
+#define SDHCI_CTRL_TUNED_CLK		0x0080
+#define SDHCI_CTRL_PRESET_VAL_ENABLE	0x8000
 
 #define SDHCI_CAPABILITIES	0x40
 #define  SDHCI_TIMEOUT_CLK_MASK	0x0000003F
-- 
2.7.4

  parent reply	other threads:[~2017-05-15  6:07 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15  6:06 [U-Boot] [PATCH 01/33] mmc: select the available type from host_caps and card_caps Ziyuan Xu
2017-05-15  6:06 ` [U-Boot] [PATCH 02/33] mmc: add set_timing entry for timing selection Ziyuan Xu
2017-05-15  6:06 ` [U-Boot] [PATCH 03/33] mmc: xenon_sdhci: drop redundant timing definitions Ziyuan Xu
2017-05-15  6:06 ` [U-Boot] [PATCH 04/33] mmc: rework high speed mode selection Ziyuan Xu
2017-05-15  6:06 ` [U-Boot] [PATCH 05/33] mmc: sdhci: fix HISPD bit setting Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 06/33] mmc: add card_busy to query card status Ziyuan Xu
2017-05-25 13:02   ` Jaehoon Chung
2017-05-15  6:07 ` [U-Boot] [PATCH 07/33] mmc: dw_mmc: implement card_busy detection Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 08/33] mmc: sdhci: " Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 09/33] mmc: rework mmc_switch for non-send_status scenario Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 10/33] mmc: add support for HS200 mode of eMMC4.5 Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 11/33] mmc: rework ddr mode judgement with timing Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 12/33] mmc: remove tran_speed from struct mmc Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 13/33] cmd: mmc: show the current speed mode Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 14/33] clk: introduce clk_phase get/set function & callback Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 15/33] rockchip: clk: rk3288: fix mmc clock setting Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 16/33] rockchip: clk: rk3288: add support for the clock phase Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 17/33] rockchip: clk: rk3399: fix emmc clock setting Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 18/33] mmc: dw_mmc: add the support for the tuning scheme Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 19/33] mmc: dw_mmc: rockchip: implement tuning with clock phase framework Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 20/33] mmc: dw_mmc: reset controller after data error Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 21/33] mmc: add DDR52 support for eMMC card Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 22/33] mmc: dw_mmc: rockchip: fix data crc error on ddr52 8bit mode Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 23/33] mmc: dw_mmc: fix bus width setting Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 24/33] mmc: sdhci: rockchip: " Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 25/33] mmc: sdhci: update host->clock after clock setting Ziyuan Xu
2017-05-15  6:07 ` Ziyuan Xu [this message]
2017-05-15  6:07 ` [U-Boot] [PATCH 27/33] mmc: sdhci: rename set_clock callback Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 28/33] mmc: sdhci: export sdhci_set_clock() Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 29/33] mmc: sdhci: rockchip: add phy support Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 30/33] mmc: sdhci: add the support for tuning Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 31/33] mmc: add support for HS400 mode of eMMC5.0 Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 32/33] dts: rk3399: change the maximum eMMC clock frequency to 150MHz Ziyuan Xu
2017-05-15  6:07 ` [U-Boot] [PATCH 33/33] SPL: tiny-printf: add "X" modifier Ziyuan Xu
2017-05-16  0:18 ` [U-Boot] [PATCH 01/33] mmc: select the available type from host_caps and card_caps Simon Glass
2017-05-16  1:15   ` Ziyuan
2017-05-16  1:55     ` Jaehoon Chung
2017-05-16  2:22       ` Ziyuan
2017-05-25  8:12       ` Ziyuan
2017-05-25 10:50         ` Jaehoon Chung
2017-05-25 13:08         ` Jaehoon Chung
2017-06-05  0:50           ` Ziyuan
2017-06-05  1:13             ` Jaehoon Chung
2017-05-17  1:38     ` Simon Glass

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=1494828447-24332-26-git-send-email-xzy.xu@rock-chips.com \
    --to=xzy.xu@rock-chips.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.