[PATCH] usb: i.MX: improve regulator handling
Marco Felsch
m.felsch at pengutronix.de
Tue Oct 20 10:58:44 EDT 2020
On 20-10-20 16:28, Marco Felsch wrote:
> On 20-10-20 16:09, Sascha Hauer wrote:
> > On Tue, Oct 20, 2020 at 03:33:17PM +0200, Marco Felsch wrote:
> > > Hi Uwe,
> > >
> > > On 20-10-20 13:15, Uwe Kleine-König wrote:
> > > > Instead of just ignoring errors related to regulator getting error out.
> > > > In case there is no regulator in the device tree, regulator_get() returns
> > > > the dummy regulator and not an error code, so the change is right for
> > > > this situation, too.
> > > >
> > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> > > > ---
> > > > drivers/usb/imx/chipidea-imx.c | 7 +++++--
> > > > 1 file changed, 5 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
> > > > index 786beede6d89..dd0e3c1a2a58 100644
> > > > --- a/drivers/usb/imx/chipidea-imx.c
> > > > +++ b/drivers/usb/imx/chipidea-imx.c
> > > > @@ -267,8 +267,11 @@ static int imx_chipidea_probe(struct device_d *dev)
> > > > }
> > > >
> > > > ci->vbus = regulator_get(dev, "vbus");
> > > > - if (IS_ERR(ci->vbus))
> > > > - ci->vbus = NULL;
> > > > + if (IS_ERR(ci->vbus)) {
> > > > + ret = ERR_PTR(ci->vbus);
> > > > + dev_err(dev, "Cannot get vbus regulator: %s\n", strerror(-ret));
> > > > + return ret;
> > >
> > > Returning the error here can cause problems with exisiting boards, e.g.
> > > if the regulator support is missing for the specified vbus regulator.
> > > This is often the case since we have very limited regulator support for
> > > now.
> >
> > But when there is a regulator we also have to control it, right?
>
> So you need to add each regulator driver or worst case you need to add
> PMIC drivers. If I remember correctly, I added the same for mci which
> broke a lot of boards. Later you reverted those commit. Now Oleksij
> added the regulator support for the fec driver and people are starting
> to remove the phy-supply handle from the barebox-dt's (commit 84cf5cfa9a
> ("ARM: dts: imx6qdl: pfla02: Remove fec phy-supply")). I'm not again
> this patch, just wanted to show the consequences of it.
Sorry I have to correct myself, pls check the linux driver:
static int ci_get_platdata(struct device *dev,
struct ci_hdrc_platform_data *platdata)
{
...
/* Get the vbus regulator */
platdata->reg_vbus = devm_regulator_get_optional(dev, "vbus");
if (PTR_ERR(platdata->reg_vbus) == -EPROBE_DEFER) {
return -EPROBE_DEFER;
} else if (PTR_ERR(platdata->reg_vbus) == -ENODEV) {
/* no vbus regulator is needed */
platdata->reg_vbus = NULL;
} else if (IS_ERR(platdata->reg_vbus)) {
dev_err(dev, "Getting regulator error: %ld\n",
PTR_ERR(platdata->reg_vbus));
return PTR_ERR(platdata->reg_vbus);
}
...
}
So if ENODEV is returned we can assign NULL here and the coming
deep-probe v3 address the -EPROBE_DEFER failure. So I'm not sure if this
patch is correct.
Regards,
Marco
More information about the barebox
mailing list