diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2013-07-09 09:04:23 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2013-08-04 19:53:34 -0400 |
commit | 024783ef422791d7ca58b106495f7c31802df6f3 (patch) | |
tree | 66d09596816eac8d8d836d1ef7d2a55c9287898b /drivers/extcon/extcon-palmas.c | |
parent | 002945f014ab51c470fdbd30b199fa85f715280d (diff) |
extcon: palams: add support for suspend/resume
Add suspend/resume callbacks and support for wakeup from
suspend on USB HOST or USB Device cable insertion or removal.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-palmas.c')
-rw-r--r-- | drivers/extcon/extcon-palmas.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index ef77a461ca39..d0ce0f16de70 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c | |||
@@ -181,7 +181,8 @@ static int palmas_usb_probe(struct platform_device *pdev) | |||
181 | 181 | ||
182 | status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq, | 182 | status = devm_request_threaded_irq(palmas_usb->dev, palmas_usb->id_irq, |
183 | NULL, palmas_id_irq_handler, | 183 | NULL, palmas_id_irq_handler, |
184 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | 184 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | |
185 | IRQF_ONESHOT | IRQF_EARLY_RESUME, | ||
185 | "palmas_usb_id", palmas_usb); | 186 | "palmas_usb_id", palmas_usb); |
186 | if (status < 0) { | 187 | if (status < 0) { |
187 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", | 188 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", |
@@ -191,7 +192,8 @@ static int palmas_usb_probe(struct platform_device *pdev) | |||
191 | 192 | ||
192 | status = devm_request_threaded_irq(palmas_usb->dev, | 193 | status = devm_request_threaded_irq(palmas_usb->dev, |
193 | palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler, | 194 | palmas_usb->vbus_irq, NULL, palmas_vbus_irq_handler, |
194 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | 195 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | |
196 | IRQF_ONESHOT | IRQF_EARLY_RESUME, | ||
195 | "palmas_usb_vbus", palmas_usb); | 197 | "palmas_usb_vbus", palmas_usb); |
196 | if (status < 0) { | 198 | if (status < 0) { |
197 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", | 199 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", |
@@ -200,7 +202,7 @@ static int palmas_usb_probe(struct platform_device *pdev) | |||
200 | } | 202 | } |
201 | 203 | ||
202 | palmas_enable_irq(palmas_usb); | 204 | palmas_enable_irq(palmas_usb); |
203 | 205 | device_set_wakeup_capable(&pdev->dev, true); | |
204 | return 0; | 206 | return 0; |
205 | 207 | ||
206 | fail_extcon: | 208 | fail_extcon: |
@@ -218,6 +220,35 @@ static int palmas_usb_remove(struct platform_device *pdev) | |||
218 | return 0; | 220 | return 0; |
219 | } | 221 | } |
220 | 222 | ||
223 | #ifdef CONFIG_PM_SLEEP | ||
224 | static int palmas_usb_suspend(struct device *dev) | ||
225 | { | ||
226 | struct palmas_usb *palmas_usb = dev_get_drvdata(dev); | ||
227 | |||
228 | if (device_may_wakeup(dev)) { | ||
229 | enable_irq_wake(palmas_usb->vbus_irq); | ||
230 | enable_irq_wake(palmas_usb->id_irq); | ||
231 | } | ||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | static int palmas_usb_resume(struct device *dev) | ||
236 | { | ||
237 | struct palmas_usb *palmas_usb = dev_get_drvdata(dev); | ||
238 | |||
239 | if (device_may_wakeup(dev)) { | ||
240 | disable_irq_wake(palmas_usb->vbus_irq); | ||
241 | disable_irq_wake(palmas_usb->id_irq); | ||
242 | } | ||
243 | return 0; | ||
244 | }; | ||
245 | #endif | ||
246 | |||
247 | static const struct dev_pm_ops palmas_pm_ops = { | ||
248 | SET_SYSTEM_SLEEP_PM_OPS(palmas_usb_suspend, | ||
249 | palmas_usb_resume) | ||
250 | }; | ||
251 | |||
221 | static struct of_device_id of_palmas_match_tbl[] = { | 252 | static struct of_device_id of_palmas_match_tbl[] = { |
222 | { .compatible = "ti,palmas-usb", }, | 253 | { .compatible = "ti,palmas-usb", }, |
223 | { .compatible = "ti,twl6035-usb", }, | 254 | { .compatible = "ti,twl6035-usb", }, |
@@ -231,6 +262,7 @@ static struct platform_driver palmas_usb_driver = { | |||
231 | .name = "palmas-usb", | 262 | .name = "palmas-usb", |
232 | .of_match_table = of_palmas_match_tbl, | 263 | .of_match_table = of_palmas_match_tbl, |
233 | .owner = THIS_MODULE, | 264 | .owner = THIS_MODULE, |
265 | .pm = &palmas_pm_ops, | ||
234 | }, | 266 | }, |
235 | }; | 267 | }; |
236 | 268 | ||