power_supply: bq25700: update status when charger pull out
authorShunqing Chen <csq@rock-chips.com>
Mon, 23 Jan 2017 01:38:12 +0000 (09:38 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 13 Feb 2017 03:32:58 +0000 (11:32 +0800)
Change-Id: I416aba3e0318544497bdf444df213461fd10ec7e
Signed-off-by: Shunqing Chen <csq@rock-chips.com>
drivers/power/bq25700_charger.c

index eb0230d798ea372ad601a3913da42db43588087f..0509ecd5ea20b6dccebffbd7bbbb7ddd14f95038 100644 (file)
@@ -428,6 +428,8 @@ static const struct regmap_config bq25700_regmap_config = {
        .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
+static void bq25700_disable_charge(struct bq25700_device *charger);
+
 static struct bq25700_device *bq25700_charger;
 
 static int bq25700_field_read(struct bq25700_device *charger,
@@ -1026,6 +1028,7 @@ static irqreturn_t bq25700_irq_handler_thread(int irq, void *private)
 {
        struct bq25700_device *charger = private;
        int irq_flag;
+       struct bq25700_state state;
 
        if (bq25700_field_read(charger, AC_STAT)) {
                irq_flag = IRQF_TRIGGER_LOW;
@@ -1033,6 +1036,12 @@ static irqreturn_t bq25700_irq_handler_thread(int irq, void *private)
                irq_flag = IRQF_TRIGGER_HIGH;
                bq25700_field_write(charger, INPUT_CURRENT,
                                    charger->init_data.input_current_sdp);
+               bq25700_disable_charge(charger);
+               bq25700_get_chip_state(charger, &state);
+               charger->state = state;
+               power_supply_changed(charger->supply_charger);
+               charger->typec0_status = USB_STATUS_NONE;
+               charger->typec1_status = USB_STATUS_NONE;
        }
        irq_set_irq_type(irq, irq_flag | IRQF_ONESHOT);
        rk_send_wakeup_key();