From patchwork Sun Dec 2 08:43:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10707905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCE3C17D4 for ; Sun, 2 Dec 2018 08:46:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B04EF29C9B for ; Sun, 2 Dec 2018 08:46:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A491229D6F; Sun, 2 Dec 2018 08:46:54 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 32DC129C9B for ; Sun, 2 Dec 2018 08:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725809AbeLBIq4 (ORCPT ); Sun, 2 Dec 2018 03:46:56 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34236 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbeLBIqz (ORCPT ); Sun, 2 Dec 2018 03:46:55 -0500 Received: by mail-lj1-f193.google.com with SMTP id u6-v6so8616918ljd.1 for ; Sun, 02 Dec 2018 00:46:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TzOe2u4fto7Xz/iSAM01s65H6JiNfU2vSdL18luD4Do=; b=Wl5xMcDNw5s458G7sofboVSVIwYh6NFcPP3kDi1BF9WUSo305ChxOMs78dKthqy3e4 gktnEiWNZ5ezP6LtCu/LVgss31mJ2cm/IOKOKEQPSDEWpk6akKyuscNfo/26wj6wZY83 thofICPxpsAchOU8BBCWUNRisXnqEYeiSb54k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TzOe2u4fto7Xz/iSAM01s65H6JiNfU2vSdL18luD4Do=; b=b4uoeM45th46UrvWtMrv3Z6F3pmWaZUP6D5CvQ5rRvI4olDfeJk0ouC5qnSaN6BzRt Y/DfBlolV5Oi7m2EAjcfU4jnOjMu09Z4EaTQ+YdjNqbbcgCpiepDZ/jiqEgWWxEhbskq n9u/zl3enFgixps/iv6NwqMsUxlrPzZlzXV4ltDprwscNDKHwMorZqvIiBzkDfNprXhQ RPBcUU9/9H0oHGbSyKnwBSqBd/MDRoDjKVmG45IPFyH0sPtuO1VZ/gMqgS9z65lXRqnr +HhbW25n3SX6OyxlmBWiHr3qpw0+KOZ+eMJCyCQ0OTU1tj7w4FxFe52G765p3x7z0muR 7Wnw== X-Gm-Message-State: AA+aEWYQgL0xa+0b8EQi3spiieDLyHMVLtqVPRfBwI6HNXRHUcBKvfD0 GWbQtuu7isceWkqWvpeYnIY77okEST069A== X-Google-Smtp-Source: AFSGD/XrKjCLl6SXCi4YCtWEL/wuyubsYvFbWBf5ViPy/5Zx+rCWS2Rzkm6MCgtomLehA0HRS4RfrA== X-Received: by 2002:a2e:5b93:: with SMTP id m19-v6mr6429687lje.115.1543740406118; Sun, 02 Dec 2018 00:46:46 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id z7-v6sm1772719lji.42.2018.12.02.00.46.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Dec 2018 00:46:45 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij , Daniel Mack , Robert Jarzmik , Bartosz Golaszewski , Andrea Adami Subject: [PATCH 07/11 v4] mmc: pxamci: Support getting GPIO descs for RO and WP Date: Sun, 2 Dec 2018 09:43:24 +0100 Message-Id: <20181202084328.25546-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181202084328.25546-1-linus.walleij@linaro.org> References: <20181202084328.25546-1-linus.walleij@linaro.org> MIME-Version: 1.0 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 This implements the code path for the PXAMCI hostso that it can retrieve GPIO descriptors rather than use the global GPIO numberspace for GPIO lines. If the GPIO descriptor is present, it will take precedence and get used in place of the platform data GPIO number. We move the code around a bit so we request the card detect first and the write protect second. We keep the code setting the host flag for the write protect polarity inversion semantics since the slot GPIO core needs to be refactored to deal with this before we can get rid of this. Cc: Daniel Mack Cc: Robert Jarzmik Cc: Bartosz Golaszewski Cc: Andrea Adami Signed-off-by: Linus Walleij Acked-by: Robert Jarzmik --- ChangeLog v3->v4: - Fix a small but fatal typ pointed out by Robert. ChangeLog v1->v3: - Split out as separate patch at Robert's request. --- drivers/mmc/host/pxamci.c | 42 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index f7ffbf1676b1..5f06c7902306 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -63,6 +62,7 @@ struct pxamci_host { unsigned int imask; unsigned int power_mode; unsigned long detect_delay_ms; + bool use_ro_gpio; struct pxamci_platform_data *pdata; struct mmc_request *mrq; @@ -432,7 +432,7 @@ static int pxamci_get_ro(struct mmc_host *mmc) { struct pxamci_host *host = mmc_priv(mmc); - if (host->pdata && gpio_is_valid(host->pdata->gpio_card_ro)) + if (host->use_ro_gpio) return mmc_gpio_get_ro(mmc); if (host->pdata && host->pdata->get_ro) return !!host->pdata->get_ro(mmc_dev(mmc)); @@ -749,25 +749,39 @@ static int pxamci_probe(struct platform_device *pdev) host->pdata->gpio_power_invert); } - if (gpio_is_valid(gpio_ro)) { + /* FIXME: should we pass detection delay to debounce? */ + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); + if (ret && ret != -ENOENT) { + dev_err(dev, "Failed requesting gpio_cd\n"); + goto out; + } + if (ret == -ENOENT && gpio_is_valid(gpio_cd)) { + ret = mmc_gpio_request_cd(mmc, gpio_cd, 0); + if (ret) { + dev_err(dev, "Failed requesting gpio_cd %d\n", + gpio_cd); + } + } + + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL); + if (ret && ret != -ENOENT) { + dev_err(dev, "Failed requesting gpio_ro\n"); + goto out; + } + /* Try platform data instead */ + if (ret == -ENOENT && gpio_is_valid(gpio_ro)) { ret = mmc_gpio_request_ro(mmc, gpio_ro); if (ret) { dev_err(dev, "Failed requesting gpio_ro %d\n", gpio_ro); goto out; - } else { - mmc->caps2 |= host->pdata->gpio_card_ro_invert ? - 0 : MMC_CAP2_RO_ACTIVE_HIGH; } } - - if (gpio_is_valid(gpio_cd)) - ret = mmc_gpio_request_cd(mmc, gpio_cd, 0); - if (ret) { - dev_err(dev, "Failed requesting gpio_cd %d\n", - gpio_cd); - goto out; + if (!ret) { + host->use_ro_gpio = true; + mmc->caps2 |= host->pdata->gpio_card_ro_invert ? + 0 : MMC_CAP2_RO_ACTIVE_HIGH; } if (host->pdata->init) @@ -775,7 +789,7 @@ static int pxamci_probe(struct platform_device *pdev) if (gpio_is_valid(gpio_power) && host->pdata->setpower) dev_warn(dev, "gpio_power and setpower() both defined\n"); - if (gpio_is_valid(gpio_ro) && host->pdata->get_ro) + if (host->use_ro_gpio && host->pdata->get_ro) dev_warn(dev, "gpio_ro and get_ro() both defined\n"); }