devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@sonymobile.com>
To: Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Ulf Hansson <ulf.hansson@linaro.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mmc@vger.kernel.org
Subject: [PATCH v2] mmc: core: Allow specifying current consumption
Date: Mon, 12 Oct 2015 18:00:32 -0700	[thread overview]
Message-ID: <1444698032-9051-1-git-send-email-bjorn.andersson@sonymobile.com> (raw)
In-Reply-To: <1435725525-4367-1-git-send-email-bjorn.andersson@sonymobile.com>

This allows us to specify expected current consumption of the vmmc and
vqmmc regulators. This is needed to bring the supplying regulators out
of their low-power-mode while accessing the mmc.

Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
---

The sd specification states that if the host can provide more than 150mA this
should be indicated in the "XPC value in the argument of ACMD41" for SDXC
cards. Should this be tied in with the added property as well?

Changes since v1:
- Property name and description updated to clarify intention

 Documentation/devicetree/bindings/mmc/mmc.txt | 2 ++
 drivers/mmc/core/core.c                       | 6 ++++++
 drivers/mmc/core/host.c                       | 4 ++++
 include/linux/mmc/host.h                      | 2 ++
 4 files changed, 14 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
index 0384fc3f64e8..7514083a9f55 100644
--- a/Documentation/devicetree/bindings/mmc/mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc.txt
@@ -47,6 +47,8 @@ Optional properties:
 - mmc-hs400-1_2v: eMMC HS400 mode(1.2V I/O) is supported
 - dsr: Value the card's (optional) Driver Stage Register (DSR) should be
   programmed with. Valid range: [0 .. 0xffff].
+- vmmc-active-current: current required from the vmmc regulator, in uA
+- vqmmc-active-current: current required from the vqmmc regulator, in uA
 
 *NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line
 polarity properties, we have to fix the meaning of the "normal" and "inverted"
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 23fa221ce803..603f40136306 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1469,12 +1469,18 @@ int mmc_regulator_get_supply(struct mmc_host *mmc)
 			mmc->ocr_avail = ret;
 		else
 			dev_warn(dev, "Failed getting OCR mask: %d\n", ret);
+
+		if (mmc->supply.vmmc_current)
+			regulator_set_load(mmc->supply.vmmc, mmc->supply.vmmc_current);
 	}
 
 	if (IS_ERR(mmc->supply.vqmmc)) {
 		if (PTR_ERR(mmc->supply.vqmmc) == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 		dev_info(dev, "No vqmmc regulator found\n");
+	} else {
+		if (mmc->supply.vqmmc_current)
+			regulator_set_load(mmc->supply.vqmmc, mmc->supply.vqmmc_current);
 	}
 
 	return 0;
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 970e6906930b..ede508d63fb5 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -235,6 +235,10 @@ int mmc_of_parse(struct mmc_host *host)
 			host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
 	}
 
+	/* Parse regulator load requests */
+	of_property_read_u32(np, "vmmc-active-current", &host->supply.vmmc_current);
+	of_property_read_u32(np, "vqmmc-active-current", &host->supply.vqmmc_current);
+
 	/* Parse Write Protection */
 	ro_cap_invert = of_property_read_bool(np, "wp-inverted");
 
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 8673ffe3d86e..640d8dbb8559 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -197,6 +197,8 @@ struct mmc_pwrseq;
 struct mmc_supply {
 	struct regulator *vmmc;		/* Card power supply */
 	struct regulator *vqmmc;	/* Optional Vccq supply */
+	u32 vmmc_current;		/* Requested current for vmmc */
+	u32 vqmmc_current;		/* Requested current for vqmmc */
 };
 
 struct mmc_host {
-- 
2.4.2


  parent reply	other threads:[~2015-10-13  1:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01  4:38 [PATCH] mmc: core: Set load on vmmc and vqmmc Bjorn Andersson
2015-07-01 10:59 ` Mark Brown
2015-07-02 18:10   ` Bjorn Andersson
2015-10-13  1:00 ` Bjorn Andersson [this message]
2015-10-16 12:55   ` [PATCH v2] mmc: core: Allow specifying current consumption Ulf Hansson
     [not found]     ` <CAPDyKFqQEY64AToR0So72Sc4DtKhH5Sxff=oy8pDZZmw8O0aMQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-17 17:09       ` Bjorn Andersson

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=1444698032-9051-1-git-send-email-bjorn.andersson@sonymobile.com \
    --to=bjorn.andersson@sonymobile.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=ulf.hansson@linaro.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).