mmc: sdhci-esdhc-imx: Do not break platform data boards
[linux-drm-fsl-dcu.git] / drivers / mmc / host / sdhci-esdhc-imx.c
index 0107eb315b55b8a5395ed1de7c71e594da250821..ef290a5b34c4aef43b9b9a309dbcb110c25b12ff 100644 (file)
@@ -925,6 +925,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
        struct esdhc_platform_data *boarddata;
        int err;
        struct pltfm_imx_data *imx_data;
+       bool dt = true;
 
        host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata, 0);
        if (IS_ERR(host))
@@ -1012,11 +1013,44 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
                }
                imx_data->boarddata = *((struct esdhc_platform_data *)
                                        host->mmc->parent->platform_data);
+               dt = false;
+       }
+       /* write_protect */
+       if (boarddata->wp_type == ESDHC_WP_GPIO && !dt) {
+               err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
+               if (err) {
+                       dev_err(mmc_dev(host->mmc),
+                               "failed to request write-protect gpio!\n");
+                       goto disable_clk;
+               }
+               host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
        }
 
        /* card_detect */
-       if (boarddata->cd_type == ESDHC_CD_CONTROLLER)
+       switch (boarddata->cd_type) {
+       case ESDHC_CD_GPIO:
+               if (dt)
+                       break;
+               err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
+               if (err) {
+                       dev_err(mmc_dev(host->mmc),
+                               "failed to request card-detect gpio!\n");
+                       goto disable_clk;
+               }
+               /* fall through */
+
+       case ESDHC_CD_CONTROLLER:
+               /* we have a working card_detect back */
                host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+               break;
+
+       case ESDHC_CD_PERMANENT:
+               host->mmc->caps |= MMC_CAP_NONREMOVABLE;
+               break;
+
+       case ESDHC_CD_NONE:
+               break;
+       }
 
        switch (boarddata->max_bus_width) {
        case 8: