mmc: add a new mmc parameter to disable mmc clock
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@ti.com> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
This commit is contained in:
parent
fb7c3beb51
commit
35f6782055
@ -665,7 +665,7 @@ static int esdhc_init_common(struct fsl_esdhc_priv *priv, struct mmc *mmc)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set the initial clock speed */
|
/* Set the initial clock speed */
|
||||||
mmc_set_clock(mmc, 400000);
|
mmc_set_clock(mmc, 400000, false);
|
||||||
|
|
||||||
/* Disable the BRR and BWR bits in IRQSTAT */
|
/* Disable the BRR and BWR bits in IRQSTAT */
|
||||||
esdhc_clrbits32(®s->irqstaten, IRQSTATEN_BRR | IRQSTATEN_BWR);
|
esdhc_clrbits32(®s->irqstaten, IRQSTATEN_BRR | IRQSTATEN_BWR);
|
||||||
|
@ -1214,7 +1214,7 @@ static int mmc_set_ios(struct mmc *mmc)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int mmc_set_clock(struct mmc *mmc, uint clock)
|
int mmc_set_clock(struct mmc *mmc, uint clock, bool disable)
|
||||||
{
|
{
|
||||||
if (clock > mmc->cfg->f_max)
|
if (clock > mmc->cfg->f_max)
|
||||||
clock = mmc->cfg->f_max;
|
clock = mmc->cfg->f_max;
|
||||||
@ -1223,6 +1223,7 @@ int mmc_set_clock(struct mmc *mmc, uint clock)
|
|||||||
clock = mmc->cfg->f_min;
|
clock = mmc->cfg->f_min;
|
||||||
|
|
||||||
mmc->clock = clock;
|
mmc->clock = clock;
|
||||||
|
mmc->clk_disable = disable;
|
||||||
|
|
||||||
return mmc_set_ios(mmc);
|
return mmc_set_ios(mmc);
|
||||||
}
|
}
|
||||||
@ -1322,7 +1323,7 @@ static int sd_select_mode_and_width(struct mmc *mmc)
|
|||||||
|
|
||||||
/* configure the bus mode (host) */
|
/* configure the bus mode (host) */
|
||||||
mmc_select_mode(mmc, mwt->mode);
|
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);
|
err = sd_read_ssr(mmc);
|
||||||
if (!err)
|
if (!err)
|
||||||
@ -1333,7 +1334,7 @@ static int sd_select_mode_and_width(struct mmc *mmc)
|
|||||||
error:
|
error:
|
||||||
/* revert to a safer bus speed */
|
/* revert to a safer bus speed */
|
||||||
mmc_select_mode(mmc, SD_LEGACY);
|
mmc_select_mode(mmc, SD_LEGACY);
|
||||||
mmc_set_clock(mmc, mmc->tran_speed);
|
mmc_set_clock(mmc, mmc->tran_speed, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1476,7 +1477,7 @@ static int mmc_select_mode_and_width(struct mmc *mmc)
|
|||||||
|
|
||||||
/* configure the bus mode (host) */
|
/* configure the bus mode (host) */
|
||||||
mmc_select_mode(mmc, mwt->mode);
|
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 */
|
/* do a transfer to check the configuration */
|
||||||
err = mmc_read_and_compare_ext_csd(mmc);
|
err = mmc_read_and_compare_ext_csd(mmc);
|
||||||
@ -1950,7 +1951,7 @@ static void mmc_set_initial_state(struct mmc *mmc)
|
|||||||
|
|
||||||
mmc_select_mode(mmc, MMC_LEGACY);
|
mmc_select_mode(mmc, MMC_LEGACY);
|
||||||
mmc_set_bus_width(mmc, 1);
|
mmc_set_bus_width(mmc, 1);
|
||||||
mmc_set_clock(mmc, 0);
|
mmc_set_clock(mmc, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mmc_power_on(struct mmc *mmc)
|
static int mmc_power_on(struct mmc *mmc)
|
||||||
|
@ -472,6 +472,7 @@ struct mmc {
|
|||||||
void *priv;
|
void *priv;
|
||||||
uint has_init;
|
uint has_init;
|
||||||
int high_capacity;
|
int high_capacity;
|
||||||
|
bool clk_disable; /* true if the clock can be turned off */
|
||||||
uint bus_width;
|
uint bus_width;
|
||||||
uint clock;
|
uint clock;
|
||||||
enum mmc_voltage signal_voltage;
|
enum mmc_voltage signal_voltage;
|
||||||
@ -567,7 +568,16 @@ int mmc_unbind(struct udevice *dev);
|
|||||||
int mmc_initialize(bd_t *bis);
|
int mmc_initialize(bd_t *bis);
|
||||||
int mmc_init(struct mmc *mmc);
|
int mmc_init(struct mmc *mmc);
|
||||||
int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
|
int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
|
||||||
int mmc_set_clock(struct mmc *mmc, uint clock);
|
|
||||||
|
/**
|
||||||
|
* mmc_set_clock() - change the bus clock
|
||||||
|
* @mmc: MMC struct
|
||||||
|
* @clock: bus frequency in Hz
|
||||||
|
* @disable: flag indicating if the clock must on or off
|
||||||
|
* @return 0 if OK, -ve on error
|
||||||
|
*/
|
||||||
|
int mmc_set_clock(struct mmc *mmc, uint clock, bool disable);
|
||||||
|
|
||||||
struct mmc *find_mmc_device(int dev_num);
|
struct mmc *find_mmc_device(int dev_num);
|
||||||
int mmc_set_dev(int dev_num);
|
int mmc_set_dev(int dev_num);
|
||||||
void print_mmc_devices(char separator);
|
void print_mmc_devices(char separator);
|
||||||
|
Loading…
Reference in New Issue
Block a user