mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Chris Ball <chris@printf.net>,
	Seungwon Jeon <tgih.jun@samsung.com>,
	Tim Kryger <tim.kryger@linaro.org>,
	Haijun Zhang <Haijun.Zhang@freescale.com>,
	Mark Brown <broonie@kernel.org>,
	Doug Anderson <dianders@chromium.org>,
	Olof Johansson <olof@lixom.net>,
	Yuvaraj Kumar C D <yuvaraj.cd@gmail.com>,
	linux-samsung-soc@vger.kernel.org, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Subject: [PATCH 1/1] mmc: core: Use regulator_get_voltage() if OCR mask is empty.
Date: Thu, 14 Aug 2014 14:39:00 +0200	[thread overview]
Message-ID: <1408019940-11153-1-git-send-email-javier.martinez@collabora.co.uk> (raw)

The operation conditions register (OCR) stores the voltage
profile of the card, however the list of possible voltages
is restricted by the voltage range supported by the supply
used as VCC/VDD. So in mmc_vddrange_to_ocrmask() a OCR mask
is obtained to filter the not supported voltages, from the
value read in the host controller OCR register.

For fixed regulators, regulator_list_voltage() returns the
fixed output for the first selector but this doesn't happen
for switch (FET) regulators that obtain their voltage from
their parent supply. A call to regulator_get_voltage() is
needed in this case so the regulator core can return the
FET's parent supply voltage output.

This change is consistent with the fact that for other
fixed regulators (that are not FETs) the OCR mask is
returned even when mmc_regulator_set_ocr() checks if the
regulator is fixed before calling regulator_set_voltage().

Without this patch, the following warning is reported when
a FET is used as a vmmc-supply:

dwmmc_exynos 12220000.mmc: Failed getting OCR mask: -22

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---

 drivers/mmc/core/core.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 7dc0c85..8abae04 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1221,15 +1221,14 @@ int mmc_regulator_get_ocrmask(struct regulator *supply)
 	int			result = 0;
 	int			count;
 	int			i;
+	int			vdd_uV;
+	int			vdd_mV;
 
 	count = regulator_count_voltages(supply);
 	if (count < 0)
 		return count;
 
 	for (i = 0; i < count; i++) {
-		int		vdd_uV;
-		int		vdd_mV;
-
 		vdd_uV = regulator_list_voltage(supply, i);
 		if (vdd_uV <= 0)
 			continue;
@@ -1238,6 +1237,15 @@ int mmc_regulator_get_ocrmask(struct regulator *supply)
 		result |= mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
 	}
 
+	if (!result) {
+		vdd_uV = regulator_get_voltage(supply);
+		if (vdd_uV <= 0)
+			return vdd_uV;
+
+		vdd_mV = vdd_uV / 1000;
+		result = mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
+	}
+
 	return result;
 }
 EXPORT_SYMBOL_GPL(mmc_regulator_get_ocrmask);
-- 
2.0.0.rc2


             reply	other threads:[~2014-08-14 12:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-14 12:39 Javier Martinez Canillas [this message]
2014-08-14 14:13 ` Tim Kryger
2014-08-14 15:19   ` Mark Brown
2014-08-15  5:36     ` Tim Kryger
2014-08-15  7:48       ` Javier Martinez Canillas
2014-08-15  9:55         ` Mark Brown
2014-08-15 11:13           ` Javier Martinez Canillas
2014-08-15 14:51           ` Ulf Hansson
2014-08-16 12:59             ` Mark Brown
2014-08-19 11:29             ` Javier Martinez Canillas
2014-08-19 12:43               ` Ulf Hansson
2014-08-19 12:54                 ` Javier Martinez Canillas
2014-08-15 14:19         ` Tim Kryger
2014-08-15 22:29           ` Mark Brown
2014-08-17 17:11             ` Tim Kryger
2014-08-18 13:18               ` Mark Brown
2014-08-15  8:59       ` Mark Brown
2014-08-14 15:29   ` Javier Martinez Canillas
2014-08-19 12:51 ` Ulf Hansson

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=1408019940-11153-1-git-send-email-javier.martinez@collabora.co.uk \
    --to=javier.martinez@collabora.co.uk \
    --cc=Haijun.Zhang@freescale.com \
    --cc=broonie@kernel.org \
    --cc=chris@printf.net \
    --cc=dianders@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=tgih.jun@samsung.com \
    --cc=tim.kryger@linaro.org \
    --cc=ulf.hansson@linaro.org \
    --cc=yuvaraj.cd@gmail.com \
    /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

all inboxes | Powered by JetHome®