[U-Boot] [PATCH 15/22] mmc: add a new mmc parameter to disable mmc clock
Jean-Jacques Hiblot
jjhiblot at ti.com
Fri May 12 18:16:33 UTC 2017
mmc clock has to be disabled in certain cases like during
the voltage switch sequence. Modify mmc_set_clock function
to take disable as an argument that signifies if the
clock has to be enabled or disabled.
Signed-off-by: Kishon Vijay Abraham I <kishon at ti.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---
drivers/mmc/fsl_esdhc.c | 2 +-
drivers/mmc/mmc.c | 11 ++++++-----
include/mmc.h | 3 ++-
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index f3c6358..b631392 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -658,7 +658,7 @@ static int esdhc_init(struct mmc *mmc)
#endif
/* Set the initial clock speed */
- mmc_set_clock(mmc, 400000);
+ mmc_set_clock(mmc, 400000, false);
/* Disable the BRR and BWR bits in IRQSTAT */
esdhc_clrbits32(®s->irqstaten, IRQSTATEN_BRR | IRQSTATEN_BWR);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 032260b..70b7d19 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1216,7 +1216,7 @@ static int mmc_set_ios(struct mmc *mmc)
}
#endif
-int mmc_set_clock(struct mmc *mmc, uint clock)
+int mmc_set_clock(struct mmc *mmc, uint clock, u8 disable)
{
if (clock > mmc->cfg->f_max)
clock = mmc->cfg->f_max;
@@ -1225,6 +1225,7 @@ int mmc_set_clock(struct mmc *mmc, uint clock)
clock = mmc->cfg->f_min;
mmc->clock = clock;
+ mmc->clk_disable = disable;
return mmc_set_ios(mmc);
}
@@ -1316,7 +1317,7 @@ static int sd_select_mode_and_width(struct mmc *mmc)
/* configure the bus mode (host) */
mmc_select_mode(mmc, mwt->mode);
- mmc_set_clock(mmc, mmc->tran_speed);
+ mmc_set_clock(mmc, mmc->tran_speed, false);
err = sd_read_ssr(mmc);
if (!err)
@@ -1327,7 +1328,7 @@ static int sd_select_mode_and_width(struct mmc *mmc)
error:
/* revert to a safer bus speed */
mmc_select_mode(mmc, SD_LEGACY);
- mmc_set_clock(mmc, mmc->tran_speed);
+ mmc_set_clock(mmc, mmc->tran_speed, false);
}
}
}
@@ -1465,7 +1466,7 @@ static int mmc_select_mode_and_width(struct mmc *mmc)
/* configure the bus mode (host) */
mmc_select_mode(mmc, mwt->mode);
- mmc_set_clock(mmc, mmc->tran_speed);
+ mmc_set_clock(mmc, mmc->tran_speed, false);
/* do a transfer to check the configuration */
err = mmc_read_and_compare_ext_csd(mmc);
@@ -1928,7 +1929,7 @@ static void mmc_set_initial_state(struct mmc *mmc)
printf("failed to set signal voltage\n");
mmc_set_bus_width(mmc, 1);
- mmc_set_clock(mmc, 1);
+ mmc_set_clock(mmc, 1, false);
mmc_select_mode(mmc, MMC_LEGACY);
}
diff --git a/include/mmc.h b/include/mmc.h
index 43d37a4..097a685 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -466,6 +466,7 @@ struct mmc {
void *priv;
uint has_init;
int high_capacity;
+ u8 clk_disable;
uint bus_width;
uint clock;
uint signal_voltage;
@@ -557,7 +558,7 @@ int mmc_unbind(struct udevice *dev);
int mmc_initialize(bd_t *bis);
int mmc_init(struct mmc *mmc);
int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
-int mmc_set_clock(struct mmc *mmc, uint clock);
+int mmc_set_clock(struct mmc *mmc, uint clock, u8 disable);
struct mmc *find_mmc_device(int dev_num);
int mmc_set_dev(int dev_num);
void print_mmc_devices(char separator);
--
1.9.1
More information about the U-Boot
mailing list