public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] mmc: atmel-mci: add vmmc-supply support
@ 2013-10-16 22:19 Alexandre Belloni
  2013-10-17  8:34 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2013-10-16 22:19 UTC (permalink / raw)
  To: Ludovic Desroches; +Cc: Chris Ball, linux-mmc, linux-kernel, Alexandre Belloni

Other MMC hosts handle a regulator named vmmc-supply that allows to power the
MMC card or SDIO device before communicating on the bus.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---

Changes in v2:
 - use mmc_regulator_get_supply instead of devm_regulator_get

 drivers/mmc/host/atmel-mci.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 69e438e..4ea5333 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 #include <linux/scatterlist.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
@@ -2198,6 +2199,14 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	host->slot[id] = slot;
 	mmc_add_host(mmc);
 
+	mmc_regulator_get_supply(mmc);
+	if (!IS_ERR(mmc->supply.vmmc)) {
+		int ret = regulator_enable(mmc->supply.vmmc);
+		if (ret)
+			dev_err(&mmc->class_dev,
+				"failed to enable regulator: %d\n", ret);
+	}
+
 	if (gpio_is_valid(slot->detect_pin)) {
 		int ret;
 
-- 
1.8.1.2


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

* Re: [PATCHv2] mmc: atmel-mci: add vmmc-supply support
  2013-10-16 22:19 [PATCHv2] mmc: atmel-mci: add vmmc-supply support Alexandre Belloni
@ 2013-10-17  8:34 ` Ulf Hansson
  2013-10-17  8:59   ` Alexandre Belloni
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2013-10-17  8:34 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Ludovic Desroches, Chris Ball, linux-mmc,
	linux-kernel@vger.kernel.org

On 17 October 2013 00:19, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> Other MMC hosts handle a regulator named vmmc-supply that allows to power the
> MMC card or SDIO device before communicating on the bus.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>
> Changes in v2:
>  - use mmc_regulator_get_supply instead of devm_regulator_get
>
>  drivers/mmc/host/atmel-mci.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 69e438e..4ea5333 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -23,6 +23,7 @@
>  #include <linux/of_device.h>
>  #include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
> +#include <linux/regulator/consumer.h>
>  #include <linux/scatterlist.h>
>  #include <linux/seq_file.h>
>  #include <linux/slab.h>
> @@ -2198,6 +2199,14 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>         host->slot[id] = slot;
>         mmc_add_host(mmc);
>
> +       mmc_regulator_get_supply(mmc);
> +       if (!IS_ERR(mmc->supply.vmmc)) {
> +               int ret = regulator_enable(mmc->supply.vmmc);

You should not enable the regulator here, instead handle that from the
.set_ios function. This complete code chunk must also be moved prior
to mmc_add_host above.

When enabling/disabling the regulator from the .set_ios, I suppose you
want to use mmc_regulator_set_ocr API instead.

Kind regards
Ulf Hansson

> +               if (ret)
> +                       dev_err(&mmc->class_dev,
> +                               "failed to enable regulator: %d\n", ret);
> +       }
> +
>         if (gpio_is_valid(slot->detect_pin)) {
>                 int ret;
>
> --
> 1.8.1.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCHv2] mmc: atmel-mci: add vmmc-supply support
  2013-10-17  8:34 ` Ulf Hansson
@ 2013-10-17  8:59   ` Alexandre Belloni
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2013-10-17  8:59 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Ludovic Desroches, Chris Ball, linux-mmc,
	linux-kernel@vger.kernel.org

On 17/10/2013 10:34, Ulf Hansson wrote:
> On 17 October 2013 00:19, Alexandre Belloni
> <alexandre.belloni@free-electrons.com> wrote:
>> Other MMC hosts handle a regulator named vmmc-supply that allows to power the
>> MMC card or SDIO device before communicating on the bus.
>>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>> ---
>>
>> Changes in v2:
>>  - use mmc_regulator_get_supply instead of devm_regulator_get
>>
>>  drivers/mmc/host/atmel-mci.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
>> index 69e438e..4ea5333 100644
>> --- a/drivers/mmc/host/atmel-mci.c
>> +++ b/drivers/mmc/host/atmel-mci.c
>> @@ -23,6 +23,7 @@
>>  #include <linux/of_device.h>
>>  #include <linux/of_gpio.h>
>>  #include <linux/platform_device.h>
>> +#include <linux/regulator/consumer.h>
>>  #include <linux/scatterlist.h>
>>  #include <linux/seq_file.h>
>>  #include <linux/slab.h>
>> @@ -2198,6 +2199,14 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>>         host->slot[id] = slot;
>>         mmc_add_host(mmc);
>>
>> +       mmc_regulator_get_supply(mmc);
>> +       if (!IS_ERR(mmc->supply.vmmc)) {
>> +               int ret = regulator_enable(mmc->supply.vmmc);
> You should not enable the regulator here, instead handle that from the
> .set_ios function. This complete code chunk must also be moved prior
> to mmc_add_host above.

Right, I was wondering about that. I actually had a version where it was
before mmc_add_host
>
> When enabling/disabling the regulator from the .set_ios, I suppose you
> want to use mmc_regulator_set_ocr API instead.

Oh right, I pretty new to the mmc subsystem and I was probably to tired
to find that one yesterday. I actually looked for regulator_enable in
mmc/core/core.c and didn't see it ...

Thank you for your prompt reviews.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


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

end of thread, other threads:[~2013-10-17  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-16 22:19 [PATCHv2] mmc: atmel-mci: add vmmc-supply support Alexandre Belloni
2013-10-17  8:34 ` Ulf Hansson
2013-10-17  8:59   ` Alexandre Belloni

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