mmc: core: Drop HS400 caps unless 8-bit bus is supported too
authorUlf Hansson <ulf.hansson@linaro.org>
Thu, 3 Mar 2022 16:51:51 +0000 (17:51 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 15 Mar 2022 09:25:21 +0000 (10:25 +0100)
When mmc_select_hs400es() tries to switch to the HS400 ES mode, it may bail
out early if the host doesn't support an 8-bit buswidth, as it's required
for the HS400 mode.

To improve the situation, let's instead drop the HS400 bits from the
capability field if the 8-bit bus isn't supported. In this way, we allow
the mmc initialization to continue by trying a lower speed mode.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20220303165151.129806-1-ulf.hansson@linaro.org
drivers/mmc/core/host.c
drivers/mmc/core/mmc.c

index d739e2b631fe8ee12b15600653b921c1667a8002..2ed2b4d5e5a5be588e2007e12a72070f56c57d25 100644 (file)
@@ -590,11 +590,20 @@ EXPORT_SYMBOL(mmc_alloc_host);
 
 static int mmc_validate_host_caps(struct mmc_host *host)
 {
-       if (host->caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) {
-               dev_warn(host->parent, "missing ->enable_sdio_irq() ops\n");
+       struct device *dev = host->parent;
+       u32 caps = host->caps, caps2 = host->caps2;
+
+       if (caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) {
+               dev_warn(dev, "missing ->enable_sdio_irq() ops\n");
                return -EINVAL;
        }
 
+       if (caps2 & (MMC_CAP2_HS400_ES | MMC_CAP2_HS400) &&
+           !(caps & MMC_CAP_8_BIT_DATA)) {
+               dev_warn(dev, "drop HS400 support since no 8-bit bus\n");
+               host->caps2 = caps2 & ~MMC_CAP2_HS400_ES & ~MMC_CAP2_HS400;
+       }
+
        return 0;
 }
 
index 3f5d0d7c021ca7d99ec4c59538f9c1fb17bb20cc..e7ea45386c22f7e1880a521a281397893a3a6612 100644 (file)
@@ -1355,11 +1355,6 @@ static int mmc_select_hs400es(struct mmc_card *card)
        int err = -EINVAL;
        u8 val;
 
-       if (!(host->caps & MMC_CAP_8_BIT_DATA)) {
-               err = -ENOTSUPP;
-               goto out_err;
-       }
-
        if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_2V)
                err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120);