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

Ohad Ben-Cohen ohad at wizery.com
Mon Jul 5 20:37:36 EDT 2010


From: Ohad Ben-Cohen <ohadb at ti.com>

Add support for software emulation of card detect
events.

This is required for specific controllers
that are hard wired with embedded SDIO devices
(such as TI's wl1271 WLAN device).

Board-specific configuration is required to
enable this software card detect control.

Based on Android's EMBEDDED SDIO patch by
San Mehat <san at android.com>.

Signed-off-by: Ohad Ben-Cohen <ohadb at ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

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);
 
-- 
1.7.0.4




More information about the linux-arm-kernel mailing list