On 05/13/2017 03:16 AM, Jean-Jacques Hiblot wrote:
> mmc/sd specification requires vdd to be disabled for 1 ms
> and then enabled again during power cycle. Add a
> function in mmc core to perform power cycle and set
> the io signal to it's initial state.
> 
> Signed-off-by: Kishon Vijay Abraham I <kis...@ti.com>
> Signed-off-by: Jean-Jacques Hiblot <jjhib...@ti.com>
> ---
>  drivers/mmc/mmc.c | 50 +++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 41 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index d40a22b..032260b 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -30,6 +30,7 @@ static const unsigned int sd_au_size[] = {
>       SZ_16M / 512,   (SZ_16M + SZ_8M) / 512, SZ_32M / 512,   SZ_64M / 512,
>  };
>  static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage);
> +static void mmc_power_cycle(struct mmc *mmc);
>  
>  #if CONFIG_IS_ENABLED(MMC_TINY)
>  static struct mmc mmc_static;
> @@ -1915,6 +1916,45 @@ static int mmc_power_init(struct mmc *mmc)
>       return 0;
>  }
>  
> +static void mmc_set_initial_state(struct mmc *mmc)
> +{
> +     int err;
> +
> +     /* First try to set 3.3V. If it fails set to 1.8V */
> +     err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_330);
> +     if (err != 0)
> +             err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_180);
> +     if (err != 0)
> +             printf("failed to set signal voltage\n");
> +
> +     mmc_set_bus_width(mmc, 1);
> +     mmc_set_clock(mmc, 1);
> +     mmc_select_mode(mmc, MMC_LEGACY);
> +}
> +
> +static void mmc_power_up(struct mmc *mmc)
> +{
> +     mmc_set_initial_state(mmc);
> +     mmc_set_vdd(mmc, true);

mmc_set_vdd has the return value..but there are no usage anywhere..
if this is correct, mmc_set_vdd can be *void* type.

> +     udelay(10000);
> +}
> +
> +static void mmc_power_off(struct mmc *mmc)
> +{
> +     mmc_set_vdd(mmc, false);
> +}
> +
> +static void mmc_power_cycle(struct mmc *mmc)
> +{
> +     mmc_power_off(mmc);
> +     /*
> +      * SD spec recommends at least 1ms of delay. Let's wait for 2ms
> +      * to be on the safer side.
> +      */

Could you put the SD spec version and about which part...?
I didn't find the 2ms so..i want to see the spec about 2ms.

> +     udelay(2000);
> +     mmc_power_up(mmc);
> +}
> +
>  int mmc_start_init(struct mmc *mmc)
>  {
>       bool no_card;
> @@ -1952,16 +1992,8 @@ int mmc_start_init(struct mmc *mmc)
>               return err;
>  #endif
>       mmc->ddr_mode = 0;
> -     mmc_set_vdd(mmc, true);
> -     /* First try to set 3.3V. If it fails set to 1.8V */
> -     err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_330);
> -     if (err != 0)
> -             err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_180);
> -     if (err != 0)
> -             printf("failed to set signal voltage\n");
>  
> -     mmc_set_bus_width(mmc, 1);
> -     mmc_set_clock(mmc, 1);
> +     mmc_power_cycle(mmc);
>  
>       /* Reset the Card */
>       err = mmc_go_idle(mmc);
> 

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to