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: 4383101 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6689F9F26E for ; Thu, 19 Jun 2014 13:05:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F32920340 for ; Thu, 19 Jun 2014 13:05:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75105201F7 for ; Thu, 19 Jun 2014 13:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754476AbaFSNFn (ORCPT ); Thu, 19 Jun 2014 09:05:43 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:54129 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978AbaFSNF1 (ORCPT ); Thu, 19 Jun 2014 09:05:27 -0400 Received: by mail-lb0-f173.google.com with SMTP id s7so1438723lbd.32 for ; Thu, 19 Jun 2014 06:05:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PqvaoffNvr7+XAGY8e0JmBF9FgBHhrtQyRPTLWvew3o=; b=GcYToXGnnjG4Sj7zZplgo2HGZ6FQZW95R1ZS9JaLnxmxHUVhl1zJpIHdOn3y8I1Wey wVB+IvEPN2cItpE/YffwC3Rs2vsylhkgN+yH6bpIbQIFs63lmR3xpU6moWGz9Q93h8B6 tX2cFHsoFmqJP89VefZnxkyExpPx1VvzwPGbtpumLpauOSFjYjve1KcCbH14Q2nCWMH/ Fz47HkGLqcfKJaclbLqWZrGHgz/tu3VR/bzleXuRoiVCF7OQP+jRxoZGb3h4/xbShfdX sO++b6ymybUQOjtvgBHBKLUY+Nz0THg9802XMEAJYcRXUaKJp8+uoOXOXDctSgB0ApNw bp6g== X-Gm-Message-State: ALoCoQlqq3VFJsvABFljEro/2HizV0AfW2aJx6stXE/u029ehpFqjCkS41IlHPl6kzbyMilT4hj9 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> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;