mmc: mtk-sd: Take action for no-sdio device-tree parameter
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Thu, 16 Dec 2021 12:57:46 +0000 (13:57 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 28 Dec 2021 16:21:14 +0000 (17:21 +0100)
This driver was unconditionally enabling support for SDIO mode,
but we do have a generic "no-sdio" DT parameter that sets caps2
MMC_CAP2_NO_SDIO.

Modify the HW initialization sequence to enable SDIO support only
if it hasn't been explicitly disabled in device-tree.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20211216125748.179602-3-angelogioacchino.delregno@collabora.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/mtk-sd.c

index d067636434caaf73d6d1900c7fb9b54bd0e01d3d..f08695e52601e82378edd2c53ecb73158ad3957b 100644 (file)
@@ -1638,6 +1638,7 @@ static void msdc_init_hw(struct msdc_host *host)
 {
        u32 val;
        u32 tune_reg = host->dev_comp->pad_tune_reg;
+       struct mmc_host *mmc = mmc_from_priv(host);
 
        if (host->reset) {
                reset_control_assert(host->reset);
@@ -1743,14 +1744,18 @@ static void msdc_init_hw(struct msdc_host *host)
                                     MSDC_PAD_TUNE_RXDLYSEL);
        }
 
-       /* Configure to enable SDIO mode.
-        * it's must otherwise sdio cmd5 failed
-        */
-       sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO);
+       if (mmc->caps2 & MMC_CAP2_NO_SDIO) {
+               sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIO);
+               sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
+               sdr_clr_bits(host->base + SDC_ADV_CFG0, SDC_DAT1_IRQ_TRIGGER);
+       } else {
+               /* Configure to enable SDIO mode, otherwise SDIO CMD5 fails */
+               sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO);
 
-       /* Config SDIO device detect interrupt function */
-       sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
-       sdr_set_bits(host->base + SDC_ADV_CFG0, SDC_DAT1_IRQ_TRIGGER);
+               /* Config SDIO device detect interrupt function */
+               sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
+               sdr_set_bits(host->base + SDC_ADV_CFG0, SDC_DAT1_IRQ_TRIGGER);
+       }
 
        /* Configure to default data timeout */
        sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, 3);