mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Markus Pargmann <mpa@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2 1/2] usb: chipidea: Add DT vbus-supply parsing
Date: Tue, 29 Jul 2014 11:11:04 +0200	[thread overview]
Message-ID: <1406625065-20070-1-git-send-email-mpa@pengutronix.de> (raw)

Add some code to parse and enable vbus supply when probing.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/usb/imx/chipidea-imx.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
index 9b6829b8f59f..fd3a57145f4d 100644
--- a/drivers/usb/imx/chipidea-imx.c
+++ b/drivers/usb/imx/chipidea-imx.c
@@ -15,9 +15,11 @@
 #include <common.h>
 #include <init.h>
 #include <io.h>
+#include <linux/err.h>
 #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>
@@ -136,6 +138,7 @@ static int imx_chipidea_probe(struct device_d *dev)
 	void __iomem *base;
 	struct imx_chipidea *ci;
 	uint32_t portsc;
+	struct regulator *vbus;
 
 	ci = xzalloc(sizeof(*ci));
 	ci->dev = dev;
@@ -184,9 +187,23 @@ static int imx_chipidea_probe(struct device_d *dev)
 		ret = ci_udc_register(dev, base);
 	} else {
 		dev_err(dev, "No supported role\n");
-		ret = -ENODEV;
+		return -ENODEV;
+	}
+
+	if (ret)
+		return ret;
+
+	vbus = regulator_get(dev, "vbus");
+	if (IS_ERR(vbus)) {
+		dev_err(dev, "Failed to get vbus regulator %ld\n", PTR_ERR(vbus));
+		return PTR_ERR(vbus);
 	}
 
+	if (ci->mode == IMX_USB_MODE_HOST)
+		ret = regulator_enable(vbus);
+	else
+		ret = regulator_disable(vbus);
+
 	return ret;
 };
 
-- 
2.0.1


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

             reply	other threads:[~2014-07-29  9:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-29  9:11 Markus Pargmann [this message]
2014-07-29  9:11 ` [PATCH v2 2/2] usb: imx-usb-misc: Use reasonable defaults to setup the ports Markus Pargmann

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=1406625065-20070-1-git-send-email-mpa@pengutronix.de \
    --to=mpa@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