[U-Boot] [PATCH] sunxi: axp221: Use vbus-available rather then vbus-usable for vbus-detect

Paul Kocialkowski contact at paulk.fr
Mon Mar 23 23:44:22 CET 2015


Le lundi 23 mars 2015 à 17:38 +0100, Hans de Goede a écrit :
> Hi,
> 
> On 23-03-15 17:33, Paul Kocialkowski wrote:
> > Le lundi 23 mars 2015 à 17:28 +0100, Hans de Goede a écrit :
> >> vbus-usable does not get set if power is provided through the power barrel
> >> connector, even if external 5v is also present on the otg connector.
> >>
> >> vbus-available correctly always reflects if there is 5v present on the otg
> >> connector.
> >
> > You (or I) could submit the very same change for the AXP209. It's the
> > same bit for available (1 << 5).
> 
> Yes I was about to mail you about that when I noticed that this seems to
> break actual host mode support on the otg connector, it seems that
> plugging in a micro-b to usb-a receptacle (aka host) convertor + a device
> plugged into the usb-a receptacle also causes bit 5 to get set :|

Actually, as soon as host mode is enabled on the musb controller (even
without a device), vbus is set to 1 and the present bit (5) from the
axp209 gets set (tested with both an OTG and a non-OTG micro-b to usb-a
adapter). However, it only happens *after* starting the musb controller
(with or without a device in), so since detection is done prior to that,
it should still work to use available bit (5) to detect external cables,
at least for our use case.

Are you experiencing the same thing, or does having AC plugged-in change
that?

> So my patch is no good, but powering the otg port while external 5v is present
> also is not good (one side effect is that the tablet will power up immediately
> after sending a power-off command to the axp221).

Of course, the port shouldn't be set in host mode when a cable that
provides VBUS is attached, we should avoid this.

> If you've some time to tinker with this I would appreciate any ideas
> you may have (assuming the same problem exists on the axp209)
> simply plug in 5v power into the power barrel, as well as 5v power
> (e.g. simply from your pc) and boot up the tablet, at least in my
> case then it does not properly give the charger plugged in error.

The (axp209-enabled and axp209-vbus-detection-enabled) tablet I have
around this week doesn't have a power barrel (the Ainol AW1), but I get
the problem in theory.

If I understood correctly the AXP209 datasheet (and according to
Chen-Yu's email), setting REG30H[7] to 1 will force the AXP to charge
the battery from USB when AC is in. It is unclear whether it will simply
ignore the power barrel or somewhat use both to charge the battery.

That would enable us to keep using the usable bit (4) for detection in
every case.

Since I cannot test this week (until next week-end), I'll leave it up to
you (or anyone else) to do the actual testing.

> Regards,
> 
> Hans
> 
> 
> 
> >
> >> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> >> ---
> >>   drivers/power/axp221.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c
> >> index f758a75..dc3a7f1 100644
> >> --- a/drivers/power/axp221.c
> >> +++ b/drivers/power/axp221.c
> >> @@ -424,7 +424,7 @@ int axp_gpio_get_value(unsigned int pin)
> >>   		if (ret)
> >>   			return ret;
> >>
> >> -		return !!(val & AXP221_POWER_STATUS_VBUS_USABLE);
> >> +		return !!(val & AXP221_POWER_STATUS_VBUS_AVAIL);
> >>   	default:
> >>   		return -EINVAL;
> >>   	}
> >

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150323/38c8aedb/attachment.sig>


More information about the U-Boot mailing list