diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2013-12-10 17:47:16 -0500 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-12-23 21:54:03 -0500 |
commit | 4ea81266010ae41a48c7ce393335dfe241931209 (patch) | |
tree | 05c1d77c120499105652ecca7094bcf8ce51367f /drivers/power | |
parent | 55e6470120b2cb94700e2cb97077dfe9a5744244 (diff) |
gpio-charger: Support wakeup events
Add support for using gpio-charger IRQ as a wakeup event.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/gpio-charger.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c index 4e858a23568f..a0024b252197 100644 --- a/drivers/power/gpio-charger.c +++ b/drivers/power/gpio-charger.c | |||
@@ -28,6 +28,7 @@ | |||
28 | struct gpio_charger { | 28 | struct gpio_charger { |
29 | const struct gpio_charger_platform_data *pdata; | 29 | const struct gpio_charger_platform_data *pdata; |
30 | unsigned int irq; | 30 | unsigned int irq; |
31 | bool wakeup_enabled; | ||
31 | 32 | ||
32 | struct power_supply charger; | 33 | struct power_supply charger; |
33 | }; | 34 | }; |
@@ -136,6 +137,8 @@ static int gpio_charger_probe(struct platform_device *pdev) | |||
136 | 137 | ||
137 | platform_set_drvdata(pdev, gpio_charger); | 138 | platform_set_drvdata(pdev, gpio_charger); |
138 | 139 | ||
140 | device_init_wakeup(&pdev->dev, 1); | ||
141 | |||
139 | return 0; | 142 | return 0; |
140 | 143 | ||
141 | err_gpio_free: | 144 | err_gpio_free: |
@@ -159,18 +162,32 @@ static int gpio_charger_remove(struct platform_device *pdev) | |||
159 | } | 162 | } |
160 | 163 | ||
161 | #ifdef CONFIG_PM_SLEEP | 164 | #ifdef CONFIG_PM_SLEEP |
165 | static int gpio_charger_suspend(struct device *dev) | ||
166 | { | ||
167 | struct gpio_charger *gpio_charger = dev_get_drvdata(dev); | ||
168 | |||
169 | if (device_may_wakeup(dev)) | ||
170 | gpio_charger->wakeup_enabled = | ||
171 | enable_irq_wake(gpio_charger->irq); | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
162 | static int gpio_charger_resume(struct device *dev) | 176 | static int gpio_charger_resume(struct device *dev) |
163 | { | 177 | { |
164 | struct platform_device *pdev = to_platform_device(dev); | 178 | struct platform_device *pdev = to_platform_device(dev); |
165 | struct gpio_charger *gpio_charger = platform_get_drvdata(pdev); | 179 | struct gpio_charger *gpio_charger = platform_get_drvdata(pdev); |
166 | 180 | ||
181 | if (gpio_charger->wakeup_enabled) | ||
182 | disable_irq_wake(gpio_charger->irq); | ||
167 | power_supply_changed(&gpio_charger->charger); | 183 | power_supply_changed(&gpio_charger->charger); |
168 | 184 | ||
169 | return 0; | 185 | return 0; |
170 | } | 186 | } |
171 | #endif | 187 | #endif |
172 | 188 | ||
173 | static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, NULL, gpio_charger_resume); | 189 | static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, |
190 | gpio_charger_suspend, gpio_charger_resume); | ||
174 | 191 | ||
175 | static struct platform_driver gpio_charger_driver = { | 192 | static struct platform_driver gpio_charger_driver = { |
176 | .probe = gpio_charger_probe, | 193 | .probe = gpio_charger_probe, |