From patchwork Wed Jun 17 18:05:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Aisheng X-Patchwork-Id: 6627611 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 40EC9C0020 for ; Wed, 17 Jun 2015 18:27:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2207B20840 for ; Wed, 17 Jun 2015 18:27:51 +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 E8AB220846 for ; Wed, 17 Jun 2015 18:27:49 +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 1Z5I1P-0002Uc-Mn; Wed, 17 Jun 2015 18:25:11 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5I1M-0001kR-Sr for linux-arm-kernel@bombadil.infradead.org; Wed, 17 Jun 2015 18:25:09 +0000 Received: from mail-bl2on0139.outbound.protection.outlook.com ([65.55.169.139] helo=na01-bl2-obe.outbound.protection.outlook.com) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5HlQ-0000dw-QJ for linux-arm-kernel@lists.infradead.org; Wed, 17 Jun 2015 18:08:42 +0000 Received: from BN3PR0301CA0057.namprd03.prod.outlook.com (10.160.152.153) by BLUPR03MB1412.namprd03.prod.outlook.com (10.163.81.146) with Microsoft SMTP Server (TLS) id 15.1.190.14; Wed, 17 Jun 2015 18:08:04 +0000 Received: from BY2FFO11FD020.protection.gbl (2a01:111:f400:7c0c::115) by BN3PR0301CA0057.outlook.office365.com (2a01:111:e400:401e::25) with Microsoft SMTP Server (TLS) id 15.1.195.15 via Frontend Transport; Wed, 17 Jun 2015 18:08:04 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD020.mail.protection.outlook.com (10.1.14.137) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Wed, 17 Jun 2015 18:08:04 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t5HI7jAc003611; Wed, 17 Jun 2015 11:07:58 -0700 From: Dong Aisheng To: Subject: [PATCH 2/6] mmc: sdhci-esdhc-imx: move all non dt probe code into one function Date: Thu, 18 Jun 2015 02:05:33 +0800 Message-ID: <1434564337-24720-3-git-send-email-aisheng.dong@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434564337-24720-1-git-send-email-aisheng.dong@freescale.com> References: <1434564337-24720-1-git-send-email-aisheng.dong@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD020; 1:hXZK/0zOzXtKUe57co09zhN2IJu7cc8NTM+L2FgF6arSioj3zAz2rV9+DDOi+62yEypj2+QAyjFPd39y3Ephh3Vus5D0Ni49j03DM88vP6oooILvq8rMA3TyeITtQK9ZluOUlrdj2kLNa7BH2Pg0S2YuomIEM4TK53kaX6FdcWbLuDOjdm1rWy7oxNhj7NG0XPQnhy6FSC9v/HUqz6bb5+s6DgxR0ceRdiYnmVijT6YX1Fs/CxCor+y4Old6cpagkKBBI6g3UgYLg6wc84Z/4XU1HUxEajZOxFCjLN2wJvLXwtBElGRNOeoWI+QmTD6Ca9lK8r5h/hvmVahOnEe1612k4rknORspRDGXld8uIHo= X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(110136002)(5001960100002)(189998001)(36756003)(77156002)(230783001)(62966003)(229853001)(2351001)(2950100001)(50466002)(81156007)(92566002)(47776003)(19580395003)(85426001)(48376002)(87936001)(105606002)(104016003)(33646002)(50226001)(77096005)(6806004)(46102003)(86362001)(19580405001)(76176999)(106466001)(50986999); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB1412; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1412; 2:P24splA9kLSF4+sNHmpzwmQHxpuJJDEm+RrnpIN7W0A9BJURtHdMEZaKZ9zCFmjy; 2:o1GQoex+7Jca2t/PtkArfi+4k+MqMvSVBKaBCTjepnsZ+vjdhBP7ldcIitNSUdevsthiWSi6lmKKFhcwnh9EO8FdCLaaVPGOpGWQFDAwco8mC+/OvWj+z1TWh2T/fIp3W/URRAs1bmA4swnDG+yEWnesXHgzsKzqEVO8fcuWkcm0Kb8cXtaGr4Y8I7wA+gSh+m8XPc4S6zcCL0yLIOM1byGEiIrJXCaFgwymZzMw39I=; 6:LwwhX+NV3PaH0v69CJ1qkkfqji/xP9BZ4AUq6mOiY2flS/64rLJCTQrj2NtosKnT5cmKa7MA5lp91DzCHJMAvOGLKpfG3YHS91oKzaBEmLyBZbcPT/FIWqpI1o7QaxbqCIkJzFg34lGTLLrI2rJZBayVfC7nq45I0LGqgZ4jlkV9W2GTpcVXYYigTPvDRQMqnvGovAxbyLzDpQsomUQ4hGbWF0+dukYnapYDX1hBch+lKoCrMwXjPjkraphhF7Ua1piTj/l+Avawn08HrDzdgwMY48UFk7srOyJq6M+yikvXs0NFff5Pl6PxQvDE8Lv238zjt7wXM38pK5npUYdy8Q==; 3:GibGdDZotT4jgwoN6hlUaiiYe+AvzKiOCSPJm/SUebweKF/36v3xjs4sMsfhXcbkTTfCKXiPEp0XBtE6yh0vphZNGitxcoYYCYdrPzKNvEIhv2cEOPQK12Zb2khunGqKupjaWIxbhueD33YTy4AgdAelNNVkxJuLvia7g9lKJDUyE5J0BvPJUrJKcF00FJ6jekNlQ3h5TjbTRn9T/z2g29x4ICH8MScPU0IeRCedsZp+NUy8EAsoTZeXnArvPlD96WrBgXZuuRsqBukG2dbHqo+B/PW1Q6i/xIG+Z2pss3fd6fiQDTEsS1Ds2D49+g3J X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1412; 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:BLUPR03MB1412; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB1412; X-Forefront-PRVS: 0610D16BBE X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1412; 9:7SELwURqZLoEir1MMwNHkbbkHKKxa83CTmdm3840oOOoIHiewthrj20i/RizK6LwYu/wlX4L1gzlrCrrfcYZE4qvyjXlXr6ccouBTzo4lSFs5L88IOH2xGnsBiuIk4NiTo6gWY96z7mFIVf8kdpUQMxXZEqdZciK52oFEeLDH4TT0JOPihQwKehc3Nl+0yKGyiBX8HWyb1k/5hX1iqy+yGNrMxEVU2oWFDhUogZoVOBHSfIBL6Q0Rszlr8YeYphTOXMytCB0kEXSg9ppICCOM0PERNp3Oo+cyXKze3fl8GEXiPd/YJ6APmi8ZBmii27J51KV0IpvGwdtyQOjK2JNt/+zmHAmJpeVh/VRUW1lpZ9TE6/qSFJNzYS4+24Hl092SqvmZ0t6jeFvaGYYK8fHgy9RI9Xt+kwfUjL4MN01KM+Rfg3YLb44OpOv1ezTyxd116ng5BJfbEkVHifhl1+0sp6pkeBr2N7hk00WpzLK7UzI2WJNCc3VmX44WYK15RdvtLXXokPQT3LEBMyEmRdP3cSCkgaH51dxWy7VLqcSPqxF4tstAcRw4zJ1jt18hBBLybU5S94T3Rwoupoz7VQ6ZIdTrJlJELf+H7o2w4MQifOdJehx7iN0Kz0nCVv7pbB3I1MPtGCrm069Q5CN8lW3OPIG+gz3H9xHazrp5hiXcqlA+2FSCkeMqoDIqedOLdTQhhHOvAhMxjFqtoYV/Yi6T/htmmUC+rl+4XdP6v1p8VLPrbt7QSZNvpo2kBKdVDPnp7uC9Gikj62rngK/Qh8sfJNbOs5GBq5WmI+c+EtoNgBIRCur0S+fuq+myqp1qYdF7hzeTXC2+qnkcI9rP6e5XbJMHOAv5ulnl8zRMjmdYqwYNp8CL82RyVbMb5TbgBkx+BiVPDbOrZUTrLjJ4AZ15e9KfrRRIhKQid8BdkBGd5c= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1412; 3:248+9wEYa/JF98vQCvXPykM5jvZ0u7IFDiHpis/Fiaq2+B/Uk/XMkeWN30BIqpLu4BEOCyvevjSbndQCD7M0bj50uazevrxMi8qHn8OgMo4HhL8B7yU89bTdJASDxBjl2crwEDmeS77+su6j+liP8w==; 10:xWDbgUXn2LeEZftiKEkgHXSt7QmN8iVDtXScicfEG1I+Mly2QDhElZSDlJCLHkEpNOdTA2U/KSoB9iVTcOo1XUr0vIF7EPFWTu4u6XH8blQ=; 6:3aCd+JrzIiF1vP+1bJIrF40e0Ac5b3OOlaDijz6vleAgPc0HyzgwXUV3lmjoPONI X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2015 18:08:04.0095 (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: BLUPR03MB1412 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150617_190841_106046_F25519AC X-CRM114-Status: GOOD ( 21.15 ) X-Spam-Score: -1.9 (-) Cc: fabio.estevam@freescale.com, marex@denx.de, ulf.hansson@linaro.org, s.trumtrar@pengutronix.de, smoch@web.de, linux-arm-kernel@lists.infradead.org, robertcnelson@gmail.com, s.hauer@pengutronix.de, chris@printf.net, rabeeh@solid-run.com, troy.kisky@boundarydevices.com, lisovy@gmail.com, hs@denx.de, gwenhael.goavec-merou@armadeus.com, p.zabel@pengutronix.de, rmk+kernel@arm.linux.org.uk, shawn.guo@linaro.org, b29396@freescale.com, tharvey@gateworks.com, LW@KARO-electronics.de, ipaton0@gmail.com 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.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 This is an incremental fix of commit e62bd351b("mmc: sdhci-esdhc-imx: Do not break platform data boards"). After commit 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()"), we do not need to run the check of boarddata->wp_type/cd_type/max_bus_width again for dt platform since those are already handled by mmc_of_parse(). Current code only exclude the checking of wp_type for dt platform which does not make sense. This patch moves all non dt probe code into one function. Besides, since we only support SD3.0/eMMC HS200 for dt platform, the support_vsel checking and ultra high speed pinctrl state are also merged into sdhci_esdhc_imx_probe_dt. Then we have two separately probe function for dt and non dt type. This can make the driver probe more clearly. Signed-off-by: Dong Aisheng --- drivers/mmc/host/sdhci-esdhc-imx.c | 179 +++++++++++++++++++------------------ 1 file changed, 94 insertions(+), 85 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 4815391..10f03ee 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -878,14 +878,12 @@ static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { static int sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, struct sdhci_host *host, - struct esdhc_platform_data *boarddata) + struct pltfm_imx_data *imx_data) { struct device_node *np = pdev->dev.of_node; + struct esdhc_platform_data *boarddata = &imx_data->boarddata; int ret; - if (!np) - return -ENODEV; - if (of_get_property(np, "non-removable", NULL)) boarddata->cd_type = ESDHC_CD_PERMANENT; @@ -917,6 +915,26 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, mmc_of_parse_voltage(np, &host->ocr_mask); + /* sdr50 and sdr104 needs work on 1.8v signal voltage */ + if ((boarddata->support_vsel) && esdhc_is_usdhc(imx_data) && + !IS_ERR(imx_data->pins_default)) { + imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl, + ESDHC_PINCTRL_STATE_100MHZ); + imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl, + ESDHC_PINCTRL_STATE_200MHZ); + if (IS_ERR(imx_data->pins_100mhz) || + IS_ERR(imx_data->pins_200mhz)) { + dev_warn(mmc_dev(host->mmc), + "could not get ultra high speed state, work on normal mode\n"); + /* + * fall back to not support uhs by specify no 1.8v quirk + */ + host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; + } + } else { + host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; + } + /* call to generic mmc_of_parse to support additional capabilities */ ret = mmc_of_parse(host->mmc); if (ret) @@ -931,22 +949,85 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, static inline int sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, struct sdhci_host *host, - struct esdhc_platform_data *boarddata) + struct pltfm_imx_data *imx_data) { return -ENODEV; } #endif +static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev, + struct sdhci_host *host, + struct pltfm_imx_data *imx_data) +{ + struct esdhc_platform_data *boarddata = &imx_data->boarddata; + int err; + + if (!host->mmc->parent->platform_data) { + dev_err(mmc_dev(host->mmc), "no board data!\n"); + return -EINVAL; + } + + imx_data->boarddata = *((struct esdhc_platform_data *) + host->mmc->parent->platform_data); + /* write_protect */ + if (boarddata->wp_type == ESDHC_WP_GPIO) { + err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio); + if (err) { + dev_err(mmc_dev(host->mmc), + "failed to request write-protect gpio!\n"); + return err; + } + host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; + } + + /* card_detect */ + switch (boarddata->cd_type) { + case ESDHC_CD_GPIO: + err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0); + if (err) { + dev_err(mmc_dev(host->mmc), + "failed to request card-detect gpio!\n"); + return err; + } + /* fall through */ + + case ESDHC_CD_CONTROLLER: + /* we have a working card_detect back */ + host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; + break; + + case ESDHC_CD_PERMANENT: + host->mmc->caps |= MMC_CAP_NONREMOVABLE; + break; + + case ESDHC_CD_NONE: + break; + } + + switch (boarddata->max_bus_width) { + case 8: + host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA; + break; + case 4: + host->mmc->caps |= MMC_CAP_4_BIT_DATA; + break; + case 1: + default: + host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA; + break; + } + + return 0; +} + static int sdhci_esdhc_imx_probe(struct platform_device *pdev) { const struct of_device_id *of_id = of_match_device(imx_esdhc_dt_ids, &pdev->dev); struct sdhci_pltfm_host *pltfm_host; struct sdhci_host *host; - struct esdhc_platform_data *boarddata; int err; struct pltfm_imx_data *imx_data; - bool dt = true; host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata, 0); if (IS_ERR(host)) @@ -1038,84 +1119,12 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (imx_data->socdata->flags & ESDHC_FLAG_ERR004536) host->quirks |= SDHCI_QUIRK_BROKEN_ADMA; - boarddata = &imx_data->boarddata; - if (sdhci_esdhc_imx_probe_dt(pdev, host, boarddata) < 0) { - if (!host->mmc->parent->platform_data) { - dev_err(mmc_dev(host->mmc), "no board data!\n"); - err = -EINVAL; - goto disable_clk; - } - imx_data->boarddata = *((struct esdhc_platform_data *) - host->mmc->parent->platform_data); - dt = false; - } - /* write_protect */ - if (boarddata->wp_type == ESDHC_WP_GPIO && !dt) { - err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio); - if (err) { - dev_err(mmc_dev(host->mmc), - "failed to request write-protect gpio!\n"); - goto disable_clk; - } - host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; - } - - /* card_detect */ - switch (boarddata->cd_type) { - case ESDHC_CD_GPIO: - if (dt) - break; - err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0); - if (err) { - dev_err(mmc_dev(host->mmc), - "failed to request card-detect gpio!\n"); - goto disable_clk; - } - /* fall through */ - - case ESDHC_CD_CONTROLLER: - /* we have a working card_detect back */ - host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; - break; - - case ESDHC_CD_PERMANENT: - host->mmc->caps |= MMC_CAP_NONREMOVABLE; - break; - - case ESDHC_CD_NONE: - break; - } - - switch (boarddata->max_bus_width) { - case 8: - host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA; - break; - case 4: - host->mmc->caps |= MMC_CAP_4_BIT_DATA; - break; - case 1: - default: - host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA; - break; - } - - /* sdr50 and sdr104 needs work on 1.8v signal voltage */ - if ((boarddata->support_vsel) && esdhc_is_usdhc(imx_data) && - !IS_ERR(imx_data->pins_default)) { - imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl, - ESDHC_PINCTRL_STATE_100MHZ); - imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl, - ESDHC_PINCTRL_STATE_200MHZ); - if (IS_ERR(imx_data->pins_100mhz) || - IS_ERR(imx_data->pins_200mhz)) { - dev_warn(mmc_dev(host->mmc), - "could not get ultra high speed state, work on normal mode\n"); - /* fall back to not support uhs by specify no 1.8v quirk */ - host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; - } - } else { - host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; - } + if (of_id) + err = sdhci_esdhc_imx_probe_dt(pdev, host, imx_data); + else + err = sdhci_esdhc_imx_probe_nondt(pdev, host, imx_data); + if (err) + goto disable_clk; err = sdhci_add_host(host); if (err)