power: pm8921-charger: Enable Battery Temperature Interrupts
Handle temperature related interrupts to disable or re-enable
charging of battery for JEITA compliance. If the temperature
drops or rises beyond the respective temperature level the falling
edge of the BAT_TEMP_OK_IRQ is triggered and external charging
is disabled. Once the temperature returns to an acceptable level
the rising edge of the interrupt triggers and the handler enables
external charging again.
CRs-Fixed: 315196
Change-Id: I7d001cde2ee9ac96e2321202fbf76ad03a986536
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c
index 552ed82..d7a7b5a 100644
--- a/drivers/power/pm8921-charger.c
+++ b/drivers/power/pm8921-charger.c
@@ -1688,13 +1688,31 @@
power_supply_changed(&chip->dc_psy);
return IRQ_HANDLED;
}
-
+/*
+ *
+ * bat_temp_ok_irq_handler - is edge triggered, hence it will
+ * fire for two cases:
+ *
+ * If the interrupt line switches to high temperature is okay
+ * and thus charging begins.
+ * If bat_temp_ok is low this means the temperature is now
+ * too hot or cold, so charging is stopped.
+ *
+ */
static irqreturn_t bat_temp_ok_irq_handler(int irq, void *data)
{
+ int bat_temp_ok;
struct pm8921_chg_chip *chip = data;
- pr_debug("batt temp ok fsm_state=%d\n", pm_chg_get_fsm_state(data));
- handle_start_ext_chg(chip);
+ bat_temp_ok = pm_chg_get_rt_status(chip, BAT_TEMP_OK_IRQ);
+
+ pr_debug("batt_temp_ok = %d fsm_state%d\n",
+ bat_temp_ok, pm_chg_get_fsm_state(data));
+
+ if (bat_temp_ok)
+ handle_start_ext_chg(chip);
+ else
+ handle_stop_ext_chg(chip);
power_supply_changed(&chip->batt_psy);
power_supply_changed(&chip->usb_psy);
@@ -2119,6 +2137,7 @@
pm8921_chg_enable_irq(chip, CHGFAIL_IRQ);
pm8921_chg_enable_irq(chip, FASTCHG_IRQ);
pm8921_chg_enable_irq(chip, VBATDET_LOW_IRQ);
+ pm8921_chg_enable_irq(chip, BAT_TEMP_OK_IRQ);
spin_lock_irqsave(&vbus_lock, flags);
if (usb_chg_current) {