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: 151938 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4908890ljp; Sun, 25 Nov 2018 14:54:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/UI7YKLJ6RSoY7INDmej4mGVfAzGBSHQ85YLAlL5Yz5xgsPTyv1X3qD2uQgXte0jIf/5FIv X-Received: by 2002:a17:902:15c5:: with SMTP id a5-v6mr24707382plh.136.1543186491693; Sun, 25 Nov 2018 14:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543186491; cv=none; d=google.com; s=arc-20160816; b=cdaYjMVa5l0NHUsTgMt3Tz8VFZ1/0KUbJwEgy0pnBd1VTNDS02eYvxD/AVBQnI2mqr PlQQHbtqgb1ixCVGt6tyD8Bl6g+OvCA0J4MhMag2DDv/GyotDTIBm0OdEoNI4YreFO+A 4kgTkbU9jZRUqVnIwmcIs7LbyoIVjWYgcpJd+VqDy0ViyAsSIcZ6A+eTLEAsxGZ2+QtA 8PSds8MUMtrn0u6M8+hJGMIyQ8DqKIp3Xl4439O2igf/dU4pCGv71+2Dfln061/Qgaxw Xk9dhZab3yt17rUs/tVtkGk91C2/SMri9Y8oPKug63CS006r/6R0y+rjPxpItoxX713l Zypg== 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=D05aRSDtBy8T/2cyFShIAaqmP79zJMnJc6GIN359i/c=; b=SrIh9tjALiF1V7ZbbG88zZg38H7Gbiw0vk78XTwb5ZIBXpTSQD2BIvX6sMseMFQq7o 8sMvTOZ4nmzY0XPmOUVr2sTMwyrDB3iXpix31SrHRJo1llZHi/Cjko74thnOTIPLIHkO p7cVtxgBcwu4x8nIMihL1lI0pvCWSniZh+4vpIUgN2Imt3qLUwoms+YrYHi8S8bC9arT BYearFHXZhdDngitOZCabsnv/9QO0OfiK4X69YDkzSOed0FJAHWi+UJttVqhO0zLOPx/ +LQc0+pinCwxS5TtU2Ck6fx/RyWt2iVCzbTIlo91BHgOfdjAey7g2tsQrax3oLbMYzBk hdgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Lk0IcaV/"; 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 m75si39838955pga.432.2018.11.25.14.54.51; Sun, 25 Nov 2018 14:54:51 -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="Lk0IcaV/"; 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 S1726079AbeKZJrC (ORCPT + 5 others); 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-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 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(-) -- 2.19.1 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"); }