MLK-16461-1 mmc: sdhci-esdhc-imx: add strobe-dll-delay-target support
authorHaibo Chen <haibo.chen@nxp.com>
Fri, 15 Sep 2017 11:48:14 +0000 (19:48 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:38:33 +0000 (15:38 -0500)
strobe-dll-delay-target is the delay cell add on the strobe line.
Strobe line the the uSDHC loopback read clock which is use in HS400
mode. Different strobe-dll-delay-target may need to set for different
board/SoC. If this delay cell is not set to an appropriate value,
we may see some read operation meet CRC error after HS400 mode select
which already pass the tuning.

This patch add the strobe-dll-delay-target setting in driver, so that
user can easily config this delay cell in dts file.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
drivers/mmc/host/sdhci-esdhc-imx.c
include/linux/platform_data/mmc-esdhc-imx.h

index de3270b..229fe25 100644 (file)
@@ -35,6 +35,11 @@ Optional properties:
   This property allows user to change the tuning step to more than one delay
   cells which is useful for some special boards or cards when the default
   tuning step can't find the proper delay window within limited tuning retries.
+- fsl,strobe-dll-delay-target: Specify the strobe dll control slave delay target.
+  This delay target programming host controller loopback read clock, and this
+  property allows user to change the delay target for the strobe input read clock.
+  If not use this property, driver default set the delay target to value 7.
+  Only eMMC HS400 mode need to take care of this property.
 - wifi-host : assigned as a wifi host.
   This is required for Broadcom BCM WiFi cards to do card detect
 
index 1e650b5..b332372 100644 (file)
@@ -73,7 +73,7 @@
 #define ESDHC_STROBE_DLL_CTRL          0x70
 #define ESDHC_STROBE_DLL_CTRL_ENABLE   (1 << 0)
 #define ESDHC_STROBE_DLL_CTRL_RESET    (1 << 1)
-#define ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET   0x7
+#define ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_DEFAULT   0x7
 #define ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_SHIFT     3
 
 #define ESDHC_STROBE_DLL_STATUS                0x74
@@ -960,7 +960,10 @@ static int esdhc_change_pinstate(struct sdhci_host *host,
  */
 static void esdhc_set_strobe_dll(struct sdhci_host *host)
 {
+       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+       struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
        u32 v;
+       u32 strobe_delay;
 
        if (host->mmc->actual_clock > ESDHC_STROBE_DLL_CLK_FREQ) {
                /* disable clock before enabling strobe dll */
@@ -975,9 +978,12 @@ static void esdhc_set_strobe_dll(struct sdhci_host *host)
                 * enable strobe dll ctrl and adjust the delay target
                 * for the uSDHC loopback read clock
                 */
+               if (imx_data->boarddata.strobe_dll_delay_target)
+                       strobe_delay = imx_data->boarddata.strobe_dll_delay_target;
+               else
+                       strobe_delay = ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_DEFAULT;
                v = ESDHC_STROBE_DLL_CTRL_ENABLE |
-                       (ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET
-                        << ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_SHIFT);
+                       (strobe_delay << ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_SHIFT);
                writel(v, host->ioaddr + ESDHC_STROBE_DLL_CTRL);
                /* wait 1us to make sure strobe dll status register stable */
                udelay(1);
@@ -1276,6 +1282,8 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
        of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
        of_property_read_u32(np, "fsl,tuning-start-tap",
                             &boarddata->tuning_start_tap);
+       of_property_read_u32(np, "fsl,strobe-dll-delay-target",
+                            &boarddata->strobe_dll_delay_target);
 
        if (of_find_property(np, "no-1-8-v", NULL))
                boarddata->support_vsel = false;
index 7daa78a..4ddb217 100644 (file)
@@ -47,5 +47,6 @@ struct esdhc_platform_data {
        unsigned int delay_line;
        unsigned int tuning_step;       /* The delay cell steps in tuning procedure */
        unsigned int tuning_start_tap;  /* The start delay cell point in tuning procedure */
+       unsigned int strobe_dll_delay_target; /* The delay cell for strobe pad (read clock) */
 };
 #endif /* __ASM_ARCH_IMX_ESDHC_H */