public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mmc: core: Remove fixed voltage regulator logic
@ 2014-08-12  5:05 Tim Kryger
  2014-08-12  8:49 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Kryger @ 2014-08-12  5:05 UTC (permalink / raw)
  To: Chris Ball, Ulf Hansson
  Cc: Tim Kryger, Linux MMC List, Linux Kernel Mailing List

There is no need for regulator consumers to include special logic for
fixed voltage regulators as they support regulator_set_voltage() just
like their non-fixed regulator counterparts.

Signed-off-by: Tim Kryger <tim.kryger@gmail.com>
---

Changes in v2:
  - Remove query of the current voltage, just set the desired voltage


This simplification of logic is possible due to a recent change that
allows fixed regulators to return success for regulator_set_voltage
operations if the requested range overlaps with the fixed voltage.

c00dc35 regulator: core: Allow regulator_set_voltage for fixed regulators

I have verified this change on a BeagleBone Black where the eMMC and SD
card receive a fixed 3.3v supply.  The TI HSMMC driver used on the BBB,
like the Intel PXA MMC driver, ensures that software only requests VMMC
be set to supported voltage ranges by calling mmc_regulator_get_ocrmask.
This function considers the capabilities of the regulator in order to
determine an appropriate OCR mask of supported voltages that constrains
the set of values which may later be passed into mmc_regulator_set_ocr.

Once the following (queued) patch is merged, the SDHCI driver will call
mmc_regulator_get_supply which then calls mmc_regulator_get_ocrmask.

https://lkml.org/lkml/2014/6/13/451

The Atmel, ARM, Freescale MXC, SuperH Internal MMCIF, Allwinner sunxi,
Toshiba Mobile IO Controller, and Renesas USDHI6ROL0 drivers already
call mmc_regulator_get_supply so they too only request voltages that
are achievable.

There are no other callers of mmc_regulator_set_ocr so this patch should
be safe.


 drivers/mmc/core/core.c |   18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 7dc0c85..1a3e35b 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1263,7 +1263,6 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
 
 	if (vdd_bit) {
 		int		tmp;
-		int		voltage;
 
 		/*
 		 * REVISIT mmc_vddrange_to_ocrmask() may have set some
@@ -1280,22 +1279,7 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
 			max_uV = min_uV + 100 * 1000;
 		}
 
-		/*
-		 * If we're using a fixed/static regulator, don't call
-		 * regulator_set_voltage; it would fail.
-		 */
-		voltage = regulator_get_voltage(supply);
-
-		if (!regulator_can_change_voltage(supply))
-			min_uV = max_uV = voltage;
-
-		if (voltage < 0)
-			result = voltage;
-		else if (voltage < min_uV || voltage > max_uV)
-			result = regulator_set_voltage(supply, min_uV, max_uV);
-		else
-			result = 0;
-
+		result = regulator_set_voltage(supply, min_uV, max_uV);
 		if (result == 0 && !mmc->regulator_enabled) {
 			result = regulator_enable(supply);
 			if (!result)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mmc: core: Remove fixed voltage regulator logic
  2014-08-12  5:05 [PATCH v2] mmc: core: Remove fixed voltage regulator logic Tim Kryger
@ 2014-08-12  8:49 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2014-08-12  8:49 UTC (permalink / raw)
  To: Tim Kryger; +Cc: Chris Ball, Linux MMC List, Linux Kernel Mailing List

On 12 August 2014 07:05, Tim Kryger <tim.kryger@gmail.com> wrote:
> There is no need for regulator consumers to include special logic for
> fixed voltage regulators as they support regulator_set_voltage() just
> like their non-fixed regulator counterparts.
>
> Signed-off-by: Tim Kryger <tim.kryger@gmail.com>

Thanks! Queued for 3.18.

Kind regards
Uffe

> ---
>
> Changes in v2:
>   - Remove query of the current voltage, just set the desired voltage
>
>
> This simplification of logic is possible due to a recent change that
> allows fixed regulators to return success for regulator_set_voltage
> operations if the requested range overlaps with the fixed voltage.
>
> c00dc35 regulator: core: Allow regulator_set_voltage for fixed regulators
>
> I have verified this change on a BeagleBone Black where the eMMC and SD
> card receive a fixed 3.3v supply.  The TI HSMMC driver used on the BBB,
> like the Intel PXA MMC driver, ensures that software only requests VMMC
> be set to supported voltage ranges by calling mmc_regulator_get_ocrmask.
> This function considers the capabilities of the regulator in order to
> determine an appropriate OCR mask of supported voltages that constrains
> the set of values which may later be passed into mmc_regulator_set_ocr.
>
> Once the following (queued) patch is merged, the SDHCI driver will call
> mmc_regulator_get_supply which then calls mmc_regulator_get_ocrmask.
>
> https://lkml.org/lkml/2014/6/13/451
>
> The Atmel, ARM, Freescale MXC, SuperH Internal MMCIF, Allwinner sunxi,
> Toshiba Mobile IO Controller, and Renesas USDHI6ROL0 drivers already
> call mmc_regulator_get_supply so they too only request voltages that
> are achievable.
>
> There are no other callers of mmc_regulator_set_ocr so this patch should
> be safe.
>
>
>  drivers/mmc/core/core.c |   18 +-----------------
>  1 file changed, 1 insertion(+), 17 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 7dc0c85..1a3e35b 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -1263,7 +1263,6 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
>
>         if (vdd_bit) {
>                 int             tmp;
> -               int             voltage;
>
>                 /*
>                  * REVISIT mmc_vddrange_to_ocrmask() may have set some
> @@ -1280,22 +1279,7 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
>                         max_uV = min_uV + 100 * 1000;
>                 }
>
> -               /*
> -                * If we're using a fixed/static regulator, don't call
> -                * regulator_set_voltage; it would fail.
> -                */
> -               voltage = regulator_get_voltage(supply);
> -
> -               if (!regulator_can_change_voltage(supply))
> -                       min_uV = max_uV = voltage;
> -
> -               if (voltage < 0)
> -                       result = voltage;
> -               else if (voltage < min_uV || voltage > max_uV)
> -                       result = regulator_set_voltage(supply, min_uV, max_uV);
> -               else
> -                       result = 0;
> -
> +               result = regulator_set_voltage(supply, min_uV, max_uV);
>                 if (result == 0 && !mmc->regulator_enabled) {
>                         result = regulator_enable(supply);
>                         if (!result)
> --
> 1.7.9.5
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-12  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-12  5:05 [PATCH v2] mmc: core: Remove fixed voltage regulator logic Tim Kryger
2014-08-12  8:49 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox