From patchwork Fri Jan 2 16:14:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 42701 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A605F20545 for ; Fri, 2 Jan 2015 16:14:37 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf10585716lbv.9 for ; Fri, 02 Jan 2015 08:14:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=TKiKbZONC3oPqPkCUgKYrFOWmX7lBUESzxiSw80di3w=; b=gQWRZkvSVZ4rgZGoqQwgG883bsCQFlJupCqVcWJGCJOzzrMPK1Cq9zCZ0VQ8WNnONr i4OprnHCvBZxqVpZL6xVPy1yQgpLH2YIp3wEmy3nklljQMCSduE9LC++WjIFGhzidLPN yKeDDzTl7da5qo0x9VQ7aXF1M4e4nb2G6vJ09/IAaEGe6+2NKiXPq8n1F3lkQ2WJYYLF Il6WJR/J8PXOHj25uDNtkMC/g0/WSPkLvA/mASMAfx168ty5JvSrffSo3nFeO9KTc1pk 0vFOGc4SB0ikU0CUxZSbHTgL1M0JHbdd/DmRYA2eSiofABo7AukVRIqvpaGIbpXoM8gN RAbA== X-Gm-Message-State: ALoCoQkb/K+g2OkEPMCkbqfFFH3li1ahFIb7Mm/ERJ/u8zA1+HODsv3XezeSAijo3PCo0RqfCBUJ X-Received: by 10.112.171.74 with SMTP id as10mr328263lbc.8.1420215276397; Fri, 02 Jan 2015 08:14:36 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.200 with SMTP id d8ls1778183lah.18.gmail; Fri, 02 Jan 2015 08:14:36 -0800 (PST) X-Received: by 10.152.5.198 with SMTP id u6mr78201779lau.42.1420215276191; Fri, 02 Jan 2015 08:14:36 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id ds5si44614566lbc.138.2015.01.02.08.14.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Jan 2015 08:14:36 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id z11so7203335lbi.6 for ; Fri, 02 Jan 2015 08:14:36 -0800 (PST) X-Received: by 10.152.164.133 with SMTP id yq5mr71605844lab.38.1420215276080; Fri, 02 Jan 2015 08:14:36 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.9.200 with SMTP id c8csp235576lbb; Fri, 2 Jan 2015 08:14:35 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr76672156lac.6.1420215268758; Fri, 02 Jan 2015 08:14:28 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id f10si14540142lbs.123.2015.01.02.08.14.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Jan 2015 08:14:28 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pn19so15919663lab.9 for ; Fri, 02 Jan 2015 08:14:28 -0800 (PST) X-Received: by 10.112.156.132 with SMTP id we4mr52554992lbb.59.1420215268649; Fri, 02 Jan 2015 08:14:28 -0800 (PST) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id y5sm12786551lag.7.2015.01.02.08.14.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Jan 2015 08:14:27 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Linus Walleij , Mark Brown , Arnd Bergmann , Alexandre Courbot , Arend van Spriel , Sascha Hauer , Olof Johansson , Russell King , Hans de Goede , Doug Anderson , NeilBrown , Ulf Hansson Subject: [PATCH 4/4] mmc: pwrseq_simple: Add support for a reset GPIO pin Date: Fri, 2 Jan 2015 17:14:08 +0100 Message-Id: <1420215248-20650-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1420215248-20650-1-git-send-email-ulf.hansson@linaro.org> References: <1420215248-20650-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The need for a reset GPIO has several times been pointed out from earlier posted patchsets. Especially some WLAN chips which are attached to an SDIO interface may use a GPIO reset. In this first version, one reset pin is supported. We may want to extend the support to cover more pins, but let's leave that as a future change. The added DT binding for the reset GPIO can easily be extended to manage several pins. The reset GPIO is asserted at initialization and prior we start the power up procedure. It will then be de-asserted right after the power has been provided for the external chip/card, from the ->power_on() callback. Note, the reset GPIO is optional. Thus we don't return an error even if we can't find a GPIO pin for the consumer. Signed-off-by: Ulf Hansson --- .../devicetree/bindings/mmc/mmc,pwrseq-simple.txt | 5 +++ drivers/mmc/core/pwrseq_simple.c | 38 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/mmc,pwrseq-simple.txt b/Documentation/devicetree/bindings/mmc/mmc,pwrseq-simple.txt index e1b7f9c..6fe0cd6 100644 --- a/Documentation/devicetree/bindings/mmc/mmc,pwrseq-simple.txt +++ b/Documentation/devicetree/bindings/mmc/mmc,pwrseq-simple.txt @@ -11,8 +11,13 @@ for several SOC designs. Required properties: - compatible : contains "mmc,pwrseq-simple". +Optional properties: +- reset-gpios : contains a list of GPIO specifiers, though currently only one + specifier is supported. + Example: sdhci0_pwrseq { compatible = "mmc,pwrseq-simple"; + reset-gpios = <&gpio1 12 0>; } diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c index 7f87bc1..97112b1 100644 --- a/drivers/mmc/core/pwrseq_simple.c +++ b/drivers/mmc/core/pwrseq_simple.c @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -18,31 +19,68 @@ struct mmc_pwrseq_simple { struct mmc_pwrseq pwrseq; + struct gpio_desc *reset_gpio; }; +static void mmc_pwrseq_simple_power_up(struct mmc_host *host) +{ + struct mmc_pwrseq_simple *pwrseq = container_of(host->pwrseq, + struct mmc_pwrseq_simple, pwrseq); + + if (!IS_ERR(pwrseq->reset_gpio)) + gpiod_set_value_cansleep(pwrseq->reset_gpio, 1); +} + +static void mmc_pwrseq_simple_power_on(struct mmc_host *host) +{ + struct mmc_pwrseq_simple *pwrseq = container_of(host->pwrseq, + struct mmc_pwrseq_simple, pwrseq); + + if (!IS_ERR(pwrseq->reset_gpio)) + gpiod_set_value_cansleep(pwrseq->reset_gpio, 0); +} + static void mmc_pwrseq_simple_free(struct mmc_host *host) { struct mmc_pwrseq_simple *pwrseq = container_of(host->pwrseq, struct mmc_pwrseq_simple, pwrseq); + if (!IS_ERR(pwrseq->reset_gpio)) + gpiod_put(pwrseq->reset_gpio); + kfree(&pwrseq); host->pwrseq = NULL; } static struct mmc_pwrseq_ops mmc_pwrseq_simple_ops = { + .power_up = mmc_pwrseq_simple_power_up, + .power_on = mmc_pwrseq_simple_power_on, + .power_off = mmc_pwrseq_simple_power_up, .free = mmc_pwrseq_simple_free, }; int mmc_pwrseq_simple_alloc(struct mmc_host *host, struct device *dev) { struct mmc_pwrseq_simple *pwrseq; + int ret = 0; pwrseq = kzalloc(sizeof(struct mmc_pwrseq_simple), GFP_KERNEL); if (!pwrseq) return -ENOMEM; + pwrseq->reset_gpio = gpiod_get_index(dev, "reset", 0, GPIOD_OUT_HIGH); + if (IS_ERR(pwrseq->reset_gpio) && + PTR_ERR(pwrseq->reset_gpio) != -ENOENT && + PTR_ERR(pwrseq->reset_gpio) != -ENOSYS) { + ret = PTR_ERR(pwrseq->reset_gpio); + goto free; + } + pwrseq->pwrseq.ops = &mmc_pwrseq_simple_ops; host->pwrseq = &pwrseq->pwrseq; return 0; +free: + kfree(&pwrseq); + return ret; }