From: Grazvydas Ignotas Date: Thu, 4 Aug 2011 22:37:22 +0000 (+0300) Subject: pndevmapperd: add unexpected charge stop workaround X-Git-Tag: sz_beta3~40 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c7db6d5e5c0634ae85713fc27fd3bef2ee96827;p=pandora-libraries.git pndevmapperd: add unexpected charge stop workaround My machine in some real rare cases (once a week or so) just stops charging without any good reason. What helps here is replugging the charger or writing to a chip charge register, so we do the later indirectly every 20 minutes as a workaround. There have been similar reports in the forums, where user leaves the machine charging overnight and finds flat battery in the morning, so hopefully this will help them too. --- diff --git a/apps/pndevmapperd.c b/apps/pndevmapperd.c index b5301f1..3f860ed 100644 --- a/apps/pndevmapperd.c +++ b/apps/pndevmapperd.c @@ -869,7 +869,7 @@ void sigalrm_handler ( int n ) { pnd_log ( pndn_debug, "---[ SIGALRM ]---\n" ); - static time_t last_charge_check; + static time_t last_charge_check, last_charge_worka; int batlevel = pnd_device_get_battery_gauge_perc(); int uamps = 0; time_t now; @@ -935,6 +935,16 @@ void sigalrm_handler ( int n ) { pnd_log ( pndn_debug, "Charge start conditions reached, enabling charging\n" ); pnd_device_set_charger_enable ( bc_charge_device, 1 ); } + + // for some unknown reason it just stops charging randomly (happens once per week or so), + // and does not restart, resulting in a flat battery if machine is unattended. + // What seems to help here is writing to chip registers, we can do it here indirectly + // by writing to enable. Doing it occasionally should do no harm even with missing charger. + if ( batlevel <= bc_startcap && (unsigned int)(now - last_charge_worka) > 20*60 ) { + pnd_log ( pndn_debug, "Charge workaround trigger\n" ); + pnd_device_set_charger_enable ( bc_charge_device, 1 ); + last_charge_worka = now; + } } last_charge_check = now; }