From patchwork Fri Aug 19 15:56:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 1080992 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7JFuEML030787 for ; Fri, 19 Aug 2011 15:56:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754161Ab1HSP4O (ORCPT ); Fri, 19 Aug 2011 11:56:14 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:36561 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753144Ab1HSP4N (ORCPT ); Fri, 19 Aug 2011 11:56:13 -0400 Received: by ywf7 with SMTP id 7so2283271ywf.19 for ; Fri, 19 Aug 2011 08:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=dEczCGHq5yX74qcHn17kuDMdLe/4lu985XfNsiHuBaI=; b=oZN+jOccVU7WKBjGK9HkLOIhgtyt61HAzXZ6S1W9n8hh/xR21vqNZVPfWkVJLpSSzA AX8Jx4INUHYGHsUMPWg9+EX2NwC7FsFuERWLwd7ZA1VxaRNiaN+tVYQ95f3q3fjrEQmx QiuygLqynZ0cS8zp+PuG8YkYSSz9v4dAfiLkk= Received: by 10.150.72.27 with SMTP id u27mr2444708yba.205.1313769372625; Fri, 19 Aug 2011 08:56:12 -0700 (PDT) Received: from localhost.localdomain ([201.82.76.9]) by mx.google.com with ESMTPS id m3sm397399ybg.11.2011.08.19.08.56.10 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Aug 2011 08:56:11 -0700 (PDT) From: Fabio Estevam To: linux-input@vger.kernel.org Cc: kernel@pengutronix.de, dmitry.torokhov@gmail.com, Fabio Estevam , Fabio Estevam Subject: [PATCH] Input: imx_keypad: Provide PM support Date: Fri, 19 Aug 2011 12:56:04 -0300 Message-Id: <1313769364-27249-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.6.0.4 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 19 Aug 2011 15:56:15 +0000 (UTC) Provide PM support to imx_keypad and allow the keypad to be used as a wakeup source. Tested on a mx27_3ds, which wakes up via keypad press. Signed-off-by: Fabio Estevam --- If I put disable_irq_wake(keypad->irq) inside imx_keypad_resume like other keyboard drivers do I get the following: mx27# echo mem > /sys/power/state PM: Syncing filesystems ... done. Freezing user space processes ... (elapsed 0.01 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done. Suspending console(s) (use no_console_suspend to debug) PM: suspend of devices complete after 0.692 msecs PM: late suspend of devices complete after 0.418 msecs PM: early resume of devices complete after 0.179 msecs ------------[ cut here ]------------ WARNING: at kernel/irq/manage.c:510 irq_set_irq_wake+0xdc/0xec() Unbalanced IRQ 21 wake disable Modules linked in: [] (unwind_backtrace+0x0/0xf4) from [] (warn_slowpath_common +0x4c/0x64) [] (warn_slowpath_common+0x4c/0x64) from [] (warn_slowpath_f mt+0x30/0x40) [] (warn_slowpath_fmt+0x30/0x40) from [] (irq_set_irq_wake+0 xdc/0xec) [] (irq_set_irq_wake+0xdc/0xec) from [] (imx_keypad_resume+0 x30/0x38) [] (imx_keypad_resume+0x30/0x38) from [] (platform_pm_resume +0x2c/0x4c) [] (platform_pm_resume+0x2c/0x4c) from [] (pm_op+0xa0/0xc0) [] (pm_op+0xa0/0xc0) from [] (device_resume+0x5c/0x100) [] (device_resume+0x5c/0x100) from [] (dpm_resume+0x134/0x19 0) [] (dpm_resume+0x134/0x190) from [] (dpm_resume_end+0xc/0x18 ) [] (dpm_resume_end+0xc/0x18) from [] (suspend_devices_and_en ter+0x160/0x338) [] (suspend_devices_and_enter+0x160/0x338) from [] (enter_st ate+0xec/0x128) [] (enter_state+0xec/0x128) from [] (state_store+0xd0/0x124) [] (state_store+0xd0/0x124) from [] (kobj_attr_store+0x18/0x 1c) [] (kobj_attr_store+0x18/0x1c) from [] (sysfs_write_file+0xf 8/0x17c) [] (sysfs_write_file+0xf8/0x17c) from [] (vfs_write+0xb0/0x1 34) [] (vfs_write+0xb0/0x134) from [] (sys_write+0x40/0x70) [] (sys_write+0x40/0x70) from [] (ret_fast_syscall+0x0/0x2c) ---[ end trace 5656d76309d84fa1 ]--- PM: resume of devices complete after 1.960 msecs Restarting tasks ... done. drivers/input/keyboard/imx_keypad.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c index d92c15c..4acb480 100644 --- a/drivers/input/keyboard/imx_keypad.c +++ b/drivers/input/keyboard/imx_keypad.c @@ -408,6 +408,28 @@ open_err: return -EIO; } +#ifdef CONFIG_PM +static int imx_keypad_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct imx_keypad *keypad = platform_get_drvdata(pdev); + + if (device_may_wakeup(&pdev->dev)) + enable_irq_wake(keypad->irq); + + return 0; +} + +static int imx_keypad_resume(struct device *dev) +{ + return 0; +} + +static const struct dev_pm_ops imx_keypad_pm_ops = { + .suspend = imx_keypad_suspend, + .resume = imx_keypad_resume, +}; +#endif static int __devinit imx_keypad_probe(struct platform_device *pdev) { const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data; @@ -571,6 +593,9 @@ static struct platform_driver imx_keypad_driver = { .driver = { .name = "imx-keypad", .owner = THIS_MODULE, +#ifdef CONFIG_PM + .pm = &imx_keypad_pm_ops, +#endif }, .probe = imx_keypad_probe, .remove = __devexit_p(imx_keypad_remove),