[U-Boot] [PATCH 3/4] sunxi: common VBUS detection logic in usbc

Marek Vasut marex at denx.de
Mon Mar 16 00:31:44 CET 2015


On Sunday, March 15, 2015 at 10:54:05 PM, Paul Kocialkowski wrote:
> Le dimanche 15 mars 2015 à 19:19 +0100, Marek Vasut a écrit :
> > On Sunday, March 15, 2015 at 06:27:46 PM, Paul Kocialkowski wrote:
> > > VBUS detection could be needed not only by the musb code (to prevent
> > > host mode), but also by e.g. gadget drivers to start only when a cable
> > > is connected.
> > > 
> > > In addition, this allows more flexibility in vbus detection, as it
> > > could easily be extended to other USBC indexes. Eventually, this would
> > > help making musb support independent from a hardcoded USB controller
> > > index (0).
> > > 
> > > Signed-off-by: Paul Kocialkowski <contact at paulk.fr>
> > 
> > Hi!
> > 
> > [...]
> > 
> > > @@ -113,6 +120,17 @@ static int get_vbus_gpio(int index)
> > > 
> > >  	return -1;
> > >  
> > >  }
> > > 
> > > +static int get_vbus_detect_gpio(int index)
> > > +{
> > > +	if (use_axp_vbus_detect(index))
> > > +		return -1;
> > > +
> > > +	switch (index) {
> > > +	case 0: return sunxi_name_to_gpio(CONFIG_USB0_VBUS_DET);
> > 
> > What happens if the index != 0 here ? Default branch with some error
> > report might be a good idea here.
> 
> Well, I'm going to have a very stupid answer here, that is: I copied
> what was already being done nearby, namely in get_vbus_gpio for this
> one. So I think that we should modify both functions accordingly.

Hi

this makes sense, but if you're planning to clean this up, please also
wait for some feedback from Hans. Also, it'd be nice if the cleanup patch
could be applied before a feature-addition patch like this one.

> I don't think it makes so much sense to print an error here because this
> will never be called directly, but instead through
> sunxi_usbc_request_resources which will make noise when it fails.

OK

> We could perhaps add some error printing in sunxi_usbc_request_resources
> to make it clear what failed, but I'm not really for it.

Well if it spits in some sensible way somewhere, that'd be OK. If it doesn't,
subsequent patch which fixes this would make sense.

btw. you might want to return proper values from errno.h here instead of -1.

[...]

Thanks!


More information about the U-Boot mailing list