Let me report the results I got until now about this subject.
I rebuilt the wmt_battery.ko (from Angus' kernel:
https://github.com/projectgus/kernel_wm8505), after adding a few
printk messages, to try to understand "a bit" what's happening in
there.
Current wmt_battery.c code logic in wm85xx_read_status() is:
static int charg_stat = 1;
static int charg_gpio = 0;
...
charging=gpio_in_get(charg_gpio);
chargstatus=gpio_in_get(charg_status);
...
if(batt_gpiostate & BIT0){
if(charging & BIT0){
status = POWER_SUPPLY_STATUS_CHARGING;
printk("wmt-battery - 1 charging...\n");
}
else{
status = POWER_SUPPLY_STATUS_DISCHARGING;
printk("wmt-battery - 1 battery...\n");
}
}
else{
if(!(charging & BIT0)){
status = POWER_SUPPLY_STATUS_CHARGING;
printk("wmt-battery - 2 charging...\n ");
}
else{
status = POWER_SUPPLY_STATUS_DISCHARGING;
printk("wmt-battery - 2 battery...\n");
}
}
if(batt_gpiostate & BIT1){
if(status == POWER_SUPPLY_STATUS_CHARGING)
if(chargstatus & BIT1){
status = POWER_SUPPLY_STATUS_FULL;
printk("wmt-battery - 3 charge full....\n");
}
}
else{
if(status == POWER_SUPPLY_STATUS_CHARGING)
if(!(chargstatus & BIT1)){
status = POWER_SUPPLY_STATUS_FULL;
printk("wmt-battery - 4 charge full...\n");
}
}
return status;
- - - - -
Testing the GPIO bits under different conditions gave:
C=value of "charging"
S=value of "chargstatus"
C S Status
----------------------------------------------------------
1 2 1 - Boot. Battery is FULL (after one night charging, charging
red led if off) and external power is plugged.
0 2 2 - Unplugged power
1 0 3 - Power plugged again (after about 10-15 minutes; red led
lit)
1 2 4 - Unplugged (this one above is the same combination of Plugged
and Full)
1 0 5 - Plugged once again (after about more 10-15 minutes; red led
lit)
1 2 6 - Unplugged (after about 30 minutes, but while still charging,
before the led turned off)
1 0 7 - Plugged again (red led on)
1 2 8 - Still plugged but now charge is full (after about 15 more
minutes; red led off)
1 2 9 - Unplugged (mmhh - it's not that reliable.... nothing
changed!)
1 0 10 - After full discharge (autoshutdown), reboot and plugged
again
1 2 11 - Unplugged (just a few minutes chargic passed)
1 0 12 - Plugged once again
C & S are expected to tell if it's plugged/on-battery and full/not-
full, respectively.
S (bit 2) looks like sensing correctly for full charge (or plugged-in
power), while for C I got a "0" only once in this test cycle, I'm not
even sure why... It may well be that the wrong GPIO is being used in
this code for C.