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: 152654 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5558292ljp; Sun, 2 Dec 2018 00:46:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/XU5OOcmtH1cUIChFExGzj8ISvF8Q6GFjuuj6lqH9jzlqEGdbwQ+MpIUPVMKK8yrX0gldTu X-Received: by 2002:a63:bd1a:: with SMTP id a26mr9715909pgf.121.1543740414400; Sun, 02 Dec 2018 00:46:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543740414; cv=none; d=google.com; s=arc-20160816; b=hOsfmG4pMP5v0N1BmxOWxjC05G8QrkCa4DEKLANJGoNLWFjyAVTOYWeaN/jm9m3nt8 Yic9hGaz4eFlRe+zcaNKkaEEyvgW6G3JBvbFRkg5I3nJfB/f0sVFFRIs5wbvRqxELl9A xchZGX3CyMEKplj4EhDP59IiHj5UG3xaXeZzjAjtADkHoi3mQllbHEZ95nSygQSK8FI/ hfMIOMTL4Edk5Fgpvf01rZH0rx1bG4Pb9hUYCYTryXTOY1t6a8CyAFQxWssuLPjAz4eu 6g2BCdFgVBPsgFBMkBdHmRnVxku/YqU/jsFc5Uo3ks3RkAxE4P4IKhGnfFzkpf6MMsaZ gJCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TzOe2u4fto7Xz/iSAM01s65H6JiNfU2vSdL18luD4Do=; b=xGQrJzX8Gj6Stg8VIaz3Jg43+Tut5ydffTRo+RTlkuDw2C/tagsBvt0u7EvYH2IgtP dFINCSt+2TBfPKg1uLzltfRdIOo+t3VcW4tCFC15PahJARAEmY4jKBUAh/KzPno1AO3j SvXe06bTl6iQUJbEWvFDnv21OUb0keViN7CIYfP06mgoXiZdt+xtQPzeieLApYyZCT8w LlYqbLGrtr627Fr96S3YzZrd8ASNdXbX1IybjkNU9gvHRz4q6lupHgJOtQfnqFjk0DH9 5fY8GxoVmZPzyhqkvM6f7kJOBEosad1IC2pCFsGprQkPFtwNiZBKQJUQFnQM2wyDtedZ rXcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wl5xMcDN; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28si9351748pgz.593.2018.12.02.00.46.54; Sun, 02 Dec 2018 00:46:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wl5xMcDN; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725809AbeLBIq4 (ORCPT + 5 others); 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-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 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 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(-) -- 2.19.1 Acked-by: Robert Jarzmik 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"); }