Commit aff5d3c83fb8c294b3c4b97c5b6386306b47f1a0
Committed by
Jaehoon Chung
1 parent
2a4d212f71
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
mmc: Enable signal voltage to be selected from mmc core
Add a new function *mmc_set_signal_voltage* in mmc core which can be used during mmc initialization to select the signal voltage. Platform driver should use the set_ios callback function to select the signal voltage. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Showing 2 changed files with 24 additions and 0 deletions Side-by-side Diff
drivers/mmc/mmc.c
... | ... | @@ -30,6 +30,8 @@ |
30 | 30 | SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512, |
31 | 31 | }; |
32 | 32 | |
33 | +static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage); | |
34 | + | |
33 | 35 | #if CONFIG_IS_ENABLED(MMC_TINY) |
34 | 36 | static struct mmc mmc_static; |
35 | 37 | struct mmc *find_mmc_device(int dev_num) |
... | ... | @@ -1257,6 +1259,12 @@ |
1257 | 1259 | uint widths; |
1258 | 1260 | }; |
1259 | 1261 | |
1262 | +static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage) | |
1263 | +{ | |
1264 | + mmc->signal_voltage = signal_voltage; | |
1265 | + return mmc_set_ios(mmc); | |
1266 | +} | |
1267 | + | |
1260 | 1268 | static const struct mode_width_tuning sd_modes_by_pref[] = { |
1261 | 1269 | { |
1262 | 1270 | .mode = SD_HS, |
... | ... | @@ -1964,6 +1972,14 @@ |
1964 | 1972 | return err; |
1965 | 1973 | #endif |
1966 | 1974 | mmc->ddr_mode = 0; |
1975 | + | |
1976 | + /* First try to set 3.3V. If it fails set to 1.8V */ | |
1977 | + err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_330); | |
1978 | + if (err != 0) | |
1979 | + err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_180); | |
1980 | + if (err != 0) | |
1981 | + printf("failed to set signal voltage\n"); | |
1982 | + | |
1967 | 1983 | mmc_set_bus_width(mmc, 1); |
1968 | 1984 | mmc_set_clock(mmc, 1); |
1969 | 1985 |
include/mmc.h
... | ... | @@ -272,6 +272,13 @@ |
272 | 272 | #define ENHNCD_SUPPORT (0x2) |
273 | 273 | #define PART_ENH_ATTRIB (0x1f) |
274 | 274 | |
275 | +enum mmc_voltage { | |
276 | + MMC_SIGNAL_VOLTAGE_000 = 0, | |
277 | + MMC_SIGNAL_VOLTAGE_120, | |
278 | + MMC_SIGNAL_VOLTAGE_180, | |
279 | + MMC_SIGNAL_VOLTAGE_330 | |
280 | +}; | |
281 | + | |
275 | 282 | /* Maximum block size for MMC */ |
276 | 283 | #define MMC_MAX_BLOCK_LEN 512 |
277 | 284 | |
... | ... | @@ -457,6 +464,7 @@ |
457 | 464 | int high_capacity; |
458 | 465 | uint bus_width; |
459 | 466 | uint clock; |
467 | + enum mmc_voltage signal_voltage; | |
460 | 468 | uint card_caps; |
461 | 469 | uint ocr; |
462 | 470 | uint dsr; |