#ifdef CONFIG_PM_RUNTIME
+/*
+ * MFLD SD card insert/remove handler
+ * When removing a SD card, there may be still requests
+ * transferring. But removing a SD card can cause MFLD
+ * host controller reset its power register automatically
+ * which causes host cannot generate interrupts for the
+ * current transferring requests. That will trigger timeout
+ * timer.
+ * So before start to detect a card, finish the current
+ * request first.
+ */
static irqreturn_t mfd_sd_cd(int irq, void *dev_id)
{
struct sdhci_pci_slot *slot = dev_id;
struct sdhci_host *host = slot->host;
- mmc_detect_change(host->mmc, msecs_to_jiffies(200));
+ if (host->card_tasklet.func == NULL)
+ return IRQ_NONE;
+
+ tasklet_schedule(&host->card_tasklet);
+
return IRQ_HANDLED;
}
else
present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
SDHCI_CARD_PRESENT;
+ /*
+ * If user insert/remove card too quickly, host may send
+ * command before host power up. That is bad, which can
+ * lead host generate no interrupts.
+ * So before sending command, check power control register
+ */
+ if (!(sdhci_readb(host, SDHCI_POWER_CONTROL) & SDHCI_POWER_ON))
+ present = false;
if (!present || host->flags & SDHCI_DEVICE_DEAD) {
host->mrq->cmd->error = -ENOMEDIUM;