From patchwork Thu Jun 19 13:04:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 32216 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3C269206A0 for ; Thu, 19 Jun 2014 13:05:28 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id h18sf8226073igc.2 for ; Thu, 19 Jun 2014 06:05:27 -0700 (PDT) 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=PqvaoffNvr7+XAGY8e0JmBF9FgBHhrtQyRPTLWvew3o=; b=Sw9W37hUeHBnOh+YOBt/ZJ26bjFa1f5UKonbkwEBlOARCTGXigM1E3BAmmhp6epZlj R4Bgz31TYoqNmtNJQgiHnMYn0Rbw2wHCgsAbbI3jFNS7oY9L0lWVPXJ9jCN23hRQUYKl UuHvimX4tkXnqQmGU23EzFqizD/hAzrHZtm61AIb5U2L9YAcC7w2KGIJZ0XOg2KG3BDO S7+70JSgQJ04jV4oQngaQOwApKrWFxlcKRE9hSW8mOxtWqHFaTJLCR0JenHxaM9b8k4h ksrwE8obAtZbOdG7L6zqRtZiIrnm9xou/r5J3PPfBOzPfB87imgkrFSxRdAFTyW2y5iv F8IQ== X-Gm-Message-State: ALoCoQlLtYVsyG00tBgQj9KAaukEm8kBplx4wimRXDvxJubbg5+h+TZ3cFpOMpEgXiV1bmo5pHSH X-Received: by 10.183.11.102 with SMTP id eh6mr2163323obd.37.1403183127746; Thu, 19 Jun 2014 06:05:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.145 with SMTP id o17ls519078qga.37.gmail; Thu, 19 Jun 2014 06:05:27 -0700 (PDT) X-Received: by 10.52.51.196 with SMTP id m4mr3300845vdo.26.1403183127661; Thu, 19 Jun 2014 06:05:27 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id ce2si2329561vdc.67.2014.06.19.06.05.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Jun 2014 06:05:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id db11so2232840veb.40 for ; Thu, 19 Jun 2014 06:05:27 -0700 (PDT) X-Received: by 10.221.7.71 with SMTP id on7mr3908733vcb.18.1403183127572; Thu, 19 Jun 2014 06:05:27 -0700 (PDT) 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.221.54.6 with SMTP id vs6csp360291vcb; Thu, 19 Jun 2014 06:05:27 -0700 (PDT) X-Received: by 10.112.34.8 with SMTP id v8mr199026lbi.106.1403183126252; Thu, 19 Jun 2014 06:05:26 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) by mx.google.com with ESMTPS id xh4si2350818lbb.17.2014.06.19.06.05.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Jun 2014 06:05:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id el20so1376095lab.7 for ; Thu, 19 Jun 2014 06:05:25 -0700 (PDT) X-Received: by 10.112.85.167 with SMTP id i7mr3233713lbz.32.1403183125624; Thu, 19 Jun 2014 06:05:25 -0700 (PDT) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id ar1sm4133975lbc.3.2014.06.19.06.05.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Jun 2014 06:05:24 -0700 (PDT) From: Ulf Hansson To: linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Cc: Greg Kroah-Hartman , Linus Walleij , Mark Brown , Arnd Bergmann , Alexandre Courbot , Arend van Spriel , Sascha Hauer , Chris Ball , Chen-Yu Tsai , Olof Johansson , Russell King , Tomasz Figa , Hans de Goede , Rob Herring , Pawel Moll , Mark Rutland , Ulf Hansson Subject: [RFC 2/2] mmc: core: Add support for power sequences Date: Thu, 19 Jun 2014 15:04:51 +0200 Message-Id: <1403183091-27876-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1403183091-27876-1-git-send-email-ulf.hansson@linaro.org> References: <1403183091-27876-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.128.181 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 MMC subsystem uses a discoverable bus which sometimes means the power sequences to enable power to the card, is far too complex to be handled through the regular ->set_ios() callback. To adress these scenarios, we try to fetch a pwrseq method while parsing the common MMC DT bindings. If a such method is found we select the corresponding state for it from mmc_power_up|off(). Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 7 +++++++ drivers/mmc/core/host.c | 5 +++++ include/linux/mmc/host.h | 3 +++ 3 files changed, 15 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 7dc0c85..46558b5 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1533,6 +1534,9 @@ void mmc_power_up(struct mmc_host *host, u32 ocr) mmc_host_clk_hold(host); + if (!IS_ERR(host->pwrseq)) + pwrseq_select_state(host->pwrseq, PWRSEQ_POWER_ON); + host->ios.vdd = fls(ocr) - 1; if (mmc_host_is_spi(host)) host->ios.chip_select = MMC_CS_HIGH; @@ -1591,6 +1595,9 @@ void mmc_power_off(struct mmc_host *host) host->ios.timing = MMC_TIMING_LEGACY; mmc_set_ios(host); + if (!IS_ERR(host->pwrseq)) + pwrseq_select_state(host->pwrseq, PWRSEQ_POWER_OFF); + /* * Some configurations, such as the 802.11 SDIO card in the OLPC * XO-1.5, require a short delay after poweroff before the card diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 95cceae..fdf8596 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -317,6 +318,10 @@ int mmc_of_parse(struct mmc_host *host) if (!host->parent || !host->parent->of_node) return 0; + host->pwrseq = devm_pwrseq_get_optional(host->parent); + if (IS_ERR(host->pwrseq)) + return PTR_ERR(host->pwrseq); + np = host->parent->of_node; /* "bus-width" is translated to MMC_CAP_*_BIT_DATA flags */ diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 7960424..306b78c 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -195,9 +195,12 @@ struct mmc_supply { struct regulator *vqmmc; /* Optional Vccq supply */ }; +struct pwrseq; + struct mmc_host { struct device *parent; struct device class_dev; + struct pwrseq *pwrseq; int index; const struct mmc_host_ops *ops; unsigned int f_min;