mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: [PATCH] usb: chipidea: imx: add vbus regulator support
Date: Mon, 30 Jun 2014 09:52:26 +0200	[thread overview]
Message-ID: <1404114746-7020-1-git-send-email-s.trumtrar@pengutronix.de> (raw)

The chipidea binding describes the optional property of a regulator
for vbus named "vbus-supply".

Add support for this property to the driver so it can be used on boards
with a gpio-controlled regulator.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/usb/imx/chipidea-imx.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
index 9b6829b..84522dc 100644
--- a/drivers/usb/imx/chipidea-imx.c
+++ b/drivers/usb/imx/chipidea-imx.c
@@ -18,6 +18,7 @@
 #include <of.h>
 #include <errno.h>
 #include <driver.h>
+#include <regulator.h>
 #include <usb/usb.h>
 #include <usb/ehci.h>
 #include <usb/chipidea-imx.h>
@@ -32,6 +33,7 @@ struct imx_chipidea {
 	struct ehci_data data;
 	unsigned long flags;
 	enum imx_usb_mode mode;
+	struct regulator *reg_vbus;
 	int portno;
 	enum usb_phy_interface phymode;
 };
@@ -41,6 +43,12 @@ static int imx_chipidea_port_init(void *drvdata)
 	struct imx_chipidea *ci = drvdata;
 	int ret;
 
+	if (ci->reg_vbus) {
+		ret = regulator_enable(ci->reg_vbus);
+		if (ret < 0)
+			return ret;
+	}
+
 	if ((ci->flags & MXC_EHCI_PORTSC_MASK) == MXC_EHCI_MODE_ULPI) {
 		dev_dbg(ci->dev, "using ULPI phy\n");
 		if (IS_ENABLED(CONFIG_USB_ULPI)) {
@@ -54,8 +62,11 @@ static int imx_chipidea_port_init(void *drvdata)
 			ret = -ENODEV;
 		}
 
-		if (ret)
+		if (ret) {
+			if (ci->reg_vbus)
+				regulator_disable(ci->reg_vbus);
 			return ret;
+		}
 	}
 
 	ret = imx_usbmisc_port_init(ci->portno, ci->flags);
@@ -126,6 +137,8 @@ static int imx_chipidea_probe_dt(struct imx_chipidea *ci)
 				"disable-over-current", NULL))
 		ci->flags |= MXC_EHCI_DISABLE_OVERCURRENT;
 
+	ci->reg_vbus = regulator_get(ci->dev, "vbus");
+
 	return 0;
 }
 
-- 
2.0.0


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

             reply	other threads:[~2014-06-30  7:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-30  7:52 Steffen Trumtrar [this message]
2014-06-30  7:57 ` Sebastian Hesselbarth

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=1404114746-7020-1-git-send-email-s.trumtrar@pengutronix.de \
    --to=s.trumtrar@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