mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] usb: i.MX chipidea: Enable VBUS regulator when needed
Date: Mon,  5 Sep 2016 08:24:27 +0200	[thread overview]
Message-ID: <1473056667-2043-1-git-send-email-s.hauer@pengutronix.de> (raw)

We should enable VBUS only in host mode, not unconditionally
during probe(). Fix that.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/imx/chipidea-imx.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
index a799abe..9857fe5 100644
--- a/drivers/usb/imx/chipidea-imx.c
+++ b/drivers/usb/imx/chipidea-imx.c
@@ -150,13 +150,23 @@ static int imx_chipidea_probe_dt(struct imx_chipidea *ci)
 
 static int ci_register_role(struct imx_chipidea *ci)
 {
+	int ret;
+
 	if (ci->role_registered)
 		return -EBUSY;
 
 	if (ci->mode == IMX_USB_MODE_HOST) {
 		if (IS_ENABLED(CONFIG_USB_EHCI)) {
 			ci->role_registered = 1;
-			return ehci_register(ci->dev, &ci->data);
+			ret = regulator_enable(ci->vbus);
+			if (ret)
+				return ret;
+
+			ret = ehci_register(ci->dev, &ci->data);
+			if (!ret)
+				return 0;
+
+			regulator_disable(ci->vbus);
 		} else {
 			dev_err(ci->dev, "Host support not available\n");
 			return -ENODEV;
@@ -242,9 +252,8 @@ static int imx_chipidea_probe(struct device_d *dev)
 	}
 
 	ci->vbus = regulator_get(dev, "vbus");
-
-	if (!IS_ERR(ci->vbus))
-		regulator_enable(ci->vbus);
+	if (IS_ERR(ci->vbus))
+		ci->vbus = NULL;
 
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
-- 
2.8.1


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

                 reply	other threads:[~2016-09-05  6:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1473056667-2043-1-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