[Gta04-owner] [PATCH] twl4030_charger: add software controlled linear charging mode.

Dr. H. Nikolaus Schaller hns at goldelico.com
Fri Sep 27 12:42:06 CEST 2013


Hi,

Am 27.09.2013 um 12:13 schrieb Andreas Kemnade:

> Hi,
> 
> On Fri, 27 Sep 2013 07:39:09 +0200
> "Dr. H. Nikolaus Schaller" <hns at goldelico.com> wrote:
> 
>> Hi Andreas,
>> 
>> Am 26.09.2013 um 20:09 schrieb Andreas Kemnade:
>> 
>>> Hi,
>>> 
>>> 
>>> On Thu, 26 Sep 2013 15:19:40 +0200
>>> "Dr. H. Nikolaus Schaller" <hns at goldelico.com> wrote:
>>> 
>>>> Hi Ben,
>>>> thanks for the patch. I have applied it and now the /sys/.../lin file is back again.
>>>> 
>>>> One question (maybe to Andreas): "on" sets the variable do_lin=1 and "auto" resets it if it was on. But "off" does not set it to 0. Is this intended behaviour?
>>>> 
>>> yes, that is intended behaviour:
>>> off= manual off (and no auto on, prevented by do_lin still =0 )
> 
> s/0/1/

Ah, ok.

> 
>> 
>> I think the code is missing something (as indicated). If you set it to "on" and then to "off" do_lin will still be =1! To reset this variableto 0 you have to set it to "on" and then to "auto". At least this is how I understand the code. So what I do not see is setting it to "off" prevents auto mode by setting do_lin = 0 if it was set before.
> 
> do_lin = 0 should not prevent auto mode therefore I leave it at 1 when lin is set to off.

Well, I just wonder because it appears to be possible to have some hidden state...

I.e.

on	=> do_lin = 1
on, auto => do_lin = 0
on, off => do_lin=1
on, off, auto => do_lin = 0
on, auto, off => do_lin = 0

So depending on history you may have different values of do_lin (and twl state) after issuing the last "off" command. This is what I wonder about, that the "off" command has some random component in what it is doing to this variable. It may be harmless to do so, but makes understanding the code a little difficult.

> 
> There are several if (do_lin) in the code which prevent the autocharging from being enabled. But if power is reapplied, software-controlled charging is enabled again (by software). 
> 
> A hint for testing: vbus is not reported during hardware testing now, so the corresponding sysfs node does not give information. That has side effects on the usb module. For my use case it is better so. 
> 
>> 
>>> auto=automatic charge mode
>>> on = manual on 
>>> 
>>> btw: it is possible to keep the gta04 in suspend mode with do_lin=on when power supply goes on and off. Tested on my bike on the very hilly and windy roads around the North Cape.
>> 
>> That is a nice story we should push more to the public! Maybe we add it to the commit message "has been tested on a bike on the very hilly and windy roads around the North Cape" :)
>> 
>> Should we try to get this patch into mainline or would you do it yourself?
>> 
> I can try to do it myself. So it seems this patch is also interesting for other people and it is not only for thoses crazy people like me who do notice that cars are already invented and want to have crazy code everywhere ;-)

If you need help to get it into 3.13 please let me know.

> 
> Maybe I should make it to Munich to go to the oshw to do some charging/usb hacking demonstrations...

Yes, that would be fine! Please vote for your preferred weekend so that chances are best that you have really a spare weekend.

BR,
Nikolaus



More information about the Gta04-owner mailing list