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

Andreas Kemnade andreas at kemnade.info
Sat Oct 12 10:39:21 CEST 2013


Hi,

On Fri, 2013-09-27 at 12:42 +0200, Dr. H. Nikolaus Schaller wrote:

> >> 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...
> 
Well, it has an even more hidden state. If it is set to linear charging,
that setting stays also after reboots into different kernels without the
linear charging mode patch... That is very hidden.

> 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.
>
The code could be clearer there and reading that lin file should return
"on", "off" or "auto".

> > 
> > 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.
> 
Hmm, the question is about the software control for that. Do you think
such a patch should be for charging in special situations, or as an
alternative for the ordinary automatic charging?
If the latter one is used, then the question is which safety features we
need (and want to do that in kernel space), there is for example a
watchdog in the charger requiring some actions taken regularly. If we
use that, we would need to wake up very often from suspend (if we have
even the chance to go into suspend).

Greetings
Andreas Kemnade



More information about the Gta04-owner mailing list