From: Markus Pargmann <mpa@pengutronix.de>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] usb: chipidea: Add DT vbus-supply parsing
Date: Mon, 28 Jul 2014 22:54:31 +0200 [thread overview]
Message-ID: <20140728205431.GB13842@pengutronix.de> (raw)
In-Reply-To: <53D6B685.9000806@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 2599 bytes --]
On Mon, Jul 28, 2014 at 10:45:57PM +0200, Sebastian Hesselbarth wrote:
> On 07/28/2014 10:23 PM, Markus Pargmann wrote:
> > 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 | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
> > index 9b6829b8f59f..a4cf4a1a5f3d 100644
> > --- a/drivers/usb/imx/chipidea-imx.c
> > +++ b/drivers/usb/imx/chipidea-imx.c
> > @@ -15,6 +15,7 @@
> > #include <common.h>
> > #include <init.h>
> > #include <io.h>
> > +#include <linux/err.h>
> > #include <of.h>
> > #include <errno.h>
> > #include <driver.h>
> > @@ -23,6 +24,7 @@
> > #include <usb/chipidea-imx.h>
> > #include <usb/ulpi.h>
> > #include <usb/fsl_usb2.h>
> > +#include <regulator.h>
> >
> > #define MXC_EHCI_PORTSC_MASK ((0xf << 28) | (1 << 25))
> >
> > @@ -187,6 +189,16 @@ static int imx_chipidea_probe(struct device_d *dev)
> > ret = -ENODEV;
> > }
> >
> > + if (ci->mode == IMX_USB_MODE_HOST) {
> > + struct regulator *vbus = regulator_get(dev, "vbus");
> > + if (!IS_ERR(vbus)) {
> > + regulator_enable(vbus);
> > + } else {
> > + dev_err(dev, "Failed to get vbus regulator %ld\n", PTR_ERR(vbus));
> > + ret = PTR_ERR(vbus);
> > + }
>
> regulator_get should return a NULL pointer if there is no regulator for
> "vbus". The NULL regulator is a valid (dummy) regulator that can be used
> as if there was a real one.
>
> That basically means, you should check for an error and always use
> regulator_enable otherwise:
>
> struct regulator *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);
> }
>
> regulator_enable(vbus);
Thanks, will change that.
>
> But even more important: You should also check for a regulator on
> peripheral/otg mode. That's the cases where you can actually break
> things when you don't disable the regulator.
Oh right, I didn't thought about that. I will change the code so that it
is either enabled or disabled, depending on the mode.
Thanks,
Markus
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2014-07-28 20:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 20:23 Markus Pargmann
2014-07-28 20:23 ` [PATCH 2/2] usb: imx-usb-misc: Use reasonable defaults to setup the ports Markus Pargmann
2014-07-28 20:45 ` [PATCH 1/2] usb: chipidea: Add DT vbus-supply parsing Sebastian Hesselbarth
2014-07-28 20:54 ` Markus Pargmann [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=20140728205431.GB13842@pengutronix.de \
--to=mpa@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=sebastian.hesselbarth@gmail.com \
/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