power: qpnp-charger: fix vbatdet-lo irq storm

An interrupt storm on vbatdet-lo interrupt was observed when the battery
voltage was close to the resume voltage, charging was enabled and fast
charge hadn't yet begun. This causes the vbatdet lo to trigger over and
over since the driver does not disable it.

If the realtime status of the vbatdet-lo reads 0 that means the battery
voltage is lower than vbatdet threshold else 1 otherwise.

The falling edge of vbatdet-lo is used to resume charging once end of
charge (EOC) happens. Remove the usage of falling edge of the vbatdet-lo,
instead enable charging right after EOC happens and since battery voltage
will be higher than vbatdet it won't start charging. When the time comes to
resume charging, either because of SOC or battery voltage falling below
vbatdet threshold, the charger hardware will automatically resume
charging.

Use only the rising edge of the interrupt to wakeup for starting the
EOC worker but immediately disable the interrupt once EOC worker is
scheduled. Also update the EOC worker to enable the rising edge only
when it has confirmed that the voltage is low thrice in a row.

Also take this opportunity to fix a minor issue when charging is
enabled. The forcing of batfet should be disabled before enabling
charging.

Change-Id: I5d8f594de9dfe0ae3ee7ea1f4bf11b5795f8bf4f
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
1 file changed