mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] mci: Add regulator support
Date: Mon, 28 Apr 2014 10:18:41 +0200	[thread overview]
Message-ID: <1398673121-6075-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1398673121-6075-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c | 18 ++++++++++++++++--
 include/mci.h          |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 1dca0c0..282d239 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;
diff --git a/include/mci.h b/include/mci.h
index cd3e2c2..f2c6fd1 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -28,6 +28,7 @@
 
 #include <linux/list.h>
 #include <block.h>
+#include <regulator.h>
 
 /* Firmware revisions for SD cards */
 #define SD_VERSION_SD		0x20000
@@ -301,6 +302,7 @@ struct mci_host {
 	unsigned max_req_size;
 	unsigned dsr_val;	/**< optional dsr value */
 	int use_dsr;		/**< optional dsr usage flag */
+	struct regulator *supply;
 
 	/** init the host interface */
 	int (*init)(struct mci_host*, struct device_d*);
-- 
1.9.1


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

      parent reply	other threads:[~2014-04-28  8:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28  8:18 [PATCH] initial " Sascha Hauer
2014-04-28  8:18 ` [PATCH 1/2] Add " Sascha Hauer
2014-04-28 16:30   ` Alexander Aring
2014-04-28 16:41     ` Alexander Aring
2014-04-28 18:47     ` Sascha Hauer
2014-04-28 18:51       ` Alexander Aring
2014-04-28 20:00         ` Sascha Hauer
2014-04-28 20:08           ` Alexander Aring
2014-04-28  8:18 ` Sascha Hauer [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=1398673121-6075-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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