diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-01-18 12:52:29 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-01-20 10:53:30 +0100 |
commit | 456fae022798fd9142a0ac255890e1622463e10c (patch) | |
tree | 0d611961275b0b0cc1c45456e5cb0d2884af2193 /drivers/mci/atmel_mci.c | |
parent | d21575ddea8ca4e319814e06f7d19a027e2fd970 (diff) | |
download | barebox-456fae022798fd9142a0ac255890e1622463e10c.tar.gz barebox-456fae022798fd9142a0ac255890e1622463e10c.tar.xz |
mci atmel: implement card_present callback
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/atmel_mci.c')
-rw-r--r-- | drivers/mci/atmel_mci.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/mci/atmel_mci.c b/drivers/mci/atmel_mci.c index 4065355be5..222cd4a5fa 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; |