]> git.sur5r.net Git - u-boot/commitdiff
mmc: Enable signal voltage to be selected from mmc core
authorKishon Vijay Abraham I <kishon@ti.com>
Thu, 21 Sep 2017 14:30:00 +0000 (16:30 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Fri, 12 Jan 2018 09:11:04 +0000 (18:11 +0900)
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>
drivers/mmc/mmc.c
include/mmc.h

index 588cfb2b2e3147cc16ce877ec8db20f6eedf9096..24b5e16a3bfe0ecf7aaa3c29220316aaaacc5963 100644 (file)
@@ -30,6 +30,8 @@ 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);
+
 #if CONFIG_IS_ENABLED(MMC_TINY)
 static struct mmc mmc_static;
 struct mmc *find_mmc_device(int dev_num)
@@ -1257,6 +1259,12 @@ struct mode_width_tuning {
        uint widths;
 };
 
+static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage)
+{
+       mmc->signal_voltage = signal_voltage;
+       return mmc_set_ios(mmc);
+}
+
 static const struct mode_width_tuning sd_modes_by_pref[] = {
        {
                .mode = SD_HS,
@@ -1964,6 +1972,14 @@ int mmc_start_init(struct mmc *mmc)
                return err;
 #endif
        mmc->ddr_mode = 0;
+
+       /* 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);
 
index 3e57887af0196f1c41e92181a1c9ed40ef718c48..e5249637c85143ac79392a5a0d74f1c72465fe92 100644 (file)
 #define ENHNCD_SUPPORT         (0x2)
 #define PART_ENH_ATTRIB                (0x1f)
 
+enum mmc_voltage {
+       MMC_SIGNAL_VOLTAGE_000 = 0,
+       MMC_SIGNAL_VOLTAGE_120,
+       MMC_SIGNAL_VOLTAGE_180,
+       MMC_SIGNAL_VOLTAGE_330
+};
+
 /* Maximum block size for MMC */
 #define MMC_MAX_BLOCK_LEN      512
 
@@ -457,6 +464,7 @@ struct mmc {
        int high_capacity;
        uint bus_width;
        uint clock;
+       enum mmc_voltage signal_voltage;
        uint card_caps;
        uint ocr;
        uint dsr;