mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 14/14] atmel_mci: gpio: request and configure card detect
Date: Fri, 25 Jan 2013 16:17:47 +0100	[thread overview]
Message-ID: <1359127067-30079-14-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1359127067-30079-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/mci/atmel_mci.c |   27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c
index 647683b..9de079d 100644
--- a/drivers/mci/atmel_mci.c
+++ b/drivers/mci/atmel_mci.c
@@ -481,7 +481,7 @@ static void atmci_info(struct device_d *mci_dev)
 		printf("- %u Hz upper limit", host->mci.f_max);
 
 	printf("\n  Card detection support: %s\n",
-		pd->detect_pin != 0 ? "yes" : "no");
+		gpio_is_valid(pd->detect_pin) ? "yes" : "no");
 
 }
 #endif /* CONFIG_MCI_INFO */
@@ -527,12 +527,28 @@ static int atmci_probe(struct device_d *hw_dev)
 {
 	struct atmel_mci *host;
 	struct atmel_mci_platform_data *pd = hw_dev->platform_data;
+	int ret;
 
 	if (!pd) {
 		dev_err(hw_dev, "missing platform data\n");
 		return -EINVAL;
 	}
 
+	if (gpio_is_valid(pd->detect_pin)) {
+		ret = gpio_request(pd->detect_pin, "mci_cd");
+		if (ret) {
+			dev_err(hw_dev, "Impossible to request CD gpio %d (%d)\n",
+				ret, pd->detect_pin);
+			return ret;
+		}
+
+		ret = gpio_direction_input(pd->detect_pin);
+		if (ret) {
+			dev_err(hw_dev, "Impossible to configure CD gpio %d as input (%d)\n",
+				ret, pd->detect_pin);
+			goto err_gpio_cd_request;
+		}
+	}
 
 	host = xzalloc(sizeof(*host));
 	host->mci.send_cmd = atmci_request;
@@ -552,7 +568,8 @@ static int atmci_probe(struct device_d *hw_dev)
 	host->clk = clk_get(hw_dev, "mci_clk");
 	if (IS_ERR(host->clk)) {
 		dev_err(hw_dev, "no mci_clk\n");
-		return PTR_ERR(host->clk);
+		ret = PTR_ERR(host->clk);
+		goto err_gpio_cd_request;
 	}
 
 	clk_enable(host->clk);
@@ -579,6 +596,12 @@ static int atmci_probe(struct device_d *hw_dev)
 	mci_register(&host->mci);
 
 	return 0;
+
+err_gpio_cd_request:
+	if (gpio_is_valid(pd->detect_pin))
+		gpio_free(pd->detect_pin);
+
+	return ret;
 }
 
 static struct driver_d atmci_driver = {
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2013-01-25 15:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-25 15:14 [for master PATCH 00/14] atmel_mci: fixes and cleanup Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17 ` [PATCH 01/14] atmel_mci: rename atmel_mci_host tp atmel_mci Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 02/14] atmel_mci: rename atmel_mci_readl/writel to atmci_readl/writel Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 03/14] atmel_mci: rename all function to start with atmci Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 04/14] atmel_mci: use linux regs define Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 05/14] atmel_mci: detect IP version Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 06/14] atmel_mci: version 0x5xx of the IP have a different clk div Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 07/14] atmel_mci: fix host init Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 08/14] atmel_mci: rwproof is only needed since IP version 0x200 Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 17:31     ` Sascha Hauer
2013-01-25 17:35       ` Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 09/14] atmel_mci: on version 0x0 we need to reset the IP at each request Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 10/14] atmel_mci: after a software timeout the IP need to be reset Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 11/14] atmel_mci: support the SD highspeed since IP version 0x300 Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 12/14] atmel_mci: update the SD/SDIO Card Register at request time Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` [PATCH 13/14] atmel_mci: drop board host caps Jean-Christophe PLAGNIOL-VILLARD
2013-01-25 15:17   ` Jean-Christophe PLAGNIOL-VILLARD [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359127067-30079-14-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox