From patchwork Thu Apr 20 08:14:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9689877 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 95A4F600C8 for ; Thu, 20 Apr 2017 08:29:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 844CF28448 for ; Thu, 20 Apr 2017 08:29:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76E312845B; Thu, 20 Apr 2017 08:29:58 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E545628448 for ; Thu, 20 Apr 2017 08:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941798AbdDTI34 (ORCPT ); Thu, 20 Apr 2017 04:29:56 -0400 Received: from mail-bl2nam02on0073.outbound.protection.outlook.com ([104.47.38.73]:12447 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967442AbdDTI3r (ORCPT ); Thu, 20 Apr 2017 04:29:47 -0400 Received: from DM5PR03CA0030.namprd03.prod.outlook.com (10.174.189.147) by CY1PR03MB2393.namprd03.prod.outlook.com (10.167.8.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Thu, 20 Apr 2017 08:29:45 +0000 Received: from BL2FFO11FD053.protection.gbl (2a01:111:f400:7c09::148) by DM5PR03CA0030.outlook.office365.com (2603:10b6:4:3b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13 via Frontend Transport; Thu, 20 Apr 2017 08:29:45 +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 BL2FFO11FD053.mail.protection.outlook.com (10.173.161.181) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1019.14 via Frontend Transport; Thu, 20 Apr 2017 08:29:45 +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 v3K8Tbd1002714; Thu, 20 Apr 2017 01:29:42 -0700 From: Yangbo Lu To: , , Adrian Hunter CC: Xiaobo Xie , Yangbo Lu Subject: [v5, 2/5] mmc: sdhci-of-esdhc: add support for signal voltage switch Date: Thu, 20 Apr 2017 16:14:41 +0800 Message-ID: <1492676084-28218-3-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1492676084-28218-1-git-send-email-yangbo.lu@nxp.com> References: <1492676084-28218-1-git-send-email-yangbo.lu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131371505853603398; (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)(39850400002)(39410400002)(39840400002)(39860400002)(39400400002)(39450400003)(39380400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(4326008)(76176999)(106466001)(47776003)(53936002)(50986999)(33646002)(189998001)(2950100002)(85426001)(77096006)(104016004)(105606002)(8656002)(54906002)(50466002)(48376002)(5660300001)(81166006)(2906002)(305945005)(230783001)(8676002)(8936002)(50226002)(36756003)(38730400002)(86362001)(356003)(5003940100001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2393; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD053; 1:MdhgZBUyU06xV7Iel8GeHmMIhnwHo/2NE/JXnUXGPvkZS5ogXQjlW6HbfGxPpJfVdX+oPeclnxtslfNAvcjOIaHTTnca8sk/SXBIw75g5PfGKrZys0yrbDdsznO8zDaDUJlKtdh4ipfLFdbDDcnj8VjolPFNYFOzLwjyb+/ycuKeRHGOZ/mDy9dnywyefyIos7KvYkYAha7RzL7cZMZA7Oe7qZKCtu/YPR0bUBJUF5vir4BlEA7k+zZ/OdGRKFRTeyYEfN0T2IdL0vMzD/mAXQcxUiS0r0MLe+00dIPnegVZEDijIMdMD+aZrxfZj/YXHxfpzXp1xIRrfIhyAOn6PPpDH3V9uFNzOd/1CmLbp9DLzALsorAvumoFK7YkiBEBNv9CQTY+CGS6vMn2h5jHosEvmCkqiGk7K5u5lKEyPEarr1Vac9ptET5cuW8pxmnJtdkljL+FpZENl9DDVNF291alpbVBm53zfXXeHF8Enmbo531dNtIuvCDpYZ3LHMAbhcBus1ybRu0gn9L8FVagmxaBCM9kAWPiUw843Bz53zvXJOXHHKJrRRYu/Zu6Z6F5jmNLhR2BrhPElKHphyplRW/Uu+CxCvqIyJmKFTv8ONzCCmf0Mf4vOwjb/7KoSpfhQ3IC+V04dR20tHwEbOQUZZC3htsuYFxqHO+WzHcJWReoS6vEFug3oTpive1U+YV5ysBufmlwD9vGIn6E8Z272Ru2UALbm7jQDDZIbAKyFKjl7D9W4ombF9nyH4DG4/e/Q1WKnT27rQ6L4LWFUmFipg== MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d741042-66ce-4787-bce7-08d487c76677 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:CY1PR03MB2393; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2393; 3:7CHfq1HMyhHajvvTFp4tPvRF9AfHCC8Wcm2ITmOIENC/YkkpChFXdAvpwXHJhHcSXo/kC/GiZ9TPDRFNVgYk/hB5TxmqSl3xHJQeazhYEvD1uZC1tI0e5CqwHcZNXMdwkIGL52A2FCMROg6O17Tw3dfnZgQJjvHxZD2nmFYHife0334Cku7IvJxdnMlYbpzTWBCmQomax8kC/1A6TJlYorAGCEaDGerHXnu9BJEBIa4f50qeFKUI28FkUPbwuZPmlGVKqsEhqigBYpsVuu84chv/qH7Yjef/NounMsQ6nKPC3bojEBfQFvgzEknC/Xn0hUZoxY9rA2npUXlmNDL70cpIsY4HLJVStiXzyDugSU+P4b7YCBai4cOkkql4WzvDPSciQg0lSdgdywgJK2jv9J+xqBsN+UIKBPRkmdpCcAF5YKdVP0DcghJFFe5oDfZn; 25:1zmX8Sa4McCezwWUdT+Mw6cuwn6l31XAbytYQEO5TWAftRzyvF8MFKE912DUm4MnskHxcAqNzuXxai5v16jE18piTZoyW4ek4wDc/Tg/MvSJL1t8E4Ff9PUy3ZChoZU2WurgnxLsyL1JyDuZ74tgljHkgBFRDq8qcEi6BPHfJq9chiqLhh6F1FoaB3jmQ4/J/nAHsnUUaiajk23JT56xhaidTNt8xwmOFGEvS3ORZ/Rj0ePjroTNTvTpDq6UZvBVvAhj6P+ZGERs/pPJADBx37YIgKaCCyuFjeMZJfpqeFJVkQYxGitRAp0ey2toybd4x44PXJWdV6eIc4uhRGYUjC2Oz7l9zZv3psqRnlShTcLR5oehh0Dwgk9D/dRKrNzX1yeNGZAOz+99yilgknoFnOL8AmvUqdymt1H+98P/t7Z5tGkU4lNf0ZKONuJT1eI5Kas1o4zSlt/jhGl9VUY7gA== X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2393; 31:41F/WPGCzUBph2UMk1nYzmRvghr2msS0xpky+p4IzEKCJdXhJEvHE93+J2CCnpUnBcSoOZn1Pog9TVZ+wIDk8T8XhBdHzCxKNCGxY2SLqjMMt3Htv25ANRyy5DH82UpBEjURgL7ubhYGRjFVQos1Y4/vQ8WE28I58XNxDWnVXEiqxZ88srAg56cl2zsgyvn6ZzpihBuv20IzQrn9VweN72i+slR8GZkhBaDAWHPPP/kRNbLqGGc+0Niar4ttdOHX X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13023025)(13015025)(13024025)(13018025)(8121501046)(13017025)(5005006)(93006095)(93001095)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123556025)(20161123565025)(20161123563025); SRVR:CY1PR03MB2393; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR03MB2393; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2393; 4:IdOy71inffr2sTxfIb7/zwRpmuDz2/tz3UWIGrSGfb?= =?us-ascii?Q?3K6JDLdZi1FiUqaS7kKUJpUqpTKxzZK5bu4OEdIY7unlmzoRkEN2/zA364O4?= =?us-ascii?Q?pIpGj3BsbUxF30Q3rUpGbo8A6dprYhodFlEDTo3hSCz7lNBtWhE+BATwQywZ?= =?us-ascii?Q?d5ENnIX48Mx7gD4I0vGHkm3impcBVnC2OLf/YZ+Rrm9T0/dDeDzHvsd8BJA9?= =?us-ascii?Q?jbDF7+Z1Q8XrKJc0zGDcbCVEIrGN/Vzt4BwYPw9EP/ZrteazJ7UY++zFxJtf?= =?us-ascii?Q?9O45qO4TwpGy+bPwbtlxgLLk2D7rLqqB6nxzarAxKhm+3mQ5vWBKZIgQQGgl?= =?us-ascii?Q?gTUtisG9r4weZcyN7K5am1WypcBfIprcmqhP03DpYFA0bE0QlckhqC0bPRRL?= =?us-ascii?Q?9iAr1JqYPpm0lZyNOeIDDuWrFX1LepyATmaq0JVXGZo/0xEEiAF3hSeFmI+9?= =?us-ascii?Q?KUnigOX+9uPYBrTg/Zf2z6UZtXaPKBIlVUPlbCX9NFnDlJTzxAxt41Zkb/mT?= =?us-ascii?Q?IjmE5mfk624xzCvTR0HiUpJy7oguNN8yB777iBKPN16bcgljq+x9VCosFciO?= =?us-ascii?Q?QdUUMvMYqkle6r2PhvozATjQMSnSK0fLQjJewERTB8RgV+OGXzfH8++ZkArp?= =?us-ascii?Q?DfgTXQV3TFL6uAWSaa4ZHSLA4RA5ce7i6TCOAEt5wgfvq4/QMmuznQD/Qenu?= =?us-ascii?Q?G/vjylV5u+k/to/BlAr2kwpvw4LuHlyRsldqLFHFRVWrBr6jYO437yomjeWp?= =?us-ascii?Q?Dr5Wmh1kw6JUk9qn/QHeZyaehJtWXEV5kr2P/ECagRom/ppzat4kjrepPu28?= =?us-ascii?Q?mvZUsCMUozTLDKX+ArnwQQ5cO6OXy/CXZ1r8PBiBu9+RoMNrUUuX/aqFw1g/?= =?us-ascii?Q?W9Js3CRxnEWArZAuDOPPPD5jyEqFudgJMlT9uqlyVjW+iK0NUhrZ3KlYPtGc?= =?us-ascii?Q?k5/8tbb/3jnKiVfZnviwhBqWVQaR2sNkxbcGyu9w=3D=3D?= X-Forefront-PRVS: 02830F0362 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2393; 23:xFWCY1d3Hkx7c7GoiBkUvQCBP6EM8IaCG3u/xLA/y?= =?us-ascii?Q?s3TV7CH3OC20/Qo1POWNiIXHMtwfnamJgCPJjGnD1YjQq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1w167YqFJLKjRWeZHUqXbNGCxG8A+8y2iFEHOMeJZEhHKBlyrfTJJxoG6M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2393; 7:3k1VuwrtJFdv0niJQwS5kBTy6JemFJCFevbrpIevnDWhy+4e3RO19HgHOjWIlA9PKHQx6A4b713yTtKqRk8T8Fh9uBTnpkJH1sTb9P9azb8e+qadpctVq2D/2/TNViDwfH36LdnohG6nk65uokOTGHHEEkGQ/pyeScl1eymG6eZ0wxAPOp3WOAGmNRfvNwI6evvmkUnJGyPEeYtulC7RQrQg/QwiLUFNFgjiwuv2xI2hWLCzwP9f+rxYl7liMj9zl3a3G7hCoYFICDaAkHeREO8fpqFLrPz5VNmGfZJ1tIQQpa5p+yF9de1Evpoy2bY3WHYgnfDYXfW8voe/H6cBJQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2017 08:29:45.1887 (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: CY1PR03MB2393 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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. Changes for v4: - None Changes for v5: - Added Adrian's ACK --- 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 0b3f05a..f2d7002 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 @@ -560,6 +561,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) @@ -717,6 +788,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);