layerscape: update patches-4.9 to LSDK1712
[openwrt/staging/ynezz.git] / target / linux / layerscape / patches-4.9 / 812-mmc-layerscape-support.patch
index 6cad565ad232c77eb6459dddc6b3be134ad90b6d..1d3899d28bc21ee79d57a3e5b684146f5807b01d 100644 (file)
@@ -1,9 +1,9 @@
-From b31046c51c72232363711f0c623df08bf28c37e4 Mon Sep 17 00:00:00 2001
+From 4215d5757595e7ec7ca146c2b901beb177f415d8 Mon Sep 17 00:00:00 2001
 From: Yangbo Lu <yangbo.lu@nxp.com>
-Date: Mon, 25 Sep 2017 12:21:30 +0800
-Subject: [PATCH] mmc: layerscape support
+Date: Wed, 17 Jan 2018 15:37:13 +0800
+Subject: [PATCH 24/30] mmc: layerscape support
 
-This is a integrated patch for layerscape mmc support.
+This is an integrated patch for layerscape mmc support.
 
 Adrian Hunter <adrian.hunter@intel.com>
 Jaehoon Chung <jh80.chung@samsung.com>
@@ -12,10 +12,10 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
 ---
  drivers/mmc/host/Kconfig          |   1 +
  drivers/mmc/host/sdhci-esdhc.h    |  52 +++++---
- drivers/mmc/host/sdhci-of-esdhc.c | 251 ++++++++++++++++++++++++++++++++++++--
+ drivers/mmc/host/sdhci-of-esdhc.c | 265 ++++++++++++++++++++++++++++++++++++--
  drivers/mmc/host/sdhci.c          |  45 ++++---
  drivers/mmc/host/sdhci.h          |   3 +
- 5 files changed, 306 insertions(+), 46 deletions(-)
+ 5 files changed, 320 insertions(+), 46 deletions(-)
 
 --- a/drivers/mmc/host/Kconfig
 +++ b/drivers/mmc/host/Kconfig
@@ -253,9 +253,16 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        /* Workaround to reduce the clock frequency for p1010 esdhc */
        if (of_find_compatible_node(NULL, NULL, "fsl,p1010-esdhc")) {
                if (clock > 20000000)
-@@ -441,8 +503,8 @@ static void esdhc_of_set_clock(struct sd
+@@ -440,9 +502,15 @@ static void esdhc_of_set_clock(struct sd
+                       clock -= 5000000;
        }
  
++      /* Workaround to reduce the clock frequency for ls1021a esdhc */
++      if (of_find_compatible_node(NULL, NULL, "fsl,ls1021a-esdhc")) {
++              if (clock == 50000000)
++                      clock = 46500000;
++      }
++
        temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
 -      temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
 -              | ESDHC_CLOCK_MASK);
@@ -264,7 +271,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
  
        while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
-@@ -462,7 +524,20 @@ static void esdhc_of_set_clock(struct sd
+@@ -462,7 +530,20 @@ static void esdhc_of_set_clock(struct sd
                | (div << ESDHC_DIVIDER_SHIFT)
                | (pre_div << ESDHC_PREDIV_SHIFT));
        sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
@@ -286,7 +293,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  }
  
  static void esdhc_pltfm_set_bus_width(struct sdhci_host *host, int width)
-@@ -487,6 +562,33 @@ static void esdhc_pltfm_set_bus_width(st
+@@ -487,12 +568,136 @@ static void esdhc_pltfm_set_bus_width(st
        sdhci_writel(host, ctrl, ESDHC_PROCTL);
  }
  
@@ -319,11 +326,20 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
 +
  static void esdhc_reset(struct sdhci_host *host, u8 mask)
  {
++      u32 val;
++
        sdhci_reset(host, mask);
-@@ -495,6 +597,95 @@ static void esdhc_reset(struct sdhci_hos
-       sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
- }
  
+       sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
+       sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
++
++      if (mask & SDHCI_RESET_ALL) {
++              val = sdhci_readl(host, ESDHC_TBCTL);
++              val &= ~ESDHC_TB_EN;
++              sdhci_writel(host, val, ESDHC_TBCTL);
++      }
++}
++
 +/* The SCFG, Supplemental Configuration Unit, provides SoC specific
 + * configuration and status registers for the device. There is a
 + * SDHC IO VSEL control register on SCFG for some platforms. It's
@@ -411,12 +427,10 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
 +      esdhc_clock_enable(host, true);
 +
 +      return sdhci_execute_tuning(mmc, opcode);
-+}
-+
+ }
  #ifdef CONFIG_PM_SLEEP
- static u32 esdhc_proctl;
- static int esdhc_of_suspend(struct device *dev)
-@@ -575,10 +766,19 @@ static const struct sdhci_pltfm_data sdh
+@@ -575,10 +780,19 @@ static const struct sdhci_pltfm_data sdh
        .ops = &sdhci_esdhc_le_ops,
  };
  
@@ -436,7 +450,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        u16 host_ver;
  
        pltfm_host = sdhci_priv(host);
-@@ -588,6 +788,36 @@ static void esdhc_init(struct platform_d
+@@ -588,6 +802,36 @@ static void esdhc_init(struct platform_d
        esdhc->vendor_ver = (host_ver & SDHCI_VENDOR_VER_MASK) >>
                             SDHCI_VENDOR_VER_SHIFT;
        esdhc->spec_ver = host_ver & SDHCI_SPEC_VER_MASK;
@@ -473,7 +487,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  }
  
  static int sdhci_esdhc_probe(struct platform_device *pdev)
-@@ -610,6 +840,11 @@ static int sdhci_esdhc_probe(struct plat
+@@ -610,6 +854,11 @@ static int sdhci_esdhc_probe(struct plat
        if (IS_ERR(host))
                return PTR_ERR(host);