From patchwork Sun Nov 25 22:52:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10697175 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 0F4FE1869 for ; Sun, 25 Nov 2018 22:54:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 000982991E for ; Sun, 25 Nov 2018 22:54:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E86BB29920; Sun, 25 Nov 2018 22:54:51 +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 79E9629924 for ; Sun, 25 Nov 2018 22:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726079AbeKZJrC (ORCPT ); Mon, 26 Nov 2018 04:47:02 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:47092 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbeKZJrC (ORCPT ); Mon, 26 Nov 2018 04:47:02 -0500 Received: by mail-lj1-f194.google.com with SMTP id v15-v6so14802188ljh.13 for ; Sun, 25 Nov 2018 14:54:49 -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=D05aRSDtBy8T/2cyFShIAaqmP79zJMnJc6GIN359i/c=; b=Lk0IcaV/56wM1G5Hx7D1NWGSlX+KVDvFVmfl7meRstSH+wpEdK5j+JDNdQCpXCFknJ IcKic8y+TxkN+MuwFSC8VFTOP3SMTPWCZaTMc6Zkx8lljGvo8yyHEFKumVztlYXqIGmj lhbfFWSqUU1+8kkJueUj6WfL/1ialG/Aqhpms= 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=D05aRSDtBy8T/2cyFShIAaqmP79zJMnJc6GIN359i/c=; b=Vhz8jsyF9DcUhrkIXSmm82XH/Kqu5PkPUR1pIfpg56vRC7Tvuv2+a494YcoJ0bmZOs BckpcENNWQUB32aY/tz4BWz5IwRjiKRu5d0z81oPpmNIg1OqPNSf8awDfRz2b4jIjI6m fLuPIubtHx5/zh0NrhmP1YKoPZwZoVEQhd2rMYwCGtrWhSEdgjOXSGAXHkOR1o/DPepA vZLVZEwapLcRXAoa22CPT3zJ0kTrBxy8bPKHl5NEeAWTP5QyPtCntKEqK0jozxf7qwK4 6T0gobBKzR3Asiae/2P2NIL64kctaC5BZ28Ry7dWJTJrMIHs+J+maG0krsqzJQeJ2pfP Xwdg== X-Gm-Message-State: AA+aEWZ2zmVokQEewWLyfX8obzkeqi3Im3H6+Nvy/JOi2aEjJTo0iT13 fVWmfKAsBlIZdAl0NsbK5hhyj/z+Wo0LaQ== X-Google-Smtp-Source: AFSGD/UsW7bFqlegD9ecygnFZZmq2id9TZ6xiut07QyvQGO52iJ3mM9PhhtyNWVY7BCYxp3rwcgWBQ== X-Received: by 2002:a2e:4819:: with SMTP id v25-v6mr16262699lja.2.1543186488348; Sun, 25 Nov 2018 14:54:48 -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 c19sm9047235lfg.86.2018.11.25.14.54.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Nov 2018 14:54:47 -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 v3] mmc: pxamci: Support getting GPIO descs for RO and WP Date: Sun, 25 Nov 2018 23:52:13 +0100 Message-Id: <20181125225217.23201-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181125225217.23201-1-linus.walleij@linaro.org> References: <20181125225217.23201-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 --- 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..baed636870e0 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 (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"); }