diff mbox series

[U-Boot,4/4] dw_mmc: turn on the IO supply

Message ID 20190322191436.6268-5-urjaman@gmail.com
State Superseded
Delegated to: Philipp Tomsich
Headers show
Series Veyron Speedy / ASUS C201 fixes | expand

Commit Message

Urja Rannikko March 22, 2019, 7:14 p.m. UTC
Fixes the microSD slot on the ASUS C201.

Signed-off-by: Urja Rannikko <urjaman@gmail.com>
---
 drivers/mmc/dw_mmc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Heiko Stuebner March 29, 2019, 2:09 p.m. UTC | #1
Am Freitag, 22. März 2019, 20:14:36 CET schrieb Urja Rannikko:
> Fixes the microSD slot on the ASUS C201.
> 
> Signed-off-by: Urja Rannikko <urjaman@gmail.com>
> ---
>  drivers/mmc/dw_mmc.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
> index 93a836eac3..e1960b213a 100644
> --- a/drivers/mmc/dw_mmc.c
> +++ b/drivers/mmc/dw_mmc.c
> @@ -13,6 +13,7 @@
>  #include <mmc.h>
>  #include <dwmmc.h>
>  #include <wait_bit.h>
> +#include <power/regulator.h>
>  
>  #define PAGE_SIZE 4096
>  
> @@ -440,6 +441,7 @@ static int dwmci_set_ios(struct mmc *mmc)
>  #endif
>  	struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
>  	u32 ctype, regs;
> +	int ret;
>  
>  	debug("Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock);
>  
> @@ -469,6 +471,19 @@ static int dwmci_set_ios(struct mmc *mmc)
>  	if (host->clksel)
>  		host->clksel(host);
>  
> +#ifdef CONFIG_DM_REGULATOR

this should be 
	#if CONFIG_IS_ENABLED(DM_REGULATOR)

because otherwise an SPL-build using the mmc driver may fail with

drivers/mmc/dw_mmc.c: In function ‘dwmci_set_ios’:
drivers/mmc/dw_mmc.c:475:9: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
  if (mmc->vqmmc_supply) {
         ^~
drivers/mmc/dw_mmc.c:477:27: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
    regulator_set_value(mmc->vqmmc_supply, 1800000);
                           ^~
drivers/mmc/dw_mmc.c:479:27: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
    regulator_set_value(mmc->vqmmc_supply, 3300000);
                           ^~
drivers/mmc/dw_mmc.c:481:44: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
   ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);


> +	if (mmc->vqmmc_supply) {
> +		if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
> +			regulator_set_value(mmc->vqmmc_supply, 1800000);
> +		else
> +			regulator_set_value(mmc->vqmmc_supply, 3300000);
> +
> +		ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);
> +		if (ret)
> +			return ret;
> +	}
> +#endif
> +
>  	return 0;
>  }
>  
>
Urja Rannikko March 31, 2019, 7:45 p.m. UTC | #2
Hi,

On Fri, Mar 29, 2019 at 2:09 PM Heiko Stübner <heiko@sntech.de> wrote:
> > +#ifdef CONFIG_DM_REGULATOR
>
> this should be
>         #if CONFIG_IS_ENABLED(DM_REGULATOR)

Ok, just FYI that fragment was based on the one in tmio-common.c,
so maybe that should also be fixed(?).

>
> because otherwise an SPL-build using the mmc driver may fail with
>
> drivers/mmc/dw_mmc.c: In function ‘dwmci_set_ios’:
> drivers/mmc/dw_mmc.c:475:9: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
>   if (mmc->vqmmc_supply) {
>          ^~
> drivers/mmc/dw_mmc.c:477:27: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
>     regulator_set_value(mmc->vqmmc_supply, 1800000);
>                            ^~
> drivers/mmc/dw_mmc.c:479:27: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
>     regulator_set_value(mmc->vqmmc_supply, 3300000);
>                            ^~
> drivers/mmc/dw_mmc.c:481:44: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
>    ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);
>
>
> > +     if (mmc->vqmmc_supply) {
> > +             if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
> > +                     regulator_set_value(mmc->vqmmc_supply, 1800000);
> > +             else
> > +                     regulator_set_value(mmc->vqmmc_supply, 3300000);
> > +
> > +             ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);
> > +             if (ret)
> > +                     return ret;
> > +     }
> > +#endif
> > +
> >       return 0;
> >  }
> >
Heiko Stuebner April 2, 2019, 8:25 a.m. UTC | #3
Am Sonntag, 31. März 2019, 21:45:15 CEST schrieb Urja Rannikko:
> Hi,
> 
> On Fri, Mar 29, 2019 at 2:09 PM Heiko Stübner <heiko@sntech.de> wrote:
> > > +#ifdef CONFIG_DM_REGULATOR
> >
> > this should be
> >         #if CONFIG_IS_ENABLED(DM_REGULATOR)
> 
> Ok, just FYI that fragment was based on the one in tmio-common.c,
> so maybe that should also be fixed(?).

yep, looks like it. While it doesn't cause compile errors right now,
it might after all create runtime errors otherwise.


Heiko


> >
> > because otherwise an SPL-build using the mmc driver may fail with
> >
> > drivers/mmc/dw_mmc.c: In function ‘dwmci_set_ios’:
> > drivers/mmc/dw_mmc.c:475:9: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
> >   if (mmc->vqmmc_supply) {
> >          ^~
> > drivers/mmc/dw_mmc.c:477:27: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
> >     regulator_set_value(mmc->vqmmc_supply, 1800000);
> >                            ^~
> > drivers/mmc/dw_mmc.c:479:27: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
> >     regulator_set_value(mmc->vqmmc_supply, 3300000);
> >                            ^~
> > drivers/mmc/dw_mmc.c:481:44: error: ‘struct mmc’ has no member named ‘vqmmc_supply’
> >    ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);
> >
> >
> > > +     if (mmc->vqmmc_supply) {
> > > +             if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
> > > +                     regulator_set_value(mmc->vqmmc_supply, 1800000);
> > > +             else
> > > +                     regulator_set_value(mmc->vqmmc_supply, 3300000);
> > > +
> > > +             ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);
> > > +             if (ret)
> > > +                     return ret;
> > > +     }
> > > +#endif
> > > +
> > >       return 0;
> > >  }
> > >
> 
>
diff mbox series

Patch

diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index 93a836eac3..e1960b213a 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -13,6 +13,7 @@ 
 #include <mmc.h>
 #include <dwmmc.h>
 #include <wait_bit.h>
+#include <power/regulator.h>
 
 #define PAGE_SIZE 4096
 
@@ -440,6 +441,7 @@  static int dwmci_set_ios(struct mmc *mmc)
 #endif
 	struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
 	u32 ctype, regs;
+	int ret;
 
 	debug("Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock);
 
@@ -469,6 +471,19 @@  static int dwmci_set_ios(struct mmc *mmc)
 	if (host->clksel)
 		host->clksel(host);
 
+#ifdef CONFIG_DM_REGULATOR
+	if (mmc->vqmmc_supply) {
+		if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
+			regulator_set_value(mmc->vqmmc_supply, 1800000);
+		else
+			regulator_set_value(mmc->vqmmc_supply, 3300000);
+
+		ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);
+		if (ret)
+			return ret;
+	}
+#endif
+
 	return 0;
 }