aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2015-01-14 21:00:38 -0500
committerSebastian Reichel <sre@kernel.org>2015-01-20 07:58:32 -0500
commitf1300e7f6211139da9bc1ebf685f244fbd0ee58d (patch)
treec60ddd538394be34a633d11a2605a167167db942
parentfaeed51bb65ce0241052d8dc24ac331ade12e976 (diff)
power: collie_battery: support generating wakeup event
Teach collie_battery driver to communicate to the kernel that it can generate wakeup events. Handle enabling/disabling wakeup on battery full event in suspend/resume callbacks. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
-rw-r--r--drivers/power/collie_battery.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/power/collie_battery.c b/drivers/power/collie_battery.c
index d02ae02a7590..594e4dbc2d51 100644
--- a/drivers/power/collie_battery.c
+++ b/drivers/power/collie_battery.c
@@ -26,6 +26,7 @@
26static DEFINE_MUTEX(bat_lock); /* protects gpio pins */ 26static DEFINE_MUTEX(bat_lock); /* protects gpio pins */
27static struct work_struct bat_work; 27static struct work_struct bat_work;
28static struct ucb1x00 *ucb; 28static struct ucb1x00 *ucb;
29static int wakeup_enabled;
29 30
30struct collie_bat { 31struct collie_bat {
31 int status; 32 int status;
@@ -291,11 +292,21 @@ static int collie_bat_suspend(struct ucb1x00_dev *dev)
291{ 292{
292 /* flush all pending status updates */ 293 /* flush all pending status updates */
293 flush_work(&bat_work); 294 flush_work(&bat_work);
295
296 if (device_may_wakeup(&dev->ucb->dev) &&
297 collie_bat_main.status == POWER_SUPPLY_STATUS_CHARGING)
298 wakeup_enabled = !enable_irq_wake(gpio_to_irq(COLLIE_GPIO_CO));
299 else
300 wakeup_enabled = 0;
301
294 return 0; 302 return 0;
295} 303}
296 304
297static int collie_bat_resume(struct ucb1x00_dev *dev) 305static int collie_bat_resume(struct ucb1x00_dev *dev)
298{ 306{
307 if (wakeup_enabled)
308 disable_irq_wake(gpio_to_irq(COLLIE_GPIO_CO));
309
299 /* things may have changed while we were away */ 310 /* things may have changed while we were away */
300 schedule_work(&bat_work); 311 schedule_work(&bat_work);
301 return 0; 312 return 0;
@@ -334,10 +345,15 @@ static int collie_bat_probe(struct ucb1x00_dev *dev)
334 collie_bat_gpio_isr, 345 collie_bat_gpio_isr,
335 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 346 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
336 "main full", &collie_bat_main); 347 "main full", &collie_bat_main);
337 if (!ret) { 348 if (ret)
338 schedule_work(&bat_work); 349 goto err_irq;
339 return 0; 350
340 } 351 device_init_wakeup(&ucb->dev, 1);
352 schedule_work(&bat_work);
353
354 return 0;
355
356err_irq:
341 power_supply_unregister(&collie_bat_bu.psy); 357 power_supply_unregister(&collie_bat_bu.psy);
342err_psy_reg_bu: 358err_psy_reg_bu:
343 power_supply_unregister(&collie_bat_main.psy); 359 power_supply_unregister(&collie_bat_main.psy);