]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/mmc/host/tmio_mmc_pio.c
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[mirror_ubuntu-artful-kernel.git] / drivers / mmc / host / tmio_mmc_pio.c
index b11b088775a8af01972236728b5e94b9453f07a4..6b789a739d4dfeb598a1fced82130ee05f1e4dc6 100644 (file)
@@ -134,12 +134,21 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
        struct tmio_mmc_host *host = mmc_priv(mmc);
 
        if (enable && !host->sdio_irq_enabled) {
+               u16 sdio_status;
+
                /* Keep device active while SDIO irq is enabled */
                pm_runtime_get_sync(mmc_dev(mmc));
-               host->sdio_irq_enabled = true;
 
+               host->sdio_irq_enabled = true;
                host->sdio_irq_mask = TMIO_SDIO_MASK_ALL &
                                        ~TMIO_SDIO_STAT_IOIRQ;
+
+               /* Clear obsolete interrupts before enabling */
+               sdio_status = sd_ctrl_read16(host, CTL_SDIO_STATUS) & ~TMIO_SDIO_MASK_ALL;
+               if (host->pdata->flags & TMIO_MMC_SDIO_STATUS_SETBITS)
+                       sdio_status |= TMIO_SDIO_SETBITS_MASK;
+               sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status);
+
                sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
        } else if (!enable && host->sdio_irq_enabled) {
                host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
@@ -709,9 +718,8 @@ static bool __tmio_mmc_sdcard_irq(struct tmio_mmc_host *host,
        return false;
 }
 
-static void tmio_mmc_sdio_irq(int irq, void *devid)
+static void __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
 {
-       struct tmio_mmc_host *host = devid;
        struct mmc_host *mmc = host->mmc;
        struct tmio_mmc_data *pdata = host->pdata;
        unsigned int ireg, status;
@@ -724,8 +732,8 @@ static void tmio_mmc_sdio_irq(int irq, void *devid)
        ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdio_irq_mask;
 
        sdio_status = status & ~TMIO_SDIO_MASK_ALL;
-       if (pdata->flags & TMIO_MMC_SDIO_STATUS_QUIRK)
-               sdio_status |= 6;
+       if (pdata->flags & TMIO_MMC_SDIO_STATUS_SETBITS)
+               sdio_status |= TMIO_SDIO_SETBITS_MASK;
 
        sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status);
 
@@ -752,7 +760,7 @@ irqreturn_t tmio_mmc_irq(int irq, void *devid)
        if (__tmio_mmc_sdcard_irq(host, ireg, status))
                return IRQ_HANDLED;
 
-       tmio_mmc_sdio_irq(irq, devid);
+       __tmio_mmc_sdio_irq(host);
 
        return IRQ_HANDLED;
 }
@@ -900,6 +908,12 @@ static int tmio_mmc_clk_enable(struct tmio_mmc_host *host)
        return host->clk_enable(host);
 }
 
+static void tmio_mmc_clk_disable(struct tmio_mmc_host *host)
+{
+       if (host->clk_disable)
+               host->clk_disable(host);
+}
+
 static void tmio_mmc_power_on(struct tmio_mmc_host *host, unsigned short vdd)
 {
        struct mmc_host *mmc = host->mmc;
@@ -1175,8 +1189,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 
        _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
                                  mmc->caps & MMC_CAP_NEEDS_POLL ||
-                                 !mmc_card_is_removable(mmc) ||
-                                 mmc->slot.cd_irq >= 0);
+                                 !mmc_card_is_removable(mmc));
 
        /*
         * On Gen2+, eMMC with NONREMOVABLE currently fails because native
@@ -1285,6 +1298,8 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
+
+       tmio_mmc_clk_disable(host);
 }
 EXPORT_SYMBOL(tmio_mmc_host_remove);
 
@@ -1299,8 +1314,7 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)
        if (host->clk_cache)
                tmio_mmc_clk_stop(host);
 
-       if (host->clk_disable)
-               host->clk_disable(host);
+       tmio_mmc_clk_disable(host);
 
        return 0;
 }