aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Liu <kliu5@marvell.com>2012-03-06 01:24:54 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-03-06 01:32:54 -0500
commitadab30d73844076b6ca9cd3e6382f5db3a44ded4 (patch)
treed15cf66b45c135879e600f42cb5c275e995c93f9
parentfa3e44f391149dd49fd053aef55c42479753d45a (diff)
Input: max8925_onkey - allow to be used as a wakeup source
Implement suspend and resume methods to set up devices as wakeup source. Signed-off-by: Kevin Liu <kliu5@marvell.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/misc/max8925_onkey.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c
index 23cf08271049..27174770b13a 100644
--- a/drivers/input/misc/max8925_onkey.c
+++ b/drivers/input/misc/max8925_onkey.c
@@ -122,6 +122,7 @@ static int __devinit max8925_onkey_probe(struct platform_device *pdev)
122 info->idev->evbit[0] = BIT_MASK(EV_KEY); 122 info->idev->evbit[0] = BIT_MASK(EV_KEY);
123 info->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER); 123 info->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
124 124
125 device_init_wakeup(&pdev->dev, 1);
125 126
126 error = input_register_device(info->idev); 127 error = input_register_device(info->idev);
127 if (error) { 128 if (error) {
@@ -158,10 +159,43 @@ static int __devexit max8925_onkey_remove(struct platform_device *pdev)
158 return 0; 159 return 0;
159} 160}
160 161
162#ifdef CONFIG_PM_SLEEP
163static int max8925_onkey_suspend(struct device *dev)
164{
165 struct platform_device *pdev = to_platform_device(dev);
166 struct max8925_onkey_info *info = platform_get_drvdata(pdev);
167 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
168
169 if (device_may_wakeup(dev)) {
170 chip->wakeup_flag |= 1 << (info->irq[0] - chip->irq_base);
171 chip->wakeup_flag |= 1 << (info->irq[1] - chip->irq_base);
172 }
173
174 return 0;
175}
176
177static int max8925_onkey_resume(struct device *dev)
178{
179 struct platform_device *pdev = to_platform_device(dev);
180 struct max8925_onkey_info *info = platform_get_drvdata(pdev);
181 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
182
183 if (device_may_wakeup(dev)) {
184 chip->wakeup_flag &= ~(1 << (info->irq[0] - chip->irq_base));
185 chip->wakeup_flag &= ~(1 << (info->irq[1] - chip->irq_base));
186 }
187
188 return 0;
189}
190#endif
191
192static SIMPLE_DEV_PM_OPS(max8925_onkey_pm_ops, max8925_onkey_suspend, max8925_onkey_resume);
193
161static struct platform_driver max8925_onkey_driver = { 194static struct platform_driver max8925_onkey_driver = {
162 .driver = { 195 .driver = {
163 .name = "max8925-onkey", 196 .name = "max8925-onkey",
164 .owner = THIS_MODULE, 197 .owner = THIS_MODULE,
198 .pm = &max8925_onkey_pm_ops,
165 }, 199 },
166 .probe = max8925_onkey_probe, 200 .probe = max8925_onkey_probe,
167 .remove = __devexit_p(max8925_onkey_remove), 201 .remove = __devexit_p(max8925_onkey_remove),