From: Shengfei xu Date: Tue, 3 Jan 2017 10:02:28 +0000 (+0800) Subject: power_supply: bq25700: support charge-dect interrupt wakeup system X-Git-Tag: firefly_0821_release~810 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=05dae6cce7900f2f44a442be0eea149236fc7867;p=firefly-linux-kernel-4.4.55.git power_supply: bq25700: support charge-dect interrupt wakeup system Change-Id: I3e826021e21caecd052f6001e3bbf73ae2732acd Signed-off-by: Shengfei xu --- diff --git a/drivers/power/bq25700_charger.c b/drivers/power/bq25700_charger.c index 13201768bd48..fca588c6c7b0 100644 --- a/drivers/power/bq25700_charger.c +++ b/drivers/power/bq25700_charger.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include static int dbg_enable; module_param_named(dbg_level, dbg_enable, int, 0644); @@ -1023,18 +1025,18 @@ static int bq25700_power_supply_init(struct bq25700_device *charger) static irqreturn_t bq25700_irq_handler_thread(int irq, void *private) { struct bq25700_device *charger = private; - int ret; - struct bq25700_state state; - - ret = bq25700_get_chip_state(charger, &state); - if (ret < 0) - goto handled; + int irq_flag; - charger->state = state; - - power_supply_changed(charger->supply_charger); + if (bq25700_field_read(charger, AC_STAT)) { + irq_flag = IRQF_TRIGGER_LOW; + } else { + irq_flag = IRQF_TRIGGER_HIGH; + bq25700_field_write(charger, INPUT_CURRENT, + charger->init_data.input_current_sdp); + } + irq_set_irq_type(irq, irq_flag | IRQF_ONESHOT); + rk_send_wakeup_key(); -handled: return IRQ_HANDLED; } @@ -1637,6 +1639,7 @@ static int bq25700_probe(struct i2c_client *client, struct bq25700_device *charger; int ret = 0; u32 i = 0; + int irq_flag; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) return -EIO; @@ -1703,12 +1706,21 @@ static int bq25700_probe(struct i2c_client *client, dev_err(dev, "No irq resource found.\n"); return client->irq; } + + if (bq25700_field_read(charger, AC_STAT)) + irq_flag = IRQF_TRIGGER_LOW; + else + irq_flag = IRQF_TRIGGER_HIGH; + + device_init_wakeup(dev, 1); + ret = devm_request_threaded_irq(dev, client->irq, NULL, bq25700_irq_handler_thread, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + irq_flag | IRQF_ONESHOT, "bq25700_irq", charger); if (ret) goto irq_fail; + enable_irq_wake(client->irq); bq25700_power_supply_init(charger); bq25700_charger = charger;