summaryrefslogtreecommitdiffstats
path: root/drivers/mci/atmel_mci.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2013-01-25 16:17:47 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-01-25 19:52:44 +0100
commit2c93912f34ce06585c4ede0298aef7225e096df2 (patch)
tree4a5e58ad2ccc63417f516f8eccb75a58d6c7abaf /drivers/mci/atmel_mci.c
parent50559d2c4cf5fbc4d1b7307b975b23ebab4601d6 (diff)
downloadbarebox-2c93912f34ce06585c4ede0298aef7225e096df2.tar.gz
barebox-2c93912f34ce06585c4ede0298aef7225e096df2.tar.xz
atmel_mci: gpio: request and configure card detect
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/atmel_mci.c')
-rw-r--r--drivers/mci/atmel_mci.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c
index 647683b9d9..9de079d31d 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 = {