diff mbox

[05/15] omap: hsmmc: add virtual card detect support

Message ID 1278376666-3509-6-git-send-email-ohad@wizery.com (mailing list archive)
State Awaiting Upstream, archived
Headers show

Commit Message

Ohad Ben Cohen July 6, 2010, 12:37 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index b032828..60694df 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1208,6 +1208,38 @@  static void omap_hsmmc_detect(struct work_struct *work)
 		mmc_detect_change(host->mmc, (HZ * 50) / 1000);
 }
 
+#ifdef CONFIG_MMC_EMBEDDED_SDIO
+static void omap_hsmmc_set_embedded_data(void *dev_id, void *priv)
+{
+	struct omap_hsmmc_host *host = dev_id;
+	struct mmc_host *mmc = host->mmc;
+
+	mmc_set_embedded_data(mmc, priv);
+}
+
+static void omap_hsmmc_virtual_detect(void *dev_id, int carddetect)
+{
+	struct omap_hsmmc_host *host = dev_id;
+
+	printk(KERN_DEBUG "%s: card detect %d\n", mmc_hostname(host->mmc),
+							carddetect);
+
+	sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
+
+	if (carddetect)
+		mmc_detect_change(host->mmc, (HZ * 200) / 1000);
+	else
+		mmc_detect_change(host->mmc, (HZ * 50) / 1000);
+}
+#else
+static void omap_hsmmc_set_embedded_data(void *dev_id, void *priv)
+{
+}
+static void omap_hsmmc_virtual_detect(void *dev_id, int carddetect)
+{
+}
+#endif
+
 /*
  * ISR for handling card insertion and removal
  */
@@ -2170,7 +2202,10 @@  static int __init omap_hsmmc_probe(struct platform_device *pdev)
 				"Unable to grab MMC CD IRQ\n");
 			goto err_irq_cd;
 		}
-	}
+	} else if (mmc_slot(host).register_embedded_control)
+		mmc_slot(host).register_embedded_control(host,
+					omap_hsmmc_virtual_detect,
+					omap_hsmmc_set_embedded_data);
 
 	omap_hsmmc_disable_irq(host);