Skip to contentSkip to conversation

gpio_keys: Add suspend and resume

PATCH RESEND Superseded Anti Sullin 1 participant 1 message Sep 18, 2007 Input drivers

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 2/2 gpio_keys: Add suspend and resume

This patch adds suspend/resume support and enables wakeup from gpio_keys buttons.

---
Compared to previous patch sent, in this version the disable_irq_wake is called only for those IRQs, that were enabled earlier.

---

drivers/input/keyboard/gpio_keys.c +0 -0
diff -pur linux-2.6.23-rc5-old/drivers/input/keyboard/gpio_keys.c linux-2.6.23-rc5/drivers/input/keyboard/gpio_keys.c
@@ -54,6 +54,7 @@ static int __devinit gpio_keys_probe(str
	struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
	struct input_dev *input;
	int i, error;

+ int wakeup = 0;

	input = input_allocate_device();
	if (!input)
@@ -89,6 +90,9 @@ static int __devinit gpio_keys_probe(str
			goto fail;
		}

+ if (button->wakeup) + wakeup = 1;
+

		input_set_capability(input, type, button->code);
	}

@@ -98,6 +102,8 @@ static int __devinit gpio_keys_probe(str

		goto fail;
	}

+ device_init_wakeup(&pdev->dev, wakeup);
+

	return 0;

fail:
@@ -120,14 +126,55 @@ static int __devexit gpio_keys_remove(st

		free_irq(irq, pdev);
	}
+	device_init_wakeup(&pdev->dev, 0);
	input_unregister_device(input);

	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++) {
+ int irq = gpio_to_irq(pdata->buttons[i].gpio);
+ if (pdata->buttons[i].wakeup)
+ 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++) {
+ int irq = gpio_to_irq(pdata->buttons[i].gpio);
+ if (pdata->buttons[i].wakeup)
+ 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 = {
	.probe		= gpio_keys_probe,
	.remove		= __devexit_p(gpio_keys_remove),
+	.suspend	= gpio_keys_suspend,
+	.resume		= gpio_keys_resume,	
	.driver		= {
		.name	= "gpio-keys",
	}
include/linux/gpio_keys.h +0 -0
diff -pur linux-2.6.23-rc5-old/include/linux/gpio_keys.h linux-2.6.23-rc5/include/linux/gpio_keys.h
@@ -8,6 +8,7 @@ struct gpio_keys_button {
	int active_low;
	char *desc;
	int type;		/* input event type (EV_KEY, EV_SW) */

+ int wakeup; /* configure the button as wake-up source from suspend */
};

struct gpio_keys_platform_data {

Signature · 8 lines
Anti Sullin
Embedded Software Engineer
Artec Design LLC
Türi 10C, 11313, Tallinn, Estonia
Phone: +3726718550; Direct: +3726718564
Fax: +3726718555; GSM: +3725583068
email: [email protected]
http://www.artecdesign.ee