[PATCH 5/5] mci atmel: implement card_present callback

Sascha Hauer s.hauer at pengutronix.de
Sun Jan 20 04:58:43 EST 2013


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mci/atmel_mci.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c
index 4065355..222cd4a 100644
--- a/drivers/mci/atmel_mci.c
+++ b/drivers/mci/atmel_mci.c
@@ -331,18 +331,26 @@ static int atmel_start_cmd(struct atmel_mci_host *host, struct mci_cmd *cmd,
 	return 0;
 }
 
-/** init the host interface */
-static int mci_reset(struct mci_host *mci, struct device_d *mci_dev)
+
+static int mci_card_present(struct mci_host *mci)
 {
-	int ret;
 	struct atmel_mci_host *host = to_mci_host(mci);
 	struct atmel_mci_platform_data *pd = host->hw_dev->platform_data;
+	int ret;
+
+	/* No gpio, assume card is present */
+	if (!gpio_is_valid(pd->detect_pin))
+		return 1;
 
 	ret = gpio_get_value(pd->detect_pin);
-	dev_dbg(host->hw_dev, "card %sdetected\n", ret != 0 ? "not " : "");
 
-	if (pd->detect_pin && ret == 1)
-		return -ENODEV;
+	return ret == 0 ? 1 : 0;
+}
+
+/** init the host interface */
+static int mci_reset(struct mci_host *mci, struct device_d *mci_dev)
+{
+	struct atmel_mci_host *host = to_mci_host(mci);
 
 	clk_enable(host->clk);
 	atmel_mci_reset(host);
@@ -454,6 +462,7 @@ static int mci_probe(struct device_d *hw_dev)
 	host->mci.send_cmd = mci_request;
 	host->mci.set_ios = mci_set_ios;
 	host->mci.init = mci_reset;
+	host->mci.card_present = mci_card_present;
 	host->mci.hw_dev = hw_dev;
 
 	host->mci.host_caps = pd->host_caps;
-- 
1.7.10.4




More information about the barebox mailing list