From: Ulf Hansson <ulf.hansson@linaro.org>
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 <gregkh@linuxfoundation.org>,
Linus Walleij <linus.walleij@linaro.org>,
Mark Brown <broonie@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Alexandre Courbot <gnurou@gmail.com>,
Arend van Spriel <arend@broadcom.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Chris Ball <chris@printf.net>, Chen-Yu Tsai <wens@csie.org>,
Olof Johansson <olof@lixom.net>,
Russell King <linux@arm.linux.org.uk>,
Tomasz Figa <tomasz.figa@gmail.com>,
Hans de Goede <hdegoede@redhat.com>,
Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ulf Hansson <ulf.hansson@linaro.org>
Subject: [RFC 2/2] mmc: core: Add support for power sequences
Date: Thu, 19 Jun 2014 15:04:51 +0200 [thread overview]
Message-ID: <1403183091-27876-3-git-send-email-ulf.hansson@linaro.org> (raw)
In-Reply-To: <1403183091-27876-1-git-send-email-ulf.hansson@linaro.org>
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 <ulf.hansson@linaro.org>
---
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 <linux/random.h>
#include <linux/slab.h>
#include <linux/of.h>
+#include <linux/pwrseq.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
@@ -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 <linux/leds.h>
#include <linux/slab.h>
#include <linux/suspend.h>
+#include <linux/pwrseq.h>
#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
@@ -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;
--
1.7.9.5
prev parent reply other threads:[~2014-06-19 13:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-19 13:04 [RFC 0/2] pwrseq: Add subsystem for power sequences Ulf Hansson
2014-06-19 13:04 ` [RFC 1/2] pwrseq: Add subsystem to handle complex " Ulf Hansson
2014-06-19 14:03 ` Hans de Goede
2014-06-19 14:23 ` Hans de Goede
2014-07-01 16:33 ` Ulf Hansson
2014-06-19 17:18 ` Olof Johansson
2014-06-20 7:27 ` Hans de Goede
2014-06-20 8:02 ` Olof Johansson
2014-06-20 8:14 ` Hans de Goede
[not found] ` <53A3ED65.80605-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-07-01 16:42 ` Ulf Hansson
2014-07-01 16:51 ` Arnd Bergmann
2014-07-01 16:56 ` Arend van Spriel
2014-06-20 15:42 ` Arnd Bergmann
2014-07-01 16:56 ` Ulf Hansson
2014-06-19 13:04 ` Ulf Hansson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403183091-27876-3-git-send-email-ulf.hansson@linaro.org \
--to=ulf.hansson@linaro.org \
--cc=arend@broadcom.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=chris@printf.net \
--cc=devicetree@vger.kernel.org \
--cc=gnurou@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.rutland@arm.com \
--cc=olof@lixom.net \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=tomasz.figa@gmail.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).