From patchwork Wed Jun 10 08:50:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Chen X-Patchwork-Id: 6577751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 31718C0020 for ; Wed, 10 Jun 2015 08:51:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 20FFB2058C for ; Wed, 10 Jun 2015 08:51:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3940205C1 for ; Wed, 10 Jun 2015 08:51:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z2bh2-00071y-MX; Wed, 10 Jun 2015 08:49:04 +0000 Received: from mail-bl2on0132.outbound.protection.outlook.com ([65.55.169.132] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z2bgg-0006qV-HC for linux-arm-kernel@lists.infradead.org; Wed, 10 Jun 2015 08:48:44 +0000 Received: from CH1PR03CA002.namprd03.prod.outlook.com (10.255.156.147) by BY1PR03MB1420.namprd03.prod.outlook.com (10.162.127.150) with Microsoft SMTP Server (TLS) id 15.1.184.17; Wed, 10 Jun 2015 08:48:19 +0000 Received: from BN1AFFO11FD035.protection.gbl (10.255.156.132) by CH1PR03CA002.outlook.office365.com (10.255.156.147) with Microsoft SMTP Server (TLS) id 15.1.184.17 via Frontend Transport; Wed, 10 Jun 2015 08:48:19 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; lists.infradead.org; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD035.mail.protection.outlook.com (10.58.52.159) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Wed, 10 Jun 2015 08:48:18 +0000 Received: from b51421-server.ap.freescale.net (b51421-server.ap.freescale.net [10.193.102.119]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t5A8mAXa027809; Wed, 10 Jun 2015 01:48:16 -0700 From: Haibo Chen To: Subject: [PATCH 1/6] mmc: sdhci-esdhc-imx: add imx7d support and support HS400 Date: Wed, 10 Jun 2015 16:50:39 +0800 Message-ID: <1433926244-29244-2-git-send-email-haibo.chen@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433926244-29244-1-git-send-email-haibo.chen@freescale.com> References: <1433926244-29244-1-git-send-email-haibo.chen@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD035; 1:JHXf5x3FrWN0Zcqb9Wfj4sxjWiSTmzk3Oa+bao7VmfNSdqXYL4j3fp7vjKaykPOsO2qHsWajvkF+bFydo2bYDzUkMwyGiEpGJA0hy//56ZIaKamlu0RHUG2Bvo+PjG3uOjpxKuTHFajRlT43pU+byN0ZDjSJ5MbD8FTPOqGafEoO27PbBBWX6RKMb7Tob/L3I0WGkjM9i1DPxk48GrSjNcIO+Ln3VrF5lEGSjATuuxgNXoiOyupjGvGRlkGeSJuPp48pAKsQczji43BqWJHMbKHXVaiUM6RClkqzB73RiC4GZ4sTnBmGjBL33ayZYfwvUOhnEYWtjM8gBcTVXX4dtw== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(199003)(189002)(33646002)(230783001)(36756003)(47776003)(50226001)(2351001)(86362001)(105606002)(106466001)(104016003)(229853001)(92566002)(46102003)(5001920100001)(76176999)(189998001)(50986999)(77156002)(2950100001)(50466002)(110136002)(19580395003)(87936001)(77096005)(5001960100002)(48376002)(575784001)(6806004)(19580405001)(62966003); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR03MB1420; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1420; 2:y5QzA6F/i3oTZzIDC3jB+L84z7IL+HUJ7NM3TOyTXU6YKf96sgCPCYlIe2gjTI/2; 2:bb41G9L16UHwQsP57gmcqzJ14YVe4VpmSM19SB8Gm71NKLpwc+9oO6+R+vq5+tlLVZ8OP+8fdOEni28XA57ycaNs1naHGx7Xcx59DnNeOXhSMBeSldKIpiUVidmwMmO+Glpf7iqApzWi8cdyjcdxRHnSyWPFBp0sfD7uJAXomZN6AH06N1ezc2upkvBjK2WAlUCE4o97obZ3W5dbdcAMLuCM1j7qA0+P6aA3Mhs3GLM=; 6:zETuA6qKgf3BQOXa/HjO/cZdkYRBdrzQgkC8BWk8eeEy87xxai5nDKi13gsqCh1GdyNqE2uA/If9JLo24MUYIeOXkZazaA09hao9laB97rKVoUfbk56kTG+VV8aF8EoeWwigHsh3UCC/P+AdK359lahozHIaRQVFg1iYey+CdlqbLIP+hHoELGr0OznBbXGNNljmJMGP37SScj+EI9kwAkjxctJJzSAqtYKmfr8WBrs2E9C5KHp/HE5QbkLZ4uLtUUbE/rHJVqzyOoKYzGIRqTAsNpqJU1iM1/Tfy2ghAB3L75ylu0P7p/4V7k0C8YyoIAbRM+phJ4WXZMVu5SMkWg==; 3:4M8+ynyR3HWCO/oOpv6FlMxoW0Md5ss7gAyIQ1E6Qrk6HKh9Iss5DoOhF4n4L1T5Ec68EqBML/TRqmVwusRAoRk98glHwMU4LK4A4PiWGzqYheUHstFfkYTiGc1fMmnvA9tUuGDxMZwG1s0JuhxGu3XhuzzT4qICwPSzn9xOSnCCR+u+mOHK5/y9l1HKJCLr44gdbI3DroScrJOsJVkSOemVtz29t7aRgF/8kfiKKG2bQBZ9KVTTxURrYf4RE6ed1PTi0pwt7MH3R/TiCf90P23Xeoa4az/ANkPLHQK8Pi5xo4SyBDoaHdGexWvwPSEM X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1420; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(520003)(3002001); SRVR:BY1PR03MB1420; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1420; X-Forefront-PRVS: 06036BD506 X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1420; 9:bM5loilDnyJCscncWlj8j/uTTLwELsdTNrw1h0S+8knK+c592yCmRwFxBP7jL+u3n+U55jxzBU3orPiNvwt/w8JWBmThjljkRevJq8gqp+9xrL2LCaezJ2USCfhNOcpHwbkFG0wLTdtCEmg80DEdhjjK0iG/nOXgWiFaX4VRo352vXUPTSMfM7wSzzaDfxavoOpk/ctsmC9OqO2NHrJfJrupVCpy/RQ9yDrRmSy+V0aovHN1A1+H+2ZPYFXm0iu8HTNUGwccGADMYk8c8Mys2FNF/of71JjVMLWPyL47pj/40+UjGKmqGAMwWXPvmkdnoVC6OZ0IuaWpUcuEJLZphCuPHiTMkha8AY/bbusrIebcDOjOsy64mVJ71TXKDbP+ViWMjIZbEC72HAVB7EJfQI1wkJ0St5UdCNQ2nRKdJ9jsPO123I7hD07JPlzb3gBR4Z6VDMwOfwQkIIbchXGSzcVt1OSlH53dNUQMcKGc24Tv1qs204ekNiiEnfJH3s8iUtrZOZLAIjFaviFId+EQmK2QsyxtbEKVNDTZS3+F+CTZlGOFI0aDCVHQu1ClNmOaVwLrGDl3+wQkfKlDW6WNblq4j5QXFrJImGUFT7bfWOfYF7fGQ3LBU9fzNXhAm8ZX7Y2kyJ0O/VC/zJFyCtn2GTroJMyvFQKDem5PnBUZn/9Uj95D/ezOuhL93Ro492OMKI5Okq88yw46KzVpYBwMkT9vQd887O/LgUkRa4nCOwg9eER8jSxz8gVHoh3+PQpztCYP0y39lg6/SfoPQ+QsnJROnbZs8Il7T3pW7JcrcfaNs773xp4nVpNi9M358sDX4aHiMilywTjkSuVlGM58tIS9bWTcpkDXgxE98toQVNuFj1JOuahCNMvZeUR8Jhed604allxMXgGgF6ysXBpm7A== X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1420; 3:G7N62QsFL4pJ0cuHZxtzae64Wkit1DCqzLd+ibrTbY8/pvoCLMrg6qrzYwg9G6WDlmABbBpY7otqM58e5lqKir+eLuJ9k9BgBLFhcbIaONVv9LWBC1hsZRcnI6H36eoiNpaR5M4j39Iie+/c+pqRYg==; 10:GnRO2osGufSpsbizrQL4dV38Q3o4PX1xnRFdTPSYWxYA4ng9Lqay+eKBLF662EqLGcOHO3mI3M9FLj5TkeY8zE/AYCsLzUcMHtD3FAzsly4=; 6:+5OF86iO0ZjYnoE4itnB4hLTGo5SX2FThKKWlElh9kF56WDZ1ZWagkqGgljLap7U X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2015 08:48:18.9117 (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: BY1PR03MB1420 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150610_014842_882972_F6C2DF3A X-CRM114-Status: GOOD ( 13.85 ) X-Spam-Score: -1.1 (-) Cc: aisheng.dong@freescale.com, ulf.hansson@linaro.org, haibo.chen@freescale.com, chris@printf.net, shawn.guo@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index faf0cb9..763b928 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,8 @@ #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_SUP_HS400 BIT(9) struct esdhc_soc_data { u32 flags; @@ -156,6 +169,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_SUP_HS400, +}; + struct pltfm_imx_data { u32 scratchpad; struct pinctrl *pinctrl; @@ -199,6 +218,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 +294,10 @@ 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; + + /* imx7d does not have a support_hs400 register, fake one */ + if (imx_data->socdata->flags & ESDHC_FLAG_SUP_HS400) + val |= SDHCI_SUPPORT_HS400; } } @@ -779,6 +803,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: @@ -789,6 +814,30 @@ static int esdhc_change_pinstate(struct sdhci_host *host, return pinctrl_select_state(imx_data->pinctrl, pinctrl); } +static void esdhc_set_strobe_dll(struct sdhci_host *host) +{ + u32 v; + + /* 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); @@ -800,7 +849,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; break; case MMC_TIMING_UHS_DDR50: case MMC_TIMING_MMC_DDR52: @@ -818,6 +873,14 @@ 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; + if (host->clock == 200000000) + esdhc_set_strobe_dll(host); + break; } esdhc_change_pinstate(host, timing); @@ -1030,6 +1093,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_SUP_HS400) + host->quirks2 |= SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400; + boarddata = &imx_data->boarddata; if (sdhci_esdhc_imx_probe_dt(pdev, host, boarddata) < 0) { if (!host->mmc->parent->platform_data) {