Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755784AbbHGHsf (ORCPT ); Fri, 7 Aug 2015 03:48:35 -0400 Received: from mail-bn1bon0130.outbound.protection.outlook.com ([157.56.111.130]:11072 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754005AbbHGHsc (ORCPT ); Fri, 7 Aug 2015 03:48:32 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Date: Fri, 7 Aug 2015 15:38:56 +0800 From: Dong Aisheng To: Haibo Chen CC: , , , , , , , , , , , , , , , , Subject: Re: [PATCH v4 1/6] mmc: sdhci-esdhc-imx: add imx7d support and support HS400 Message-ID: <20150807073854.GA6935@shlinux1.ap.freescale.net> References: <1438771122-8601-1-git-send-email-haibo.chen@freescale.com> <1438771122-8601-2-git-send-email-haibo.chen@freescale.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1438771122-8601-2-git-send-email-haibo.chen@freescale.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11OLC009;1:EsmNuge5mHgjIr4hjLVwDHMep+42Rkt/zlpItrTCgkzYoYnVXgjvK82xad/QtR86UFs9DMls5gfD58UGlHpwesao0de3squxtsnMrxFzVlJ5xlmdCTSKJ6wyF3IKf8pQBOAJlM0th/hkn50383JDKjRJOj12wHrnBbPwH3/M8P9pxl280/mQN3Qu3wYuy9gCl7V4rtwkzmFiEM2KYqyoeqgC4vV5TF5sY4Eoho3XEst9GtHRk0bwOLppm9tuvVznS/jQCKLsT6LilFeBz5q5cGTHRhbprMFSc6UzF0aS/1IWeo71aQkyotqar8mcgNzfZBjnXwBB5P4X8xJ3Dj8/Hw== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(24454002)(189002)(54356999)(69596002)(46406003)(2950100001)(5003600100002)(92566002)(85426001)(86362001)(50986999)(83506001)(33656002)(76176999)(77156002)(62966003)(77096005)(4001450100002)(46102003)(189998001)(110136002)(5001960100002)(68736005)(104016003)(23726002)(87936001)(105606002)(106466001)(6806004)(230783001)(19580395003)(19580405001)(5001830100001)(5001860100001)(4001540100001)(81156007)(97736004)(4001350100001)(47776003)(50466002)(64706001)(97756001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB1309;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1309;2:55mk2pBnejSTiWtbDiX4TkYkRqpCmU+nylwezlByHIjNrJlsxyyb96RNkxE5W2+EN5eOyrRDAGogfMFaVV1WpV2QBIs0yNiHbkV8JK/+h8G8VcQMJ3yFK/QGHP+5HSjr2zcZuijPZJkh8JUpQH742c6rlUqGtKLYwXZqLu3Pb5o=;3:GMI2fDxEJT0ecFPWpyBR7oXVSyfIVzL5ZHVsCQd4RywyEUPbvgyJJavL3CRCkyiiVF0SrOxuPpXvqp6l4WVPKLlb7X9Yw4wqFKYf8Kq9dOvLjbMHRdv7ET3CdQzvzApbZRZIW+JfCUf7vrLgBeLjZYqq3A193E2eX5Z9ZP5wzq/tgvh50IVjnuKTyBrVLPVlXF1/AxW6l8sgcCiINQtz/3676jyNiiOQgRkKOW41ye8=;25:k/SvzvaIWkmge4knSJonR5kLyxs4PHXh5Eh2z6oOMwRDIahe23L4uRluYY0f4teuBUxYPh62Um2tGwPxQluAPmI4d3A//kJWog6Y/FJ/4rnfKXtIr2bTQAJNWqByxoDRvkQrGcO5FSK+Qr8sgBriXNFIyh9pIt9NQOc+2GETaZ112DiCPRSrXN5ikrlM+Qgh94onTaPia8Fo4rrGKG7GXkRsY9yK5vIOvyO3hlJhSvTwp87tqPo10SrZBdG+09Gu3PZcJ21HiTkvGVpEx5dRPg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1309; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1309;20:pS6iZK9WPPAK4kxdSDcHk+F1KFWqwebiE7xfEqGikZ0XZqnnzj+Q2g7owt53D/Um1VJZAByzHi3XK/0qI4VRN7PL/n5+70BYfn9RlpyFsOweJ+vTy5/mJc/HS9bovvEoTLpx7GP/YgpkDXszedcUx63kFjItJIfDEwklforZ6VcUzI5+akDWDnKh/9EP1RYpWZsKdBDzxfjt3i1KjX2uhlVhaDd7I/zbrDpEh3wcHfCS7w4+6xczcMCy+MbAtgaf9x6uPHwwHuVPkeI2anvQPCxFb2D0SfSA1SCSSlVTuViLwyYCuRL3NmLZ6wHzRWRamkfLFynqijsFFK/KAkN1wmzARpndX6Nx+YVzvqglpvM=;4:NIkrxLmkoCw6zb3Xr8mJtYBL77cVdzYiH+QWdg8EVAV3oFeM13tM6GxGoHz5GgYHUVxax6O9PIE9o8a7kzy8APSVAGOQim4+hVhT2kWYIGUMWfsAA1zT+1RPffxZf91ziYqgs12E9UywTSJ9Q8BHkOLDtFAPSClFyrpsSAJQY3afuHhaeGp0S4VhcGQwrb+vwf+bLmFezYTSnOPlGcwCfLmC9OsuilC/ATrG3X60xSnTfFihDoY6y609CsBCtVrFmRMpVDY4Oe0qKcqmjKyze6oOU0ytW6kFKHkS8p+x+/8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:DM2PR0301MB1309;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1309; X-Forefront-PRVS: 066153096A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0301MB1309;23:YHGiKnheF2kIEw7QuwySLJ37y/oVe0+dCGr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Yzg2V1xHeLC+1j58z1parz9FzEuE1sKDypW?= =?us-ascii?Q?ZbwjpIhSrYPM0TNrgPAptvdPDn9XPPK4gmKULBuAnuE8qAscAdxTcQTncp9G?= =?us-ascii?Q?g6exM6AsE1Ms3/VWE6mpGdcfGvF4OzHd8ry5Yvlw93tCLKyZqQ++qGl39BDK?= =?us-ascii?Q?pjm4x/+V+t7xO/2BtNQ4YHoZKzkZGI+ytQnV3aeWHSCGw4Ef2miV9YGTYiEU?= =?us-ascii?Q?e/pKodrawNQ3VrIl4Fdi2oufAYKOSOFugKwMXOGYCTgiDTLkwkB4pUSiRyNt?= =?us-ascii?Q?MybOucbvC4bzQ/n7ocxV/G9DMQdyOs5E1PpQVF6Wx3BwmPNfi9S39/Cf6Kg?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1309;5:9nxeqS9CEO+TowjnYkO5IWZG64FGS3SghiEJu2VCK2O3qgiEM2BLAbh8uNMBNT3FMp8awzRhpVMA3/XdMfslIoa4c0rVVOWw2t7yYzgmA1q6Q7c5ujGxB3DSI2kucQ6yk9Dn7TkI8yF4ngUrZC+wPA==;24:e4gf2N/E+FXhuDTMg/2Fv93Tk8Ul8kbNwmvFTJCgEKcgxqe1DM3ntigkvvz76uR29ufLvS5np/yl3ZGVkfwaKn+ba0kQUw6OY/3H/9H6OGY=;20:4h/G7nsbZyno6Rn7wkOVwVT9aVPIeQx+NWSZ4Q1r2qoKxobm8H7DO6XDlG+3TzjC3YebD0pJ9V8tckIymkAYyQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2015 07:48:28.9231 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB1309 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7034 Lines: 190 On Wed, Aug 05, 2015 at 06:38:37PM +0800, Haibo Chen wrote: > The imx7d usdhc is derived from imx6sx, the difference is that > imx7d support HS400. > > So introduce a new compatible string for imx7d and add HS400 > support for imx7d usdhc. > > Signed-off-by: Haibo Chen > --- > drivers/mmc/host/sdhci-esdhc-imx.c | 81 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 81 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c > index c6b9f64..48f009c 100644 > --- a/drivers/mmc/host/sdhci-esdhc-imx.c > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c > @@ -44,6 +44,7 @@ > #define ESDHC_MIX_CTRL_EXE_TUNE (1 << 22) > #define ESDHC_MIX_CTRL_SMPCLK_SEL (1 << 23) > #define ESDHC_MIX_CTRL_FBCLK_SEL (1 << 25) > +#define ESDHC_MIX_CTRL_HS400_EN (1 << 26) > /* Bits 3 and 6 are not SDHCI standard definitions */ > #define ESDHC_MIX_CTRL_SDHCI_MASK 0xb7 > /* Tuning bits */ > @@ -60,6 +61,16 @@ > #define ESDHC_TUNE_CTRL_MIN 0 > #define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1) > > +/* strobe dll register */ > +#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_SHIFT 3 > + > +#define ESDHC_STROBE_DLL_STATUS 0x74 > +#define ESDHC_STROBE_DLL_STS_REF_LOCK (1 << 1) > +#define ESDHC_STROBE_DLL_STS_SLV_LOCK 0x1 > + > #define ESDHC_TUNING_CTRL 0xcc > #define ESDHC_STD_TUNING_EN (1 << 24) > /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */ > @@ -120,6 +131,11 @@ > #define ESDHC_FLAG_ERR004536 BIT(7) > /* The IP supports HS200 mode */ > #define ESDHC_FLAG_HS200 BIT(8) > +/* The IP supports HS400 mode */ > +#define ESDHC_FLAG_HS400 BIT(9) > + > +/* A higher clock ferquency than this rate requires strobell dll control */ > +#define ESDHC_STROBE_DLL_CLK_FREQ 100000000 > > struct esdhc_soc_data { > u32 flags; > @@ -156,6 +172,12 @@ static struct esdhc_soc_data usdhc_imx6sx_data = { > | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200, > }; > > +static struct esdhc_soc_data usdhc_imx7d_data = { > + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING > + | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 > + | ESDHC_FLAG_HS400, > +}; > + > struct pltfm_imx_data { > u32 scratchpad; > struct pinctrl *pinctrl; > @@ -199,6 +221,7 @@ static const struct of_device_id imx_esdhc_dt_ids[] = { > { .compatible = "fsl,imx6sx-usdhc", .data = &usdhc_imx6sx_data, }, > { .compatible = "fsl,imx6sl-usdhc", .data = &usdhc_imx6sl_data, }, > { .compatible = "fsl,imx6q-usdhc", .data = &usdhc_imx6q_data, }, > + { .compatible = "fsl,imx7d-usdhc", .data = &usdhc_imx7d_data, }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids); > @@ -274,6 +297,9 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg) > val = SDHCI_SUPPORT_DDR50 | SDHCI_SUPPORT_SDR104 > | SDHCI_SUPPORT_SDR50 > | SDHCI_USE_SDR50_TUNING; > + > + if (imx_data->socdata->flags & ESDHC_FLAG_HS400) > + val |= SDHCI_SUPPORT_HS400; > } > } > > @@ -774,6 +800,7 @@ static int esdhc_change_pinstate(struct sdhci_host *host, > break; > case MMC_TIMING_UHS_SDR104: > case MMC_TIMING_MMC_HS200: > + case MMC_TIMING_MMC_HS400: > pinctrl = imx_data->pins_200mhz; > break; > default: > @@ -784,6 +811,44 @@ static int esdhc_change_pinstate(struct sdhci_host *host, > return pinctrl_select_state(imx_data->pinctrl, pinctrl); > } > > +/* > + * For HS400 eMMC, there is a data_strobe line, this signal is generated > + * by the device and used for data output and CRC status response output > + * in HS400 mode. The frequency of this signal follows the frequency of > + * CLK generated by host. Host receive the data which is aligned to the > + * edge of data_strobe line. Due to the time delay between CLK line and > + * data_strobe line, if the delay time is larger than one clock cycle, > + * then CLK and data_strobe line will misaligned, read error shows up. > + * So when the CLK is higher than 100MHz, each clock cycle is short enough, > + * host should config the delay target. > + */ > +static void esdhc_set_strobe_dll(struct sdhci_host *host) > +{ > + u32 v; > + > + if (host->mmc->actual_clock > ESDHC_STROBE_DLL_CLK_FREQ) { > + /* force a reset on strobe dll */ > + writel(ESDHC_STROBE_DLL_CTRL_RESET, > + host->ioaddr + ESDHC_STROBE_DLL_CTRL); > + /* > + * enable strobe dll ctrl and adjust the delay target > + * for the uSDHC loopback read clock > + */ > + v = ESDHC_STROBE_DLL_CTRL_ENABLE | > + (7 << 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); > + v = readl(host->ioaddr + ESDHC_STROBE_DLL_STATUS); > + if (!(v & ESDHC_STROBE_DLL_STS_REF_LOCK)) > + dev_warn(mmc_dev(host->mmc), > + "warning! HS400 strobe DLL status REF not lock!\n"); > + if (!(v & ESDHC_STROBE_DLL_STS_SLV_LOCK)) > + dev_warn(mmc_dev(host->mmc), > + "warning! HS400 strobe DLL status SLV not lock!\n"); > + } > +} > + > static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing) > { > struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > @@ -795,7 +860,13 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing) > case MMC_TIMING_UHS_SDR25: > case MMC_TIMING_UHS_SDR50: > case MMC_TIMING_UHS_SDR104: > + break; > case MMC_TIMING_MMC_HS200: > + /* disable ddr mode and disable HS400 mode */ > + writel(readl(host->ioaddr + ESDHC_MIX_CTRL) & > + ~(ESDHC_MIX_CTRL_DDREN | ESDHC_MIX_CTRL_HS400_EN), > + host->ioaddr + ESDHC_MIX_CTRL); > + imx_data->is_ddr = 0; Can you please explain why need above code? Any issues if not do it? Regards Dong Aisheng > break; > case MMC_TIMING_UHS_DDR50: > case MMC_TIMING_MMC_DDR52: > @@ -813,6 +884,13 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing) > writel(v, host->ioaddr + ESDHC_DLL_CTRL); > } > break; > + case MMC_TIMING_MMC_HS400: > + writel(readl(host->ioaddr + ESDHC_MIX_CTRL) | > + ESDHC_MIX_CTRL_DDREN | ESDHC_MIX_CTRL_HS400_EN, > + host->ioaddr + ESDHC_MIX_CTRL); > + imx_data->is_ddr = 1; > + esdhc_set_strobe_dll(host); > + break; > } > > esdhc_change_pinstate(host, timing); > @@ -1100,6 +1178,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) > if (imx_data->socdata->flags & ESDHC_FLAG_ERR004536) > host->quirks |= SDHCI_QUIRK_BROKEN_ADMA; > > + if (imx_data->socdata->flags & ESDHC_FLAG_HS400) > + host->quirks2 |= SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400; > + > if (of_id) > err = sdhci_esdhc_imx_probe_dt(pdev, host, imx_data); > else > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/