Input: gpio-keys - add suspend/resume support
This patch adds suspend/resume support and enables wakeup from gpio_keys buttons. Signed-off-by: Anti Sullin <anti.sullin@artecdesign.ee> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
006df30244
commit
e15b02138b
|
@ -55,6 +55,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
|
||||||
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
|
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
int i, error;
|
int i, error;
|
||||||
|
int wakeup = 0;
|
||||||
|
|
||||||
input = input_allocate_device();
|
input = input_allocate_device();
|
||||||
if (!input)
|
if (!input)
|
||||||
|
@ -100,6 +101,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (button->wakeup)
|
||||||
|
wakeup = 1;
|
||||||
|
|
||||||
input_set_capability(input, type, button->code);
|
input_set_capability(input, type, button->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +115,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device_init_wakeup(&pdev->dev, wakeup);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
@ -129,6 +135,8 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
|
||||||
struct input_dev *input = platform_get_drvdata(pdev);
|
struct input_dev *input = platform_get_drvdata(pdev);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
device_init_wakeup(&pdev->dev, 0);
|
||||||
|
|
||||||
for (i = 0; i < pdata->nbuttons; i++) {
|
for (i = 0; i < pdata->nbuttons; i++) {
|
||||||
int irq = gpio_to_irq(pdata->buttons[i].gpio);
|
int irq = gpio_to_irq(pdata->buttons[i].gpio);
|
||||||
free_irq(irq, pdev);
|
free_irq(irq, pdev);
|
||||||
|
@ -139,9 +147,53 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
static int gpio_keys_suspend(struct platform_device *pdev, pm_message_t state)
|
||||||
|
{
|
||||||
|
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (device_may_wakeup(&pdev->dev)) {
|
||||||
|
for (i = 0; i < pdata->nbuttons; i++) {
|
||||||
|
struct gpio_keys_button *button = &pdata->buttons[i];
|
||||||
|
if (button->wakeup) {
|
||||||
|
int irq = gpio_to_irq(button->gpio);
|
||||||
|
enable_irq_wake(irq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gpio_keys_resume(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (device_may_wakeup(&pdev->dev)) {
|
||||||
|
for (i = 0; i < pdata->nbuttons; i++) {
|
||||||
|
struct gpio_keys_button *button = &pdata->buttons[i];
|
||||||
|
if (button->wakeup) {
|
||||||
|
int irq = gpio_to_irq(button->gpio);
|
||||||
|
disable_irq_wake(irq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define gpio_keys_suspend NULL
|
||||||
|
#define gpio_keys_resume NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
struct platform_driver gpio_keys_device_driver = {
|
struct platform_driver gpio_keys_device_driver = {
|
||||||
.probe = gpio_keys_probe,
|
.probe = gpio_keys_probe,
|
||||||
.remove = __devexit_p(gpio_keys_remove),
|
.remove = __devexit_p(gpio_keys_remove),
|
||||||
|
.suspend = gpio_keys_suspend,
|
||||||
|
.resume = gpio_keys_resume,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "gpio-keys",
|
.name = "gpio-keys",
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ struct gpio_keys_button {
|
||||||
int active_low;
|
int active_low;
|
||||||
char *desc;
|
char *desc;
|
||||||
int type; /* input event type (EV_KEY, EV_SW) */
|
int type; /* input event type (EV_KEY, EV_SW) */
|
||||||
|
int wakeup; /* configure the button as a wake-up source */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gpio_keys_platform_data {
|
struct gpio_keys_platform_data {
|
||||||
|
|
Loading…
Reference in New Issue