[Gta04-owner] Sporadic USB charging issue identified
neilb at suse.de
Sun Feb 17 22:22:29 CET 2013
On Sun, 17 Feb 2013 20:44:14 +0100 "Dr. H. Nikolaus Schaller"
<hns at goldelico.com> wrote:
> I have found a sporadic charging issue on at least one GTA04 which may be
> kernel/driver/PMU-initialisazion related.
> The symptom is that the device starts to charge, suddenly stops and does
> not continue to charge - although still connected to USB and VBUS being 5V.
> After a while the battery is getting empty, although the device is still connected
> to USB and switches off. The battery is even deeply discharged to 2.6V (because
> VBUS is available and apparently overrides power off at 3.2V).
> >From my tests it appears that the USB charger driver monitors VBUS and
> resigns to charge if VBUS drops below ca. 4.3V - even for a short moment.
> It only restarts if you plug off the USB cable, i.e. lowering VBUS to 0V and
> rising it again.
> Momentary VUSB variations may happen mechanically by a loose or weak
> contact of the USB plug or cable. Or if the GTA04 suddenly draws a little more
> current (e.g. switching on backlight and WLAN) leading to a small voltage drop.
> If this drop is relevant may depend on component variations, and even the
> length of the USB cable. So it is only recognized on some GTA04 units.
> I think there is no simple threshold like "charge if VBUS > 4.2V",
> but a hysteresis: stop charging for VBUS < 4.2V and start charging
> of VBUS rises from below 1V to >1V or similar.
> In other words: VBUS must be interrupted for at least 0.5 seconds or so.
> Shorter interruptions can disturb the charger function.
> That the charger is resigning to charge if VBUS is not above some minimum
> is basically ok. But that it never restarts charging is not robust enough.
> I think (but I have not tested completely) that this effect occurs on all
> kernels we have (2.6.32 and all 3.x).
> Part of the symptom is that the BTEMP ADC of the twl4030 hardware
> monitor reports bad values (somehow proportional to the VUSB instead
> of being constant) while reading VBUS, the battery voltage or current is ok.
> But this might be simply a side-effect of a disabled charger.
> My question now:
> does anyone know how and where this hysteresis is implemented?
> is it in the TPS hardware?
> or programmable through registers?
> or is it part of the twl4030 USB charger driver?
My guess would be that it is a subtle interplay between the TPS hardware and
the twl4030 charger driver.
When the USB voltage drops below 4.4V, the TPS hardware turns off charging.
When a cable is plugged in, an interrupt triggers some sort of notification
from the USB driver to the CHARGER driver which turns on charging.
In your case, the hardware notices the voltage drop, but there is no "cable
plugged in" event.
To delve further I would enable the
dev_dbg(bci->dev, "BCI irq %02x %02x\n", irqs2, irqs1);
line in twl4030_bci_interrupt() in twl4030_charger.c
If you have dynamic debugging turned on you can do this with something like
echo file twl4030_charger.c function twl4030_bci_interrupt +p \
(I probably have the syntax a bit wrong - there is a file in Documentation/)
Then see if any BCI interrupts happen at the key time.
You might need to look for usb interrupts as well which would be
twl4030_usb_irq() in drivers/usb/otg/twl4030-usb.c. This currently calls do_notify()
which calls through a notifier chain to the charger module.
You possibly need to get twl4030_charger_enable_usb(bci, true) to run after
the voltage has stablised again. Alternately it could be that the USB PHY is
being powered down (twl4030_phy_suspend) and not powered up again
I think it is very likely that there is a race somewhere in the software
responding to hardware changes. Once you can identify exactly the sequence
of operations seen by the software it shouldn't be too hard to find a way to
close the race.
> PS: after preparing (but not yet sending) this mail I was able to reproduce
> the effect on a "sane" GTA04: just unplug the USB connector very shortly
> (<0.5 seconds), i.e. pull it almost out but not completely and replug immediately.
> Then check for VBUS, VBAT and charger status etc.
> Gta04-owner mailing list
> Gta04-owner at goldelico.com
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 828 bytes
Desc: not available
More information about the Gta04-owner