Commit 35f6782055c99410fbeae33ab28ea68de154360c
Committed by
Jaehoon Chung
1 parent
fb7c3beb51
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
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>
Showing 3 changed files with 18 additions and 7 deletions Side-by-side Diff
drivers/mmc/fsl_esdhc.c
... | ... | @@ -665,7 +665,7 @@ |
665 | 665 | #endif |
666 | 666 | |
667 | 667 | /* Set the initial clock speed */ |
668 | - mmc_set_clock(mmc, 400000); | |
668 | + mmc_set_clock(mmc, 400000, false); | |
669 | 669 | |
670 | 670 | /* Disable the BRR and BWR bits in IRQSTAT */ |
671 | 671 | esdhc_clrbits32(®s->irqstaten, IRQSTATEN_BRR | IRQSTATEN_BWR); |
drivers/mmc/mmc.c
... | ... | @@ -1214,7 +1214,7 @@ |
1214 | 1214 | } |
1215 | 1215 | #endif |
1216 | 1216 | |
1217 | -int mmc_set_clock(struct mmc *mmc, uint clock) | |
1217 | +int mmc_set_clock(struct mmc *mmc, uint clock, bool disable) | |
1218 | 1218 | { |
1219 | 1219 | if (clock > mmc->cfg->f_max) |
1220 | 1220 | clock = mmc->cfg->f_max; |
... | ... | @@ -1223,6 +1223,7 @@ |
1223 | 1223 | clock = mmc->cfg->f_min; |
1224 | 1224 | |
1225 | 1225 | mmc->clock = clock; |
1226 | + mmc->clk_disable = disable; | |
1226 | 1227 | |
1227 | 1228 | return mmc_set_ios(mmc); |
1228 | 1229 | } |
... | ... | @@ -1322,7 +1323,7 @@ |
1322 | 1323 | |
1323 | 1324 | /* configure the bus mode (host) */ |
1324 | 1325 | mmc_select_mode(mmc, mwt->mode); |
1325 | - mmc_set_clock(mmc, mmc->tran_speed); | |
1326 | + mmc_set_clock(mmc, mmc->tran_speed, false); | |
1326 | 1327 | |
1327 | 1328 | err = sd_read_ssr(mmc); |
1328 | 1329 | if (!err) |
... | ... | @@ -1333,7 +1334,7 @@ |
1333 | 1334 | error: |
1334 | 1335 | /* revert to a safer bus speed */ |
1335 | 1336 | mmc_select_mode(mmc, SD_LEGACY); |
1336 | - mmc_set_clock(mmc, mmc->tran_speed); | |
1337 | + mmc_set_clock(mmc, mmc->tran_speed, false); | |
1337 | 1338 | } |
1338 | 1339 | } |
1339 | 1340 | } |
... | ... | @@ -1476,7 +1477,7 @@ |
1476 | 1477 | |
1477 | 1478 | /* configure the bus mode (host) */ |
1478 | 1479 | mmc_select_mode(mmc, mwt->mode); |
1479 | - mmc_set_clock(mmc, mmc->tran_speed); | |
1480 | + mmc_set_clock(mmc, mmc->tran_speed, false); | |
1480 | 1481 | |
1481 | 1482 | /* do a transfer to check the configuration */ |
1482 | 1483 | err = mmc_read_and_compare_ext_csd(mmc); |
... | ... | @@ -1950,7 +1951,7 @@ |
1950 | 1951 | |
1951 | 1952 | mmc_select_mode(mmc, MMC_LEGACY); |
1952 | 1953 | mmc_set_bus_width(mmc, 1); |
1953 | - mmc_set_clock(mmc, 0); | |
1954 | + mmc_set_clock(mmc, 0, false); | |
1954 | 1955 | } |
1955 | 1956 | |
1956 | 1957 | static int mmc_power_on(struct mmc *mmc) |
include/mmc.h
... | ... | @@ -472,6 +472,7 @@ |
472 | 472 | void *priv; |
473 | 473 | uint has_init; |
474 | 474 | int high_capacity; |
475 | + bool clk_disable; /* true if the clock can be turned off */ | |
475 | 476 | uint bus_width; |
476 | 477 | uint clock; |
477 | 478 | enum mmc_voltage signal_voltage; |
... | ... | @@ -567,7 +568,16 @@ |
567 | 568 | int mmc_initialize(bd_t *bis); |
568 | 569 | int mmc_init(struct mmc *mmc); |
569 | 570 | int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); |
570 | -int mmc_set_clock(struct mmc *mmc, uint clock); | |
571 | + | |
572 | +/** | |
573 | + * mmc_set_clock() - change the bus clock | |
574 | + * @mmc: MMC struct | |
575 | + * @clock: bus frequency in Hz | |
576 | + * @disable: flag indicating if the clock must on or off | |
577 | + * @return 0 if OK, -ve on error | |
578 | + */ | |
579 | +int mmc_set_clock(struct mmc *mmc, uint clock, bool disable); | |
580 | + | |
571 | 581 | struct mmc *find_mmc_device(int dev_num); |
572 | 582 | int mmc_set_dev(int dev_num); |
573 | 583 | void print_mmc_devices(char separator); |