lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1403183091-27876-3-git-send-email-ulf.hansson@linaro.org>
Date:	Thu, 19 Jun 2014 15:04:51 +0200
From:	Ulf Hansson <ulf.hansson@...aro.org>
To:	linux-kernel@...r.kernel.org, linux-mmc@...r.kernel.org,
	linux-pm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
	devicetree@...r.kernel.org
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Linus Walleij <linus.walleij@...aro.org>,
	Mark Brown <broonie@...nel.org>, Arnd Bergmann <arnd@...db.de>,
	Alexandre Courbot <gnurou@...il.com>,
	Arend van Spriel <arend@...adcom.com>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Chris Ball <chris@...ntf.net>, Chen-Yu Tsai <wens@...e.org>,
	Olof Johansson <olof@...om.net>,
	Russell King <linux@....linux.org.uk>,
	Tomasz Figa <tomasz.figa@...il.com>,
	Hans de Goede <hdegoede@...hat.com>,
	Rob Herring <robh+dt@...nel.org>,
	Pawel Moll <pawel.moll@....com>,
	Mark Rutland <mark.rutland@....com>,
	Ulf Hansson <ulf.hansson@...aro.org>
Subject: [RFC 2/2] mmc: core: Add support for power sequences

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@...aro.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ