]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00182054: [MX6]: always_present flag will't work as designed at some cond
authorRyan QIAN <b32804@freescale.com>
Mon, 7 May 2012 05:54:04 +0000 (13:54 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:34:34 +0000 (08:34 +0200)
As designed, when 'always_present' is set, it is assumed that cd_gpio should
be not set, and gpio_get_value(boarddata->cd_gpio) should return 0. But it is
not sure that the return value of gpio_get_value(0) is 0.

- check always_present first
- remove ESDHC_FLAG_GPIO_FOR_CD_WP flag if always_present is set.

Signed-off-by: Ryan QIAN <b32804@freescale.com>
drivers/mmc/host/sdhci-esdhc-imx.c

index 9d7fadabeb7f92339ef35b35a2e8528932125c8f..c2d416dd30af24da81fd34c9ff789fdc301697ca 100644 (file)
@@ -108,6 +108,8 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
 {
        struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
        struct pltfm_imx_data *imx_data = pltfm_host->priv;
+       struct esdhc_platform_data *boarddata
+                               = host->mmc->parent->platform_data;
 
        /* fake CARD_PRESENT flag on mx25/35 */
        u32 val = readl(host->ioaddr + reg);
@@ -127,18 +129,18 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
                val |= (fsl_prss & 0x00800000) << 1;
        }
 
-       if (unlikely((reg == SDHCI_PRESENT_STATE)
-                       && (imx_data->flags & ESDHC_FLAG_GPIO_FOR_CD_WP))) {
-               struct esdhc_platform_data *boarddata =
-                               host->mmc->parent->platform_data;
-
-               if (boarddata && gpio_is_valid(boarddata->cd_gpio)
-                               && gpio_get_value(boarddata->cd_gpio))
-                       /* no card, if a valid gpio says so... */
-                       val &= ~SDHCI_CARD_PRESENT;
-               else
-                       /* ... in all other cases assume card is present */
+       if (unlikely(reg == SDHCI_PRESENT_STATE)) {
+               if (boarddata && boarddata->always_present)
                        val |= SDHCI_CARD_PRESENT;
+               else if (imx_data->flags & ESDHC_FLAG_GPIO_FOR_CD_WP) {
+                       if (boarddata && gpio_is_valid(boarddata->cd_gpio)
+                                       && gpio_get_value(boarddata->cd_gpio))
+                               /* no card, if a valid gpio says so */
+                               val &= ~SDHCI_CARD_PRESENT;
+                       else
+                               /* in all other cases assume card is present */
+                               val |= SDHCI_CARD_PRESENT;
+               }
        }
 
        if (reg == SDHCI_INT_STATUS && cpu_is_mx6()
@@ -749,7 +751,7 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd
        if (boarddata) {
                /* Device is always present, e.x, populated emmc device */
                if (boarddata->always_present) {
-                       imx_data->flags |= ESDHC_FLAG_GPIO_FOR_CD_WP;
+                       /* remove BROKEN_CD to disable card polling */
                        host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
                        if (host->clk_mgr_en)
                                clk_disable(pltfm_host->clk);