summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-04-08 15:29:33 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-04-29 08:01:35 +0200
commitacb427e2d0b9250859729420e93e4b77dfd43593 (patch)
tree185fa9ac95958cd8927da6d85dc33011462b9ba5 /drivers
parent485788954c1c4be5f64be143228fc54ec41c00f0 (diff)
downloadbarebox-acb427e2d0b9250859729420e93e4b77dfd43593.tar.gz
barebox-acb427e2d0b9250859729420e93e4b77dfd43593.tar.xz
mci: Add regulator support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mci/mci-core.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 1dca0c0137..282d2399f7 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1570,18 +1570,25 @@ static const char *mci_boot_names[] = {
static int mci_card_probe(struct mci *mci)
{
struct mci_host *host = mci->host;
- int i, rc, disknum;
+ int i, rc, disknum, ret;
if (host->card_present && !host->card_present(host)) {
dev_err(&mci->dev, "no card inserted\n");
return -ENODEV;
}
+ ret = regulator_enable(host->supply);
+ if (ret) {
+ dev_err(&mci->dev, "failed to enable regulator: %s\n",
+ strerror(-ret));
+ return ret;
+ }
+
/* start with a host interface reset */
rc = (host->init)(host, &mci->dev);
if (rc) {
dev_err(&mci->dev, "Cannot reset the SD/MMC interface\n");
- return rc;
+ goto on_error;
}
mci_set_bus_width(mci, MMC_BUS_WIDTH_1);
@@ -1665,6 +1672,7 @@ on_error:
if (rc != 0) {
host->clock = 0; /* disable the MCI clock */
mci_set_ios(mci);
+ regulator_disable(host->supply);
}
return rc;
@@ -1750,6 +1758,12 @@ int mci_register(struct mci_host *host)
host->mci = mci;
mci->dev.detect = mci_detect;
+ host->supply = regulator_get(host->hw_dev, "vmmc");
+ if (IS_ERR(host->supply)) {
+ ret = PTR_ERR(host->supply);
+ goto err_free;
+ }
+
ret = register_device(&mci->dev);
if (ret)
goto err_free;