]> asedeno.scripts.mit.edu Git - linux.git/commit
power: supply: bq24190_charger: Don't read fault register outside irq_handle_thread()
authorLiam Breck <liam@networkimprov.net>
Wed, 18 Jan 2017 17:26:53 +0000 (09:26 -0800)
committerSebastian Reichel <sre@kernel.org>
Fri, 20 Jan 2017 11:43:07 +0000 (12:43 +0100)
commit68abfb8015832ddf728b911769659468efaf8bd9
tree154221d5c40c34333cd27b417f759dfec387ecd5
parent2d9fee6a42ea170e4378b3363a7ad385d0e67281
power: supply: bq24190_charger: Don't read fault register outside irq_handle_thread()

Caching the fault register after a single I2C read may not keep an accurate
value.

Fix by doing two reads in irq_handle_thread() and using the cached value
elsewhere. If a safety timer fault later clears itself, we apparently don't get
an interrupt (INT), however other interrupts would refresh the register cache.

From the data sheet: "When a fault occurs, the charger device sends out INT
 and keeps the fault state in REG09 until the host reads the fault register.
 Before the host reads REG09 and all the faults are cleared, the charger
 device would not send any INT upon new faults. In order to read the
 current fault status, the host has to read REG09 two times consecutively.
 The 1st reads fault register status from the last read [1] and the 2nd reads
 the current fault register status."

[1] presumably a typo; should be "last fault"

Fixes: d7bf353fd0aa3 ("bq24190_charger: Add support for TI BQ24190 Battery Charger")
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/power/supply/bq24190_charger.c