Commit d4f510f6 authored by Rupesh Kumar's avatar Rupesh Kumar Committed by Lee Jones

pm2301-charger: Wake system when ext charger is plugged-in

When in suspend state, upon plug-in of external AC charger the
device needs to wake-up and charging operation started.
Signed-off-by: default avatarRupesh Kumar <rupesh.kumar@stericsson.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Reviewed-by: default avatarPhilippe LANGLAIS <philippe.langlais@stericsson.com>
parent da9e83d4
...@@ -1072,6 +1072,12 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, ...@@ -1072,6 +1072,12 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
pm2xxx_charger_irq[0].name, pm2->pdata->irq_number, ret); pm2xxx_charger_irq[0].name, pm2->pdata->irq_number, ret);
goto unregister_pm2xxx_charger; goto unregister_pm2xxx_charger;
} }
/* pm interrupt can wake up system */
ret = enable_irq_wake(pm2->pdata->irq_number);
if (ret) {
dev_err(pm2->dev, "failed to set irq wake\n");
goto unregister_pm2xxx_interrupt;
}
/*Initialize lock*/ /*Initialize lock*/
mutex_init(&pm2->lock); mutex_init(&pm2->lock);
...@@ -1084,7 +1090,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, ...@@ -1084,7 +1090,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
ret = gpio_request(pm2->lpn_pin, "pm2301_lpm_gpio"); ret = gpio_request(pm2->lpn_pin, "pm2301_lpm_gpio");
if (ret < 0) { if (ret < 0) {
dev_err(pm2->dev, "pm2301_lpm_gpio request failed\n"); dev_err(pm2->dev, "pm2301_lpm_gpio request failed\n");
goto unregister_pm2xxx_charger; goto disable_pm2_irq_wake;
} }
ret = gpio_direction_output(pm2->lpn_pin, 0); ret = gpio_direction_output(pm2->lpn_pin, 0);
if (ret < 0) { if (ret < 0) {
...@@ -1115,6 +1121,11 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, ...@@ -1115,6 +1121,11 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
free_gpio: free_gpio:
gpio_free(pm2->lpn_pin); gpio_free(pm2->lpn_pin);
disable_pm2_irq_wake:
disable_irq_wake(pm2->pdata->irq_number);
unregister_pm2xxx_interrupt:
/* disable interrupt */
free_irq(pm2->pdata->irq_number, pm2);
unregister_pm2xxx_charger: unregister_pm2xxx_charger:
/* unregister power supply */ /* unregister power supply */
power_supply_unregister(&pm2->ac_chg.psy); power_supply_unregister(&pm2->ac_chg.psy);
...@@ -1125,6 +1136,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, ...@@ -1125,6 +1136,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
destroy_workqueue(pm2->charger_wq); destroy_workqueue(pm2->charger_wq);
free_device_info: free_device_info:
kfree(pm2); kfree(pm2);
return ret; return ret;
} }
...@@ -1135,6 +1147,9 @@ static int pm2xxx_wall_charger_remove(struct i2c_client *i2c_client) ...@@ -1135,6 +1147,9 @@ static int pm2xxx_wall_charger_remove(struct i2c_client *i2c_client)
/* Disable AC charging */ /* Disable AC charging */
pm2xxx_charger_ac_en(&pm2->ac_chg, false, 0, 0); pm2xxx_charger_ac_en(&pm2->ac_chg, false, 0, 0);
/* Disable wake by pm interrupt */
disable_irq_wake(pm2->pdata->irq_number);
/* Disable interrupts */ /* Disable interrupts */
free_irq(pm2->pdata->irq_number, pm2); free_irq(pm2->pdata->irq_number, pm2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment