From patchwork Mon Mar 27 07:49:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9645533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8408C602C8 for ; Mon, 27 Mar 2017 08:17:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 714AE27F07 for ; Mon, 27 Mar 2017 08:17:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61EF5282ED; Mon, 27 Mar 2017 08:17:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D539B27F07 for ; Mon, 27 Mar 2017 08:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0XhRY+r2RsjwixAIMrN1bJTiBGB72oTOJWTKOjru6SU=; b=HwJlewZLS2crw/ NdCdeh1Z9NkG5iTkhnwle3ZUKSrLIfGzNi6Ivao6QDv5ITaqqRntG+BslWY09gKReMvJl766iz57O dujQmUymVZre2S6AIKOuiOWop+5Ra1BMn32N/71vk3jJeevso37cmdd0PsUgs6EBVgP7zHKjxXOHc RHLEskkOxt4eDT+mdL6QYMqRek+XOzQZ5vwV1/4PklP7mX1BozUi2dcTbJzbXSCqaPGXzBXNurwfa 2XQiC3UPDsg1q3BwJClw5RQn5hgWnNpZFwUK818rcaV9YNps+iCu5mokgGtZAf+Jj0elMxXgCFAkM xz6vF4fTuqINkb/d+HFg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1csPqQ-0005jF-Vz; Mon, 27 Mar 2017 08:17:43 +0000 Received: from mail-co1nam03on0080.outbound.protection.outlook.com ([104.47.40.80] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1csPdm-0005fi-3s for linux-arm-kernel@lists.infradead.org; Mon, 27 Mar 2017 08:04:44 +0000 Received: from BLUPR0301CA0012.namprd03.prod.outlook.com (10.162.113.150) by BL2PR03MB180.namprd03.prod.outlook.com (10.255.230.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14; Mon, 27 Mar 2017 08:04:17 +0000 Received: from BN1AFFO11FD032.protection.gbl (2a01:111:f400:7c10::151) by BLUPR0301CA0012.outlook.office365.com (2a01:111:e400:5259::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14 via Frontend Transport; Mon, 27 Mar 2017 08:04:15 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.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 BN1AFFO11FD032.mail.protection.outlook.com (10.58.52.186) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Mon, 27 Mar 2017 08:04:15 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2R842km024493; Mon, 27 Mar 2017 01:04:10 -0700 From: Yangbo Lu To: , , , , Adrian Hunter , Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon Subject: [v3, 2/7] mmc: sdhci-of-esdhc: add support for signal voltage switch Date: Mon, 27 Mar 2017 15:49:37 +0800 Message-ID: <1490600982-5410-3-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1490600982-5410-1-git-send-email-yangbo.lu@nxp.com> References: <1490600982-5410-1-git-send-email-yangbo.lu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131350754556191142; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39450400003)(39410400002)(39840400002)(39860400002)(39850400002)(39400400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(85426001)(5003940100001)(68736007)(48376002)(53936002)(50986999)(5660300001)(81166006)(356003)(7416002)(305945005)(50226002)(230783001)(8676002)(4326008)(8936002)(106466001)(105606002)(50466002)(38730400002)(76176999)(47776003)(86362001)(2201001)(77096006)(54906002)(8656002)(104016004)(36756003)(2950100002)(33646002)(2906002)(6666003)(189998001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB180; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD032; 1:Vo2G6X/RMfEWfp4Fh+wAqHhexvBtNzUX0MQhf3MeMv9+uJGxHfddqWZM2cqzDGZMbR4Rhhrw63LFJXQGkxwJoXjnwISbRVL89qjtKunF/ttLodnyiIpBBrHlBMhcxXSL++MYTezIbCIec5u1l989Vs5cG2DmkPrlcrNEy5DO8Eja/eUsNYl8PpPCbMX/9TtYn4JHDFkZ6cfdmSjSpwy0FbQW3NFSBsRoAcblEHeDaKCHyg9MmqlrD2j7+nucBwCW6lkLtNNbccj/kjvbwGfKFgbuIpRIokpb7bzRlWc6IIjl7GM78+bt5pkSan/PjXI41P3L4urcElDiSqHcsI3bqO7uVbeCtOu+RYN5mQey0qwUlQy3Wkiq6yWvZHDA44+5DyERSseh4OoKfOgbzjh2Xhp0m9yBLXhz/mhKZfBNQH65Il+Mtf+g1MtO4Mr6LHI2m5q9TNOgpg3074O6N40Gd7s8IXJJxZhoShef40Cr+Oe2GPS6etzc/ZUDh1fM7YnNcpsPoOejUxAPl61ucyyBDp3SivrY0I2aSNpURFKYrejBlCdBrErtgEW8C0NoUjM3UfU/W8Q/0brm/ClBs2ehowq3FOQi7jGpBxe+TXshdTVE2KQSTQG3tmOyHHygzV5dB/LQeZ4NP1W+WkkyRzqYnVIepDyOvLKVcV4meqbie1yLIDwkuCQnih3xNYrcPUk4J06fHSa/guq4/iOb0UHruEjoOEC0WR15craZjis4VeqL0N8gOfQQnB8ggU+hixox MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: c75e2a9c-e127-4116-77ff-08d474e7dcb3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BL2PR03MB180; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB180; 3:HLTEzA0xrVz1s6ukz5KUhQvDfw+3UEKgl3XbzpYPB4L/sAIO747Rv1VH82fFmSO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Jv3dqHO/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13018025)(13024025)(8121501046)(13015025)(5005006)(13017025)(13023025)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123561025)(20161123559025)(20161123556025)(20161123565025); SRVR:BL2PR03MB180; BCL:0; PCL:0; RULEID:(400006); SRVR:BL2PR03MB180; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB180; 4:Ddefevo54M63bgGrddgsiZiNSGfg+nr8duhxO7Ww7idNpXiqjdcSTNjSCTkjyuYo4cLTUmevX2y1Lx5wJ/m/PJxDBLll27N5L2nI+2B/PaDDPHF0YvhFX11Pv+T90Fn838pdixPaDJewwlag7qnABbMQU4sBjf/9cmKAeq/pAh34YTtuoXlYbueN6YQ0yzSbIqOaX5mPlZXZIXjUPtTn1kAymSESKIWq4SY7nsMdHVjC36mml5kjq9yfRR7WsqDfAnqJUeJy7KRn/7EMGB3PNS9rcJsqvLk7Ji+QH8GheJF76c7O5d3pQJJtD/lVik1BZ9lqgxHLLLG6QyFV3lDbkWqsw63pkVar65XGoVElI6eAP3qIS+xUZgTq9zvUPzLUMhUkc8+7sTVmULMa6zBHoxnKUAH6Cjp3CPDY1iOfRQk73jr5HdGc2zCXCJgP5c2qfKy4UdhAVtuT9PfwKAK6AogL2mAf3yn+tHQwtRRoVQK3szjFWjkqXvArmLB4DyE8GxJ+zxdRQwellpJ4R21hQku/V1iH4jHJDr+ZI+ChvNvwibhltRKtbzsR+3AO2Mb7B/QfpMs0Dd7qmlESC8rL0bAF42UF6QCdaAys9Ru7DWjlDpOBNT0X332kfwMD3c+VcJz44BsoFZjRMX91F6a/YPvARU6B2PO5oHVFMSEPXCdNyKwsEp+RNslIaoeZKoS9j/PudMisQ+Aurm1TIOoZwC+A4A8kq6A7NSzeO2wIVrliIOPAZYlcNcdAl5XCBaOs X-Forefront-PRVS: 02596AB7DA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB180; 23:Psue5W9bkDBOaHBjK+nv3rmCysSLu53Mp/8iOxs2ev?= =?us-ascii?Q?Q+4qsK2J5CNiWnjJc/f5wkmZNIaY9vOYtfZI4IjaFY5gQyNQiy2S80j0Uisx?= =?us-ascii?Q?M7TaSplkSSzCmwLDkOFhoD3BULbKlQtTWNSKDV4uWmdjKW5RFt2OUGsiL3gh?= =?us-ascii?Q?4fXiU9V0pS50hgtDNOx3DJqZIRJb04QEdx11U6dJf61oSgaEGJzgCJD5ASJW?= =?us-ascii?Q?lUMOZbvVEQDZiDU7LYFrt7YGnS5HUwZeWezbJcCe252EgchF/6KEQSgkI6D1?= =?us-ascii?Q?vEdldMi6jdZczCfcT+J0STdDimqqzrHaf4OG2figxTd6bjZUriDO1E4WqSfN?= =?us-ascii?Q?sq5humI0cABH6TUwZGk/V/ecokT1JwuzmCH/fLRXTVZeaKv8H1qE1f/PuuK1?= =?us-ascii?Q?tVZGFDiIxN0x7tSVBzzUb+BBnh0DEXPRMB56ASJDApoD+Zos5a2b01nKS04b?= =?us-ascii?Q?5ImlBG4f2xNwhPkNkCG3B3wx4vGmwyFtDI585Diwr5z+JjuIonM1HZws/luf?= =?us-ascii?Q?HdMuiTfVC2Mg0zlwhsf1TfNbD/ohtA4NY3V4vwmn2RFtZS01UJepE3DMRn/Y?= =?us-ascii?Q?TKWf/XbrzmjMNSVpy9Iu+lGjagsfl7tsQGtuEDGEruyPmcGDNsSsILxQj25v?= =?us-ascii?Q?Q2QeqsNeWR/DwT8MF1RkttVe53lNFsfhF+uxirsuUo88zVpR5nH0ahcPDBDv?= =?us-ascii?Q?FmDWhIEHSAF5PIsgAD5aIY0ZCzwXD9czTOAhduvl4JOm7wXp7nrSAgD2iBa+?= =?us-ascii?Q?D8sCSe8Wv9rGidCJdhUL5I9ZXTqBAJl6gA4KARffR8ENpBhYTO3dtyHLo1u4?= =?us-ascii?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5eAzPW/rOf/bot6KibALY3ddrbfZ2d3bd+L7903athNEXVX9TYKBJcfHyUBh3SICjStq0faWaLGprSfgOt4ky+PsBrEFKsv; 24:2LTJaLrhS1jS7lbml6oM7NUF6kkH2Y/2wWosRTUnL+txQrqhKobgYAt8zDH8ok2H7JLfNTB0Gf3jOTW5vfFPaG2VrrK8O/ZphZtjk6HwpMk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB180; 7:EB+wDNXYYgK9A5i6NX7up5Aba24mEhXfqboevs1v+I6EjYAhac1/HyhwzjfHmMKDgvt3rE0iwBu5k6rYLeW7xWpibAmNt3Lc+w+hZN3FkUnLyQuMpIJhAc7rlJfxbaLMIfyiRzNrRnZV9RRybhgXfEc6idWwiITfCPYuJ5wWdjAisR986CpvqejiOBKQjTDc3aNIlDkcKK0ywzGHMHV/bivzMCf809N6btV3Ptt30pL1ew/hTNzPhJUkCDMTpoprOJ2DVEice2RG3pxQbINfeKONnt/lsx6XPSUHC8PpuPZQzLAfLytHsaXkBjZWeCdkXHt3WluId3tgH+wjnNEvCA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2017 08:04:15.3227 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170327_010438_913211_5FE7EB68 X-CRM114-Status: GOOD ( 19.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xiaobo Xie , Yangbo Lu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP eSDHC supports signal voltage switch from 3.3v to 1.8v by eSDHC_PROCTL[VOLT_SEL] bit. This bit changes the value of output signal SDHC_VS, and there must be a control circuit out of eSDHC to change the signal voltage according to SDHC_VS output signal. Signed-off-by: Yangbo Lu Acked-by: Adrian Hunter --- Changes for v2: - Used Adrain's method to support voltage switching: host->mmc_host_ops.start_signal_voltage_switch = esdhc_signal_voltage_switch; Changes for v3: - Put .start_signal_voltage_switch assigning after IS_ERR(host) check. --- drivers/mmc/host/sdhci-esdhc.h | 1 + drivers/mmc/host/sdhci-of-esdhc.c | 74 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h index 5343fc0..6869567 100644 --- a/drivers/mmc/host/sdhci-esdhc.h +++ b/drivers/mmc/host/sdhci-esdhc.h @@ -37,6 +37,7 @@ /* Protocol Control Register */ #define ESDHC_PROCTL 0x28 +#define ESDHC_VOLT_SEL 0x00000400 #define ESDHC_CTRL_4BITBUS (0x1 << 1) #define ESDHC_CTRL_8BITBUS (0x2 << 1) #define ESDHC_CTRL_BUSWIDTH_MASK (0x3 << 1) diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index 7ce1caf..a70499a 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -559,6 +560,76 @@ static void esdhc_reset(struct sdhci_host *host, u8 mask) sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); } +/* 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 + * used to support SDHC IO voltage switching. + */ +static const struct of_device_id scfg_device_ids[] = { + { .compatible = "fsl,t1040-scfg", }, + { .compatible = "fsl,ls1012a-scfg", }, + { .compatible = "fsl,ls1046a-scfg", }, + {} +}; + +/* SDHC IO VSEL control register definition */ +#define SCFG_SDHCIOVSELCR 0x408 +#define SDHCIOVSELCR_TGLEN 0x80000000 +#define SDHCIOVSELCR_VSELVAL 0x60000000 +#define SDHCIOVSELCR_SDHC_VS 0x00000001 + +static int esdhc_signal_voltage_switch(struct mmc_host *mmc, + struct mmc_ios *ios) +{ + struct sdhci_host *host = mmc_priv(mmc); + struct device_node *scfg_node; + void __iomem *scfg_base = NULL; + u32 sdhciovselcr; + u32 val; + + /* + * Signal Voltage Switching is only applicable for Host Controllers + * v3.00 and above. + */ + if (host->version < SDHCI_SPEC_300) + return 0; + + val = sdhci_readl(host, ESDHC_PROCTL); + + switch (ios->signal_voltage) { + case MMC_SIGNAL_VOLTAGE_330: + val &= ~ESDHC_VOLT_SEL; + sdhci_writel(host, val, ESDHC_PROCTL); + return 0; + case MMC_SIGNAL_VOLTAGE_180: + scfg_node = of_find_matching_node(NULL, scfg_device_ids); + if (scfg_node) + scfg_base = of_iomap(scfg_node, 0); + if (scfg_base) { + sdhciovselcr = SDHCIOVSELCR_TGLEN | + SDHCIOVSELCR_VSELVAL; + iowrite32be(sdhciovselcr, + scfg_base + SCFG_SDHCIOVSELCR); + + val |= ESDHC_VOLT_SEL; + sdhci_writel(host, val, ESDHC_PROCTL); + mdelay(5); + + sdhciovselcr = SDHCIOVSELCR_TGLEN | + SDHCIOVSELCR_SDHC_VS; + iowrite32be(sdhciovselcr, + scfg_base + SCFG_SDHCIOVSELCR); + iounmap(scfg_base); + } else { + val |= ESDHC_VOLT_SEL; + sdhci_writel(host, val, ESDHC_PROCTL); + } + return 0; + default: + return 0; + } +} + #ifdef CONFIG_PM_SLEEP static u32 esdhc_proctl; static int esdhc_of_suspend(struct device *dev) @@ -714,6 +785,9 @@ static int sdhci_esdhc_probe(struct platform_device *pdev) if (IS_ERR(host)) return PTR_ERR(host); + host->mmc_host_ops.start_signal_voltage_switch = + esdhc_signal_voltage_switch; + esdhc_init(pdev, host); sdhci_get_of_property(pdev);