[Gta04-owner] various powermanagement issues

H. Nikolaus Schaller hns at goldelico.com
Mon Oct 26 08:25:46 CET 2015


Hi,

Am 25.10.2015 um 17:32 schrieb H. Nikolaus Schaller <hns at goldelico.com>:

> Hi Andreas,
> 
> Am 25.10.2015 um 14:10 schrieb Andreas Kemnade <andreas at kemnade.info>:
> 
>> On Sun, 25 Oct 2015 08:41:40 +0100
>> "H. Nikolaus Schaller" <hns at goldelico.com> wrote:
>> 
>>>>> When I find time (sigh... I assume people are still waiting for GTA04A5
>>>>> news...), I can look into the U-Boot systest approach.
>>>>> 
>>>> I managed to hang uboot with systest ch...
>>> 
>>> Yes, for me it hangs as well. So there might be another bug.
>>> 
>> PHY_DPLL clock does not come up for some reason. And systest ch waits
>> forever for it.
> 
> I have fixed the
> 
> #define BCIAUTOWEN       (TWL4030_BASEADD_PM_MASTER + 0x020)
> 
> to become
> 
> #define BCIAUTOWEN       0x020
> 
> (TWL4030_BASEADD_PM_MASTER is 0x036 so summing things up
> makes 0x056 which is a really wrong bit pattern).
> 
> and now it appears to work (PHY_DPLL fixed as well):
> 
> GTA04 # systest cha     
> USB charger detected
> Main battery charge:    3557 mV
> Battery temperature:    39 C
> Backup battery voltage: 3206 mV
> AC charger voltage:     0 mV
> USB charger voltage:    5124 mV
> Charging current:       66 mA
> GTA04 # 
> GTA04 # 
> GTA04 # 
> GTA04 # 
> GTA04 # systest cha
> USB charger detected
> Main battery charge:    4215 mV
> Battery temperature:    39 C
> Backup battery voltage: 3210 mV
> AC charger voltage:     0 mV
> USB charger voltage:    5028 mV
> Charging current:       173 mA
> GTA04 # 
> GTA04 # 
> 
> Only the charging current doesn't appear to be reasonable, but I can
> now take out the battery while connected to USB. So there is more
> than 60 mA or 173 mA available...
> 
> So I will make a patch for our letux-u-boot and provide new SD card
> images so that everyone who wants can upgrade the U-Boot in flash.
> 
> The binary of this u-boot is already here:
> 
> 	http://download.goldelico.com/letux-u-boot/GTA04/latest/
> 
> Thanks for identifying the root cause of this issue!
> 
> BR,
> Nikolaus
> 
>> Found that out by doing everything via i2c mw/md commands
>> Linear charging works with less things enabled. 
>> 
>>>> I tried to insert these lines into boot.scr
>>>> 
>>>> i2c dev 0 
>>>> i2c mw 0x4b 0x3d 0x30 1
>>>> i2c mw 0x4a 0x75 0x26 1
>>>> i2c mw 0x4a 0x95 0xf3 1
>>>> 
>>>> That starts charging for me.
>>> 
>>> Great!
>>> 
>> #enable madc
>> i2c mw 0x4a 0x00 0x01 1
>> #disable charging it bciboot 
>> i2c mw 0x4b 0x3d 0x30 1
>> #enable linear charging
>> i2c mw 0x4a 0x75 0x26 1
>> i2c mw 0x4a 0x95 0xf3 1
>> #current monitoring
>> i2c mw 0x4a 0x85 0x9c 1
>> i2c mw 0x4a 0x88 0xf0 1
>> 
>> gives a bit better behavior. Drawback is that some kernels do not
>> behave well when linear charging is enabled before bootup.
>> And I would prefer if the kernel switches back to automagic charging.
>> 
>>>> I found this line in board/goldelico/gta04/twl4030-additions.h:
>>>> #define BCIAUTOWEN       (TWL4030_BASEADD_PM_MASTER + 0x020)
>>>> 
>>>> That looks wrong for a *bit*  definition.
>>> 
>>> Indeed!
>>> 
>>> I have looked around and it appears to come from some TI / WindRiver source
>>> code from 2009 or so. E.g.
>>> 
>>> https://github.com/CMNookTablet/acclaim_cyanoboot/blob/master/include/twl4030.h
>>> 
>>> This may indeed be buggy.
>>> 
>>> In Linux it was suggested (today's code is very different) as a bit value:
>>> 
>>> https://lwn.net/Articles/364310/
>>> 
>>> #define BCIAUTOWEN		0x20
>>> 
>> The uboot stuff was an exercise to refresh my knowledge about charging
>> to be able to deal with current kernel code.
>> I have stolen i2c 0x4a and 0x4b (via echo 0x4a >unbind)from the twl4030
>> driver. Via i2cget I could find out that
>> bciiref was set to 0! I could enable charging with i2cset. And when the
>> kernel notices that theft. It became angry of course!

Some more tests have revealed another strange issue:

* if I boot MLO + U-Boot from MMC (AUX button pressed), the systest charge command now works
* if I boot X-Loader + U-Boot from NAND, the systest charge still hangs (after detecting USB cable present)

I have not identified the reason why, but it may have to do with the boot sequence.

It is (http://projects.goldelico.com/p/gta04-main/downloads/54/):

* with AUX: USB -> UART -> MMC -> NAND
* w/o AUX: NAND -> USB -> UART -> MMC

So the USB (twl4030-phy) may be differently initialized since the BootROM
stops this search as soon as it finds a boot loader. And therefore the same command
sequence in U-Boot may work or fail.

I think we should read the twl4030 registers through i2c md in both cases and compare.

BR,
Nikolaus



More information about the Gta04-owner mailing list