From patchwork Wed Jan 28 13:16:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 43886 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E8FFE2410D for ; Wed, 28 Jan 2015 20:29:38 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id fb4sf7317067wid.3 for ; Wed, 28 Jan 2015 12:29:38 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=zmTwprKB5hjJlh7eV7ZcJtaxGeV0R19Y2XbbVuKn3hU=; b=cZ9I8z7Cr2+ziVFwwx2y/Z9RoFEOKvslabF2nXgmmtL4BJyt8yP9/Ah3mWRXpC41if a1u65Hnv7FaKK5N/7liiHPgmOwmGJUX3zv8EiW2cjQ1j2P6ZIIMv41ItbYRl3aYDEdPl NNsx3LEN+ficdH9zp+omOJaVCJn4Ob4kf6ghuKx1ZPQlX52C2rdMSVg695zw94POFhk3 4rjT2+BOXETKo5/0rS/qGlbrHYwA01+C7Lap/AONniS0GsBKVIM0ur/RcYlhfFUNgnZR a99fUoLrSgjO6Qq15HziWN33mLzRWSrdbRhzMb11fG2btiD+C0sIS3XZzlV+frNyBv9r wIvQ== X-Gm-Message-State: ALoCoQlmdtfY2vz1yEFUJozVqFQSqDov2Um6inFgpDnJ/5t52WyKQEGlAObPa2blgqyhBgq0rxhV X-Received: by 10.180.87.72 with SMTP id v8mr3653930wiz.3.1422476977987; Wed, 28 Jan 2015 12:29:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.10.197 with SMTP id k5ls199729lab.77.gmail; Wed, 28 Jan 2015 12:29:37 -0800 (PST) X-Received: by 10.112.147.137 with SMTP id tk9mr10403225lbb.39.1422476977826; Wed, 28 Jan 2015 12:29:37 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id q8si5451257laj.104.2015.01.28.12.29.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Jan 2015 12:29:37 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id p9so21132065lbv.8 for ; Wed, 28 Jan 2015 12:29:37 -0800 (PST) X-Received: by 10.152.203.230 with SMTP id kt6mr10461677lac.38.1422476977735; Wed, 28 Jan 2015 12:29:37 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1555511lbj; Wed, 28 Jan 2015 12:29:36 -0800 (PST) X-Received: by 10.70.123.10 with SMTP id lw10mr8487523pdb.161.1422476975894; Wed, 28 Jan 2015 12:29:35 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gy1si7209719pbd.34.2015.01.28.12.29.35; Wed, 28 Jan 2015 12:29:35 -0800 (PST) Received-SPF: none (google.com: linux-mmc-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759442AbbA1U3X (ORCPT + 3 others); Wed, 28 Jan 2015 15:29:23 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:40263 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759421AbbA1U3P (ORCPT ); Wed, 28 Jan 2015 15:29:15 -0500 Received: by mail-wi0-f174.google.com with SMTP id n3so14819245wiv.1 for ; Wed, 28 Jan 2015 12:29:13 -0800 (PST) X-Received: by 10.180.21.206 with SMTP id x14mr7087461wie.64.1422451023594; Wed, 28 Jan 2015 05:17:03 -0800 (PST) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-2-98-209-190.as13285.net. [2.98.209.190]) by mx.google.com with ESMTPSA id fo17sm6080227wjc.19.2015.01.28.05.17.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Jan 2015 05:17:02 -0800 (PST) From: Srinivas Kandagatla To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Kumar Gala , Rob Herring , Srinivas Kandagatla Subject: [PATCH 1/2] mmc: pwrseq: Add support to control multiple gpios in simple pwrseq Date: Wed, 28 Jan 2015 13:16:59 +0000 Message-Id: <1422451019-9372-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422450981-9328-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1422450981-9328-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srinivas.kandagatla@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.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch adds support to reset/powerup multiple gpio pins on a given sdio bus. The use case is simple, on sdio we could have multiple devices like WLAN, BT which are controlled by there own reset lines. So having multiple reset is something more useful in such cases. Without this patch I could not get BT and WLAN working at same time on IFC6410. Signed-off-by: Srinivas Kandagatla --- drivers/mmc/core/pwrseq_simple.c | 64 ++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c index 0958c69..bb9aadd 100644 --- a/drivers/mmc/core/pwrseq_simple.c +++ b/drivers/mmc/core/pwrseq_simple.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -19,34 +20,44 @@ struct mmc_pwrseq_simple { struct mmc_pwrseq pwrseq; - struct gpio_desc *reset_gpio; + int ngpios; + struct gpio_desc *reset_gpios[0]; }; -static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host) +static void __mmc_pwrseq_simple_pre_post_power_on_off(struct mmc_host *host, + bool on) { struct mmc_pwrseq_simple *pwrseq = container_of(host->pwrseq, struct mmc_pwrseq_simple, pwrseq); + int i; - if (!IS_ERR(pwrseq->reset_gpio)) - gpiod_set_value_cansleep(pwrseq->reset_gpio, 1); + if (!IS_ERR(pwrseq->reset_gpios)) { + for (i = 0; i < pwrseq->ngpios; i++) + gpiod_set_value_cansleep(pwrseq->reset_gpios[i], + on ? : 0); + } } -static void mmc_pwrseq_simple_post_power_on(struct mmc_host *host) +static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host) { - struct mmc_pwrseq_simple *pwrseq = container_of(host->pwrseq, - struct mmc_pwrseq_simple, pwrseq); + __mmc_pwrseq_simple_pre_post_power_on_off(host, true); +} - if (!IS_ERR(pwrseq->reset_gpio)) - gpiod_set_value_cansleep(pwrseq->reset_gpio, 0); +static void mmc_pwrseq_simple_post_power_on(struct mmc_host *host) +{ + __mmc_pwrseq_simple_pre_post_power_on_off(host, false); } static void mmc_pwrseq_simple_free(struct mmc_host *host) { struct mmc_pwrseq_simple *pwrseq = container_of(host->pwrseq, struct mmc_pwrseq_simple, pwrseq); + int i; - if (!IS_ERR(pwrseq->reset_gpio)) - gpiod_put(pwrseq->reset_gpio); + if (!IS_ERR(pwrseq->reset_gpios)) { + for (i = 0; i < pwrseq->ngpios; i++) + gpiod_put(pwrseq->reset_gpios[i]); + } kfree(pwrseq); host->pwrseq = NULL; @@ -62,20 +73,35 @@ static struct mmc_pwrseq_ops mmc_pwrseq_simple_ops = { int mmc_pwrseq_simple_alloc(struct mmc_host *host, struct device *dev) { struct mmc_pwrseq_simple *pwrseq; - int ret = 0; + int ngpios, i, ret = 0; + + ngpios = of_count_phandle_with_args(dev->of_node, + "reset-gpios", "#gpio-cells"); - pwrseq = kzalloc(sizeof(struct mmc_pwrseq_simple), GFP_KERNEL); + if (!ngpios) + return -ENOENT; + + pwrseq = kzalloc(sizeof(struct mmc_pwrseq_simple) + + ngpios * sizeof(struct gpio_desc *), 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; + for (i = 0; i < ngpios; i++) { + pwrseq->reset_gpios[i] = gpiod_get_index(dev, "reset", + i, GPIOD_OUT_HIGH); + if (IS_ERR(pwrseq->reset_gpios[i]) && + PTR_ERR(pwrseq->reset_gpios[i]) != -ENOENT && + PTR_ERR(pwrseq->reset_gpios[i]) != -ENOSYS) { + ret = PTR_ERR(pwrseq->reset_gpios[i]); + + while (--i) + gpiod_put(pwrseq->reset_gpios[i]); + + goto free; + } } + pwrseq->ngpios = ngpios; pwrseq->pwrseq.ops = &mmc_pwrseq_simple_ops; host->pwrseq = &pwrseq->pwrseq;