]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mmc: sdhci_am654: Add sdhci_am654_start_signal_voltage_switch
authorJudith Mendez <jm@ti.com>
Fri, 13 Sep 2024 18:54:03 +0000 (13:54 -0500)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 14 Oct 2024 10:29:00 +0000 (12:29 +0200)
The sdhci_start_signal_voltage_switch function sets
V1P8_SIGNAL_ENA by default after switching to 1v8 signaling.
V1P8_SIGNAL_ENA determines whether to launch cmd/data on neg
edge or pos edge of clock.

Due to some eMMC and SD failures seen across am62x platform,
do not set V1P8_SIGNAL_ENA by default, only enable the bit
for devices that require this bit in order to switch to 1v8
voltage for uhs modes.

Signed-off-by: Judith Mendez <jm@ti.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20240913185403.1339115-1-jm@ti.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci_am654.c

index 0aa3c40ea6ed8e39c802cdc1528248b2b57ce6dd..9ff07aadb2d911260bcb0e206f4dbd2b3be17ac7 100644 (file)
@@ -155,6 +155,7 @@ struct sdhci_am654_data {
        u32 tuning_loop;
 
 #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
+#define SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA BIT(1)
 };
 
 struct window {
@@ -356,6 +357,29 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
        sdhci_set_clock(host, clock);
 }
 
+static int sdhci_am654_start_signal_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+       struct sdhci_host *host = mmc_priv(mmc);
+       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+       struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
+       int ret;
+
+       if ((sdhci_am654->quirks & SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA) &&
+           ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) {
+               if (!IS_ERR(mmc->supply.vqmmc)) {
+                       ret = mmc_regulator_set_vqmmc(mmc, ios);
+                       if (ret < 0) {
+                               pr_err("%s: Switching to 1.8V signalling voltage failed,\n",
+                                      mmc_hostname(mmc));
+                               return -EIO;
+                       }
+               }
+               return 0;
+       }
+
+       return sdhci_start_signal_voltage_switch(mmc, ios);
+}
+
 static u8 sdhci_am654_write_power_on(struct sdhci_host *host, u8 val, int reg)
 {
        writeb(val, host->ioaddr + reg);
@@ -844,6 +868,11 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
        if (device_property_read_bool(dev, "ti,fails-without-test-cd"))
                sdhci_am654->quirks |= SDHCI_AM654_QUIRK_FORCE_CDTEST;
 
+       /* Suppress v1p8 ena for eMMC and SD with vqmmc supply */
+       if (!!of_parse_phandle(dev->of_node, "vmmc-supply", 0) ==
+           !!of_parse_phandle(dev->of_node, "vqmmc-supply", 0))
+               sdhci_am654->quirks |= SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA;
+
        sdhci_get_of_property(pdev);
 
        return 0;
@@ -940,6 +969,7 @@ static int sdhci_am654_probe(struct platform_device *pdev)
                goto err_pltfm_free;
        }
 
+       host->mmc_host_ops.start_signal_voltage_switch = sdhci_am654_start_signal_voltage_switch;
        host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning;
 
        pm_runtime_get_noresume(dev);