diff options
| author | Illia Smyrnov <illia.smyrnov@ti.com> | 2013-08-26 02:29:30 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-08-26 03:15:58 -0400 |
| commit | 78608a0d940982e926401b4fa5e4a9061e9b53f3 (patch) | |
| tree | f0163572d8eb78ed16651c41a2cc0136740f5fed | |
| parent | afbac60b0c535189a76855a04d85492cf2d992e1 (diff) | |
Input: omap-keypad - enable wakeup capability for keypad.
Enable/disable IRQ wake in suspend/resume handlers
to make the keypad wakeup capable.
Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -rw-r--r-- | drivers/input/keyboard/omap4-keypad.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index 0244262e2600..cd6b9175179a 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c | |||
| @@ -74,6 +74,7 @@ struct omap4_keypad { | |||
| 74 | struct input_dev *input; | 74 | struct input_dev *input; |
| 75 | 75 | ||
| 76 | void __iomem *base; | 76 | void __iomem *base; |
| 77 | bool irq_wake_enabled; | ||
| 77 | unsigned int irq; | 78 | unsigned int irq; |
| 78 | 79 | ||
| 79 | unsigned int rows; | 80 | unsigned int rows; |
| @@ -380,6 +381,7 @@ static int omap4_keypad_probe(struct platform_device *pdev) | |||
| 380 | goto err_free_input; | 381 | goto err_free_input; |
| 381 | } | 382 | } |
| 382 | 383 | ||
| 384 | device_init_wakeup(&pdev->dev, true); | ||
| 383 | pm_runtime_put_sync(&pdev->dev); | 385 | pm_runtime_put_sync(&pdev->dev); |
| 384 | 386 | ||
| 385 | error = input_register_device(keypad_data->input); | 387 | error = input_register_device(keypad_data->input); |
| @@ -393,6 +395,7 @@ static int omap4_keypad_probe(struct platform_device *pdev) | |||
| 393 | 395 | ||
| 394 | err_pm_disable: | 396 | err_pm_disable: |
| 395 | pm_runtime_disable(&pdev->dev); | 397 | pm_runtime_disable(&pdev->dev); |
| 398 | device_init_wakeup(&pdev->dev, false); | ||
| 396 | free_irq(keypad_data->irq, keypad_data); | 399 | free_irq(keypad_data->irq, keypad_data); |
| 397 | err_free_keymap: | 400 | err_free_keymap: |
| 398 | kfree(keypad_data->keymap); | 401 | kfree(keypad_data->keymap); |
| @@ -418,6 +421,8 @@ static int omap4_keypad_remove(struct platform_device *pdev) | |||
| 418 | 421 | ||
| 419 | pm_runtime_disable(&pdev->dev); | 422 | pm_runtime_disable(&pdev->dev); |
| 420 | 423 | ||
| 424 | device_init_wakeup(&pdev->dev, false); | ||
| 425 | |||
| 421 | input_unregister_device(keypad_data->input); | 426 | input_unregister_device(keypad_data->input); |
| 422 | 427 | ||
| 423 | iounmap(keypad_data->base); | 428 | iounmap(keypad_data->base); |
| @@ -439,12 +444,46 @@ static const struct of_device_id omap_keypad_dt_match[] = { | |||
| 439 | MODULE_DEVICE_TABLE(of, omap_keypad_dt_match); | 444 | MODULE_DEVICE_TABLE(of, omap_keypad_dt_match); |
| 440 | #endif | 445 | #endif |
| 441 | 446 | ||
| 447 | #ifdef CONFIG_PM_SLEEP | ||
| 448 | static int omap4_keypad_suspend(struct device *dev) | ||
| 449 | { | ||
| 450 | struct platform_device *pdev = to_platform_device(dev); | ||
| 451 | struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); | ||
| 452 | int error; | ||
| 453 | |||
| 454 | if (device_may_wakeup(&pdev->dev)) { | ||
| 455 | error = enable_irq_wake(keypad_data->irq); | ||
| 456 | if (!error) | ||
| 457 | keypad_data->irq_wake_enabled = true; | ||
| 458 | } | ||
| 459 | |||
| 460 | return 0; | ||
| 461 | } | ||
| 462 | |||
| 463 | static int omap4_keypad_resume(struct device *dev) | ||
| 464 | { | ||
| 465 | struct platform_device *pdev = to_platform_device(dev); | ||
| 466 | struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); | ||
| 467 | |||
| 468 | if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) { | ||
| 469 | disable_irq_wake(keypad_data->irq); | ||
| 470 | keypad_data->irq_wake_enabled = false; | ||
| 471 | } | ||
| 472 | |||
| 473 | return 0; | ||
| 474 | } | ||
| 475 | #endif | ||
| 476 | |||
| 477 | static SIMPLE_DEV_PM_OPS(omap4_keypad_pm_ops, | ||
| 478 | omap4_keypad_suspend, omap4_keypad_resume); | ||
| 479 | |||
| 442 | static struct platform_driver omap4_keypad_driver = { | 480 | static struct platform_driver omap4_keypad_driver = { |
| 443 | .probe = omap4_keypad_probe, | 481 | .probe = omap4_keypad_probe, |
| 444 | .remove = omap4_keypad_remove, | 482 | .remove = omap4_keypad_remove, |
| 445 | .driver = { | 483 | .driver = { |
| 446 | .name = "omap4-keypad", | 484 | .name = "omap4-keypad", |
| 447 | .owner = THIS_MODULE, | 485 | .owner = THIS_MODULE, |
| 486 | .pm = &omap4_keypad_pm_ops, | ||
| 448 | .of_match_table = of_match_ptr(omap_keypad_dt_match), | 487 | .of_match_table = of_match_ptr(omap_keypad_dt_match), |
| 449 | }, | 488 | }, |
| 450 | }; | 489 | }; |
