Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp851494imu; Fri, 25 Jan 2019 12:11:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN5uzssMjUHOlS9+pWstpaBrr/gV8XCwZFBtHwar+rrKR22Bz4kswMSAYEp1cOIV8uIAmDm1 X-Received: by 2002:a62:f54f:: with SMTP id n76mr12343990pfh.59.1548447087975; Fri, 25 Jan 2019 12:11:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548447087; cv=none; d=google.com; s=arc-20160816; b=yARbN5aQRz4hmOsW6C6f1EGCIqikQ7g5FDAsio+OYzxHHiFhE2KhdAPFqx/rHwKqJm 1LPouHvinM8dobhOR723g6rq8ifS028kEpRxMmTLMqJdRnbwyBoHtcjhYYHMhh6/n/hg Tb5+5ORv5BClfGzRD940fHMWoWkPtBnmlJ1XQukg88Ue/lrAuQdY/+pEZhpkIDd2eaCo ahCKLS43ow9AK8+f5JUSL9mb9SKJh5fmBDZSmnXky7CO+hQ0+wnnb22pB5lehptkmSPy cNj30EVp8U21fENBX54umtq5RE8sK7JRlbcEJurj2H7nYAXznQL/g/lJ1lnwxJcan7uG NEag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=XJmGEvYv3skTMuJOx2sSMUDaSz+Es8Mo7g2m8/2irTo=; b=ERFKjszKrQ0TpDboIR/CtOM5mlbi+dIQ+iJNpQAcRvmmTGlJfEf40Y21K5FeMCHfz6 VjaSftOmYi3mmqbtXk4ZTGaz6uZztVbf2day7GI6d6HUb3FLF0ErXx/V5PoKWgQBENuA mOKYaUd1cS2lPSUd4lAIbA7YHwK5pxHTN0Imb8cX/ImCGHHlSzNLN5sGdqIq9DcEX5aS 6rziaQ/5mN2ICZF/lDa0Ynh5I7Bjz8bk4kcOo/tG/JZakbkKQ2cusNjADiq4fGaafwEK ZeY6Ao+b2znrsbRz7cKF5/ptYN+U56L2bHAA67J6YkjzP42zlT/lxTXeK7rbYrsZK3Hg SWUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="i2Sj/5OI"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r77si24954848pfa.186.2019.01.25.12.11.12; Fri, 25 Jan 2019 12:11:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b="i2Sj/5OI"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728074AbfAYUJo (ORCPT + 99 others); Fri, 25 Jan 2019 15:09:44 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:48042 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbfAYUJn (ORCPT ); Fri, 25 Jan 2019 15:09:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1548446981; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=XJmGEvYv3skTMuJOx2sSMUDaSz+Es8Mo7g2m8/2irTo=; b=i2Sj/5OIoJOXNB7FidcVENYEQ12R7EcexyPpLluoWmiGYJFTOS9uou+UYXz3jFESSOx5g4 tUyx5XzcQ2RJwqYGTq85BIystfzkCJf/M8dzmfiLW0eFYpkiHwSVA48UTS7SziYBM7eWyG d2nhcrZgHvv4rzEY4onipnGmNWxblYg= From: Paul Cercueil To: Rob Herring , Mark Rutland , Ralf Baechle , Paul Burton , James Hogan , Ulf Hansson , Linus Walleij Cc: devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, Paul Cercueil Subject: [PATCH 1/3] mmc: jz4740: Remove platform data and use standard APIs Date: Fri, 25 Jan 2019 17:09:25 -0300 Message-Id: <20190125200927.21045-1-paul@crapouillou.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drop the custom code to get the 'cd' and 'wp' GPIOs. The driver now calls mmc_of_parse() which will init these from devicetree or device properties. Also drop the custom code to get the 'power' GPIO. The MMC core provides us with the means to power the MMC card through an external regulator. Signed-off-by: Paul Cercueil --- drivers/mmc/host/jz4740_mmc.c | 71 +++++++++---------------------------------- 1 file changed, 14 insertions(+), 57 deletions(-) diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c index 33215d66afa2..e41c7230815f 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -36,7 +35,6 @@ #include #include -#include #define JZ_REG_MMC_STRPCL 0x00 #define JZ_REG_MMC_STATUS 0x04 @@ -148,9 +146,7 @@ enum jz4780_cookie { struct jz4740_mmc_host { struct mmc_host *mmc; struct platform_device *pdev; - struct jz4740_mmc_platform_data *pdata; struct clk *clk; - struct gpio_desc *power; enum jz4740_mmc_version version; @@ -894,16 +890,16 @@ static void jz4740_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) switch (ios->power_mode) { case MMC_POWER_UP: jz4740_mmc_reset(host); - if (host->power) - gpiod_set_value(host->power, 1); + if (!IS_ERR(mmc->supply.vmmc)) + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); host->cmdat |= JZ_MMC_CMDAT_INIT; clk_prepare_enable(host->clk); break; case MMC_POWER_ON: break; default: - if (host->power) - gpiod_set_value(host->power, 0); + if (!IS_ERR(mmc->supply.vmmc)) + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); clk_disable_unprepare(host->clk); break; } @@ -936,38 +932,6 @@ static const struct mmc_host_ops jz4740_mmc_ops = { .enable_sdio_irq = jz4740_mmc_enable_sdio_irq, }; -static int jz4740_mmc_request_gpios(struct jz4740_mmc_host *host, - struct mmc_host *mmc, - struct platform_device *pdev) -{ - struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev); - int ret = 0; - - if (!pdata) - return 0; - - if (!pdata->card_detect_active_low) - mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; - if (!pdata->read_only_active_low) - mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; - - /* - * Get optional card detect and write protect GPIOs, - * only back out on probe deferral. - */ - ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); - if (ret == -EPROBE_DEFER) - return ret; - - ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL); - if (ret == -EPROBE_DEFER) - return ret; - - host->power = devm_gpiod_get_optional(&pdev->dev, "power", - GPIOD_OUT_HIGH); - return PTR_ERR_OR_ZERO(host->power); -} - static const struct of_device_id jz4740_mmc_of_match[] = { { .compatible = "ingenic,jz4740-mmc", .data = (void *) JZ_MMC_JZ4740 }, { .compatible = "ingenic,jz4725b-mmc", .data = (void *)JZ_MMC_JZ4725B }, @@ -982,9 +946,6 @@ static int jz4740_mmc_probe(struct platform_device* pdev) struct mmc_host *mmc; struct jz4740_mmc_host *host; const struct of_device_id *match; - struct jz4740_mmc_platform_data *pdata; - - pdata = dev_get_platdata(&pdev->dev); mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), &pdev->dev); if (!mmc) { @@ -993,29 +954,25 @@ static int jz4740_mmc_probe(struct platform_device* pdev) } host = mmc_priv(mmc); - host->pdata = pdata; match = of_match_device(jz4740_mmc_of_match, &pdev->dev); if (match) { host->version = (enum jz4740_mmc_version)match->data; - ret = mmc_of_parse(mmc); - if (ret) { - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, - "could not parse of data: %d\n", ret); - goto err_free_host; - } } else { /* JZ4740 should be the only one using legacy probe */ host->version = JZ_MMC_JZ4740; - mmc->caps |= MMC_CAP_SDIO_IRQ; - if (!(pdata && pdata->data_1bit)) - mmc->caps |= MMC_CAP_4_BIT_DATA; - ret = jz4740_mmc_request_gpios(host, mmc, pdev); - if (ret) - goto err_free_host; } + ret = mmc_of_parse(mmc); + if (ret) { + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, + "could not parse device properties: %d\n", ret); + goto err_free_host; + } + + mmc_regulator_get_supply(mmc); + host->irq = platform_get_irq(pdev, 0); if (host->irq < 0) { ret = host->irq; -- 2.11.0