Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754148AbbHJIbJ (ORCPT ); Mon, 10 Aug 2015 04:31:09 -0400 Received: from mail-by2on0134.outbound.protection.outlook.com ([207.46.100.134]:47727 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753093AbbHJIbF (ORCPT ); Mon, 10 Aug 2015 04:31:05 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Date: Mon, 10 Aug 2015 16:21:03 +0800 From: Dong Aisheng To: Haibo Chen CC: , , , , , , , , , , , , , , , Subject: Re: [PATCH v5 1/6] mmc: sdhci-esdhc-imx: add imx7d support and support HS400 Message-ID: <20150810082100.GA15036@shlinux1.ap.freescale.net> References: <1439194688-18335-1-git-send-email-haibo.chen@freescale.com> <1439194688-18335-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: <1439194688-18335-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;BY2FFO11FD033;1:c4MdOuv7QdLAmQeW1w+4cBp+ke285cOoEB6VtT2KvsDoEKIEZru2gIijiRBqZMdT2JIQdvZNp/TQoZuPKEuNpgJQfDoIY9jaGl7oz/7slWRA90N5lV2VN/yT8BM5R/w73zGAt6ZE2TZVvymhEA634LDwT8/sjRIIi43MY1hq80CgNkGSx0PAedqb5KQrUCGQP7afRYcSeOOaxdwDApx6XeZzZEtxdkIzolFkRCbEgVBB2/2pXU6NqdoYFeA8rWkqlqrdRil05nWsqZ2XswmckA+uQJkf6BoT5Bp/fAO0Hfydps6m68cH5aMLLFumRpSBSs7jb028fhtKytvAXP2YRA== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(24454002)(199003)(189002)(47776003)(85426001)(189998001)(106466001)(92566002)(230783001)(62966003)(86362001)(105606002)(77096005)(83506001)(2950100001)(104016003)(68736005)(19580395003)(110136002)(87936001)(54356999)(64706001)(46406003)(4001540100001)(81156007)(97736004)(4001450100002)(77156002)(76176999)(4001350100001)(5001830100001)(5003600100002)(46102003)(97756001)(50466002)(33656002)(19580405001)(23726002)(5001960100002)(50986999)(6806004)(5001860100001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR0301MB1312;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1312;2:aIC1ItdrcbF9ZF6EnazeppjK05AWneXFTP/TVuHdHwqVbcaWEKYq2FG1toTZNRpUUVXCriG1aM4cOX/g95l7Zikut67Y0fuBun1RwWc6zwSDm4WV1aGPv6QnW/vD1zjR99sUCnOXnzLDhBM1F0E5q7TOpUDNnSE0yFXW7qu8Eb4=;3:eOh+rDOO3Hrz7rd5N22YFVUurJd76ZbWOziZz0vUrVnaW2Ww9A6vBDoiZBKh8hs7Qa+IeYjA6Jtl17U3QlM146u02HOKHpDg3VpTh7//y4j+YnPp9yMYfzzNmG3EBZsGCioYO4+aWDfVgCzySM9qv/lfDi5umAAYj0o5LtKVwTVvJUlByGP4znxD80SOKC1yZ2RSqhNjch/c32cI+/DoP+990ddGFkWnh14ahfuBgKo=;25:rWVriXQZT2mSCBGk58UPl1cM1aXuRziwjSlsO10/bd5uKhZKL60PPXRfm76q4fVb0c/adqZUjQdxRrzNl9+qzz4PLoQWYyFdnDCmT0wdP+fN0wDQhoO3/njiDlXucA/3wAh07gMuqmhhFvTMtGhXdctJkNfTGDK0xf8oHTo57GHs3x59slqvEUESy3gCFZI1meNCowiBMyTPZlXJ601alGbFRd4ihgTGo4q7MECAT3KccsnTyYrm9gUUsejoIFYgVv8JcAZ5MjdpfU+6eGE8Iw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1312; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1312;20:RYelkH9fH4dsnd/mIz94D9dYyxgd09El2FYDwOpr5HKuSvoYu1FsoieacFHA2Ef6SYq/rhdu+B5anJJFYD1pItosgZHkYp/YPYPDqMUmBqI97Qg5nyKL+D6wL6DzZLNMqW3+Bp+CDtTVHbYbEBkiWqgSa5qCPc4fVm8TWF4Gl7TTCmn+UkI7BX0cP2hJkVByDmp4AOobSz1x7fp+Kbm3l025Wf8bBNcsfZ4lnXoBiqo1Qay7G8tCK9okUNEB1YwrbadbIwkydrCgpOLoSgnGPu3N3Gnvq6ZOUIJ8u2zwxsN1fq5fd+kNRaTzxfDJBm01khXb8hBv5Sgt5k+t9wgFYj46BiakT41lFm6qiRKxBfo=;4:Niz9Ly2XIska3x6nBcTmz4vbDCVey4Xbej0sH1QFjko+NpReZoVOKqQCfQc0qAfNgl105rwKr0QGRqgy6J0jAPO5jW9mm3z23Yyu/qAIaPMweLrzZPaT6AC4YOI8DgbATFF5guK6C2x8+8Z/Gmw8+YNeK7npTbvXG4fLer5MjcxYPzqhSExN7dQtlABiseZYBIx7jljW7r15ZL08d28vMbut+9GDzEjn2q5gJkWxORReJtPyfVgK7wyKxpVW9ZsWLuzwpJseuVuc9gGsuAzg10Zz/YhtiFqk//7+SoBFukA= 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:DM2PR0301MB1312;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1312; X-Forefront-PRVS: 06640999CA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0301MB1312;23:nrXvrCIby4+02VRdYtCLsAM6nSnih9PVO7yWyJD?= =?us-ascii?Q?1vR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N2D4dkwjagdD+u?= =?us-ascii?Q?sB5KQ1bvSTEcrIRMbkRFKgiJlDok+nNelvTH2cN9bKxtCddehcunN6yGNFO+?= =?us-ascii?Q?5q/rCUlf46afjqSSzWDHdrmvmr3TytbMFMXK6opxGN7T1yVAX3ZqIi2EeK9o?= =?us-ascii?Q?wNhLrM33TGNjvFtlmqLEK+y62pdOBopXohSXGAe72U8lAD9Ug/QSG4XTBknt?= =?us-ascii?Q?0NLq8+WIxTZgUwXTAaImrLbZfMbiUeX6xV8CdCejxBzCU06LZVC0DJuV0686?= =?us-ascii?Q?g0D1DnJikVotAW6TtFnWqa5F1asqP3sWvMnN0?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1312;5:Gn/rMiSjC2sPhUwh3PIB4DbRYC5EURDJ77vC6wTnzsz5VfbhKOjzw6A9leTfXhvz43LEl2+yQ4ibV+6VuYXHcg5fJahxhIML4q8LxCTB+vTC1PY2/r3Q0M9Z5UVi9yWxfwokQkkwZ4tDbg/+jsAh1Q==;24:wRAxaU71M51PNEcgCDs4RO0sFAPZasa6i3Z32rekCrIG7CVnIo8RQe9S/aE2T5zu1sBOMrwS8adSzqL7qoXRDphIMbGOin243+pKvIg0tT0=;20:ZtpHetnrE5ldQTkp8nsewf0v5lrQFYUvLIu0kGXVjpfVx1JLfqTComhwWLFLwVoX4eAEDvffpFFoT5od9DmZPw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2015 08:30:59.7499 (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.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB1312 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7507 Lines: 207 On Mon, Aug 10, 2015 at 04:18:03PM +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 | 88 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 85 insertions(+), 3 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c > index c6b9f64..2a816ad 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,12 +811,57 @@ 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) > { > + u32 m; > struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > struct pltfm_imx_data *imx_data = pltfm_host->priv; > struct esdhc_platform_data *boarddata = &imx_data->boarddata; > > + /* disable ddr mode and disable HS400 mode */ > + m = readl(host->ioaddr + ESDHC_MIX_CTRL); > + m &= ~(ESDHC_MIX_CTRL_DDREN | ESDHC_MIX_CTRL_HS400_EN); > + writel(m, host->ioaddr + ESDHC_MIX_CTRL); Is this write really required? > + imx_data->is_ddr = 0; > + > switch (timing) { > case MMC_TIMING_UHS_SDR12: > case MMC_TIMING_UHS_SDR25: > @@ -799,9 +871,9 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing) > break; > case MMC_TIMING_UHS_DDR50: > case MMC_TIMING_MMC_DDR52: > - writel(readl(host->ioaddr + ESDHC_MIX_CTRL) | > - ESDHC_MIX_CTRL_DDREN, > - host->ioaddr + ESDHC_MIX_CTRL); > + m = readl(host->ioaddr + ESDHC_MIX_CTRL); Can this line be droped if using the former readback mixctl value? > + m |= ESDHC_MIX_CTRL_DDREN; > + writel(m, host->ioaddr + ESDHC_MIX_CTRL); > imx_data->is_ddr = 1; > if (boarddata->delay_line) { > u32 v; > @@ -813,6 +885,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: > + m = readl(host->ioaddr + ESDHC_MIX_CTRL); ditto Regards Dong Aisheng > + m |= ESDHC_MIX_CTRL_DDREN | ESDHC_MIX_CTRL_HS400_EN; > + writel(m, host->ioaddr + ESDHC_MIX_CTRL); > + imx_data->is_ddr = 1; > + esdhc_set_strobe_dll(host); > + break; > } > > esdhc_change_pinstate(host, timing); > @@ -1100,6 +1179,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/