From: Hui Wang Date: Thu, 13 Oct 2011 04:11:16 +0000 (-0700) Subject: Input: imx_keypad - add pm suspend and resume support X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=81e8f2bc;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git Input: imx_keypad - add pm suspend and resume support The imx_keypad driver was indicating that it was wakeup capable in imx_keypad_probe(), but it didn't implement suspend or resume methods. According to the i.MX series MCU Reference Manual, the kpp (keypad port) is a major wake up source which can detect any key press even in low power mode and even when there is no clock. Signed-off-by: Hui Wang Reviewed-by: Wanlong Gao Signed-off-by: Dmitry Torokhov --- diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c index 4b093faf5786..ccebd2d09151 100644 --- a/drivers/input/keyboard/imx_keypad.c +++ b/drivers/input/keyboard/imx_keypad.c @@ -567,10 +567,54 @@ static int __devexit imx_keypad_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int imx_kbd_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct imx_keypad *kbd = platform_get_drvdata(pdev); + struct input_dev *input_dev = kbd->input_dev; + + /* imx kbd can wake up system even clock is disabled */ + mutex_lock(&input_dev->mutex); + + if (input_dev->users) + clk_disable(kbd->clk); + + mutex_unlock(&input_dev->mutex); + + if (device_may_wakeup(&pdev->dev)) + enable_irq_wake(kbd->irq); + + return 0; +} + +static int imx_kbd_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct imx_keypad *kbd = platform_get_drvdata(pdev); + struct input_dev *input_dev = kbd->input_dev; + + if (device_may_wakeup(&pdev->dev)) + disable_irq_wake(kbd->irq); + + mutex_lock(&input_dev->mutex); + + if (input_dev->users) + clk_enable(kbd->clk); + + mutex_unlock(&input_dev->mutex); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(imx_kbd_pm_ops, imx_kbd_suspend, imx_kbd_resume); + static struct platform_driver imx_keypad_driver = { .driver = { .name = "imx-keypad", .owner = THIS_MODULE, + .pm = &imx_kbd_pm_ops, }, .probe = imx_keypad_probe, .remove = __devexit_p(imx_keypad_remove),