mmc: slot-gpio: Add a function to enable/disable card detect IRQ wakeup
[linux-2.6-microblaze.git] / drivers / mmc / core / slot-gpio.c
index 3698b05..dccbc52 100644 (file)
@@ -154,6 +154,27 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host)
 }
 EXPORT_SYMBOL(mmc_gpiod_request_cd_irq);
 
+int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on)
+{
+       int ret = 0;
+
+       if (!(host->caps & MMC_CAP_CD_WAKE) ||
+           host->slot.cd_irq < 0 ||
+           on == host->slot.cd_wake_enabled)
+               return 0;
+
+       if (on) {
+               ret = enable_irq_wake(host->slot.cd_irq);
+               host->slot.cd_wake_enabled = !ret;
+       } else {
+               disable_irq_wake(host->slot.cd_irq);
+               host->slot.cd_wake_enabled = false;
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL(mmc_gpio_set_cd_wake);
+
 /* Register an alternate interrupt service routine for
  * the card-detect GPIO.
  */