Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Driver for keys on GPIO lines capable of generating interrupts. |
| 3 | * |
| 4 | * Copyright 2005 Phil Blundell |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/module.h> |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 12 | |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/fs.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/irq.h> |
| 17 | #include <linux/sched.h> |
| 18 | #include <linux/pm.h> |
| 19 | #include <linux/sysctl.h> |
| 20 | #include <linux/proc_fs.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/input.h> |
David Brownell | 49015be | 2007-03-05 00:30:22 -0800 | [diff] [blame] | 24 | #include <linux/gpio_keys.h> |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 25 | #include <linux/workqueue.h> |
Ben Dooks | 111bc59 | 2009-11-10 21:01:31 -0800 | [diff] [blame^] | 26 | #include <linux/gpio.h> |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 27 | |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 28 | struct gpio_button_data { |
| 29 | struct gpio_keys_button *button; |
| 30 | struct input_dev *input; |
Jani Nikula | ca865a7 | 2009-06-28 22:38:44 -0700 | [diff] [blame] | 31 | struct timer_list timer; |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 32 | struct work_struct work; |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | struct gpio_keys_drvdata { |
| 36 | struct input_dev *input; |
| 37 | struct gpio_button_data data[0]; |
| 38 | }; |
| 39 | |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 40 | static void gpio_keys_report_event(struct work_struct *work) |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 41 | { |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 42 | struct gpio_button_data *bdata = |
| 43 | container_of(work, struct gpio_button_data, work); |
Uwe Kleine-König | ce25d7e | 2008-08-08 12:14:36 -0400 | [diff] [blame] | 44 | struct gpio_keys_button *button = bdata->button; |
| 45 | struct input_dev *input = bdata->input; |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 46 | unsigned int type = button->type ?: EV_KEY; |
| 47 | int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; |
| 48 | |
| 49 | input_event(input, type, button->code, !!state); |
| 50 | input_sync(input); |
| 51 | } |
| 52 | |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 53 | static void gpio_keys_timer(unsigned long _data) |
Jani Nikula | ca865a7 | 2009-06-28 22:38:44 -0700 | [diff] [blame] | 54 | { |
| 55 | struct gpio_button_data *data = (struct gpio_button_data *)_data; |
| 56 | |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 57 | schedule_work(&data->work); |
Jani Nikula | ca865a7 | 2009-06-28 22:38:44 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 60 | static irqreturn_t gpio_keys_isr(int irq, void *dev_id) |
| 61 | { |
Uwe Kleine-König | 57ffe9d | 2008-08-08 12:14:34 -0400 | [diff] [blame] | 62 | struct gpio_button_data *bdata = dev_id; |
| 63 | struct gpio_keys_button *button = bdata->button; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 64 | |
Uwe Kleine-König | 57ffe9d | 2008-08-08 12:14:34 -0400 | [diff] [blame] | 65 | BUG_ON(irq != gpio_to_irq(button->gpio)); |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 66 | |
Jani Nikula | ca865a7 | 2009-06-28 22:38:44 -0700 | [diff] [blame] | 67 | if (button->debounce_interval) |
| 68 | mod_timer(&bdata->timer, |
| 69 | jiffies + msecs_to_jiffies(button->debounce_interval)); |
| 70 | else |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 71 | schedule_work(&bdata->work); |
Roman Moravcik | 84767d0 | 2007-05-01 00:39:13 -0400 | [diff] [blame] | 72 | |
Uwe Kleine-König | 57ffe9d | 2008-08-08 12:14:34 -0400 | [diff] [blame] | 73 | return IRQ_HANDLED; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | static int __devinit gpio_keys_probe(struct platform_device *pdev) |
| 77 | { |
| 78 | struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 79 | struct gpio_keys_drvdata *ddata; |
Ben Dooks | db19fd8 | 2009-11-10 21:00:35 -0800 | [diff] [blame] | 80 | struct device *dev = &pdev->dev; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 81 | struct input_dev *input; |
| 82 | int i, error; |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 83 | int wakeup = 0; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 84 | |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 85 | ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + |
| 86 | pdata->nbuttons * sizeof(struct gpio_button_data), |
| 87 | GFP_KERNEL); |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 88 | input = input_allocate_device(); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 89 | if (!ddata || !input) { |
Ben Dooks | db19fd8 | 2009-11-10 21:00:35 -0800 | [diff] [blame] | 90 | dev_err(dev, "failed to allocate state\n"); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 91 | error = -ENOMEM; |
| 92 | goto fail1; |
| 93 | } |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 94 | |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 95 | platform_set_drvdata(pdev, ddata); |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 96 | |
| 97 | input->name = pdev->name; |
| 98 | input->phys = "gpio-keys/input0"; |
Dmitry Torokhov | 469ba4d | 2007-04-12 01:34:58 -0400 | [diff] [blame] | 99 | input->dev.parent = &pdev->dev; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 100 | |
| 101 | input->id.bustype = BUS_HOST; |
| 102 | input->id.vendor = 0x0001; |
| 103 | input->id.product = 0x0001; |
| 104 | input->id.version = 0x0100; |
| 105 | |
Dominic Curran | b67b4b1 | 2008-10-27 22:30:53 -0400 | [diff] [blame] | 106 | /* Enable auto repeat feature of Linux input subsystem */ |
| 107 | if (pdata->rep) |
| 108 | __set_bit(EV_REP, input->evbit); |
| 109 | |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 110 | ddata->input = input; |
| 111 | |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 112 | for (i = 0; i < pdata->nbuttons; i++) { |
Roman Moravcik | 84767d0 | 2007-05-01 00:39:13 -0400 | [diff] [blame] | 113 | struct gpio_keys_button *button = &pdata->buttons[i]; |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 114 | struct gpio_button_data *bdata = &ddata->data[i]; |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 115 | int irq; |
Roman Moravcik | 84767d0 | 2007-05-01 00:39:13 -0400 | [diff] [blame] | 116 | unsigned int type = button->type ?: EV_KEY; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 117 | |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 118 | bdata->input = input; |
Uwe Kleine-König | 74dd439 | 2008-07-30 10:33:43 -0400 | [diff] [blame] | 119 | bdata->button = button; |
Jani Nikula | ca865a7 | 2009-06-28 22:38:44 -0700 | [diff] [blame] | 120 | setup_timer(&bdata->timer, |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 121 | gpio_keys_timer, (unsigned long)bdata); |
| 122 | INIT_WORK(&bdata->work, gpio_keys_report_event); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 123 | |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 124 | error = gpio_request(button->gpio, button->desc ?: "gpio_keys"); |
| 125 | if (error < 0) { |
Ben Dooks | db19fd8 | 2009-11-10 21:00:35 -0800 | [diff] [blame] | 126 | dev_err(dev, "failed to request GPIO %d, error %d\n", |
| 127 | button->gpio, error); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 128 | goto fail2; |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | error = gpio_direction_input(button->gpio); |
| 132 | if (error < 0) { |
Ben Dooks | db19fd8 | 2009-11-10 21:00:35 -0800 | [diff] [blame] | 133 | dev_err(dev, "failed to configure" |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 134 | " direction for GPIO %d, error %d\n", |
| 135 | button->gpio, error); |
| 136 | gpio_free(button->gpio); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 137 | goto fail2; |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | irq = gpio_to_irq(button->gpio); |
Anti Sullin | 006df30 | 2007-09-26 00:01:03 -0400 | [diff] [blame] | 141 | if (irq < 0) { |
| 142 | error = irq; |
Ben Dooks | db19fd8 | 2009-11-10 21:00:35 -0800 | [diff] [blame] | 143 | dev_err(dev, "Unable to get irq number " |
| 144 | "for GPIO %d, error %d\n", |
Anti Sullin | 006df30 | 2007-09-26 00:01:03 -0400 | [diff] [blame] | 145 | button->gpio, error); |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 146 | gpio_free(button->gpio); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 147 | goto fail2; |
Anti Sullin | 006df30 | 2007-09-26 00:01:03 -0400 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | error = request_irq(irq, gpio_keys_isr, |
Dmitry Eremin-Solenikov | 558a5e2 | 2009-11-02 22:04:18 -0800 | [diff] [blame] | 151 | IRQF_SHARED | |
Dmitry Torokhov | 64e8563 | 2009-04-18 18:45:17 -0700 | [diff] [blame] | 152 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
Anti Sullin | 006df30 | 2007-09-26 00:01:03 -0400 | [diff] [blame] | 153 | button->desc ? button->desc : "gpio_keys", |
Uwe Kleine-König | 57ffe9d | 2008-08-08 12:14:34 -0400 | [diff] [blame] | 154 | bdata); |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 155 | if (error) { |
Ben Dooks | db19fd8 | 2009-11-10 21:00:35 -0800 | [diff] [blame] | 156 | dev_err(dev, "Unable to claim irq %d; error %d\n", |
Philipp Zabel | 0d98f6b | 2007-02-18 01:40:46 -0500 | [diff] [blame] | 157 | irq, error); |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 158 | gpio_free(button->gpio); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 159 | goto fail2; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 160 | } |
Roman Moravcik | 84767d0 | 2007-05-01 00:39:13 -0400 | [diff] [blame] | 161 | |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 162 | if (button->wakeup) |
| 163 | wakeup = 1; |
| 164 | |
Roman Moravcik | 84767d0 | 2007-05-01 00:39:13 -0400 | [diff] [blame] | 165 | input_set_capability(input, type, button->code); |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | error = input_register_device(input); |
| 169 | if (error) { |
Ben Dooks | db19fd8 | 2009-11-10 21:00:35 -0800 | [diff] [blame] | 170 | dev_err(dev, "Unable to register input device, " |
Anti Sullin | 006df30 | 2007-09-26 00:01:03 -0400 | [diff] [blame] | 171 | "error: %d\n", error); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 172 | goto fail2; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 173 | } |
| 174 | |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 175 | device_init_wakeup(&pdev->dev, wakeup); |
| 176 | |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 177 | return 0; |
| 178 | |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 179 | fail2: |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 180 | while (--i >= 0) { |
Uwe Kleine-König | 57ffe9d | 2008-08-08 12:14:34 -0400 | [diff] [blame] | 181 | free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); |
Jani Nikula | ca865a7 | 2009-06-28 22:38:44 -0700 | [diff] [blame] | 182 | if (pdata->buttons[i].debounce_interval) |
| 183 | del_timer_sync(&ddata->data[i].timer); |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 184 | cancel_work_sync(&ddata->data[i].work); |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 185 | gpio_free(pdata->buttons[i].gpio); |
| 186 | } |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 187 | |
Anti Sullin | 006df30 | 2007-09-26 00:01:03 -0400 | [diff] [blame] | 188 | platform_set_drvdata(pdev, NULL); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 189 | fail1: |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 190 | input_free_device(input); |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 191 | kfree(ddata); |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 192 | |
| 193 | return error; |
| 194 | } |
| 195 | |
| 196 | static int __devexit gpio_keys_remove(struct platform_device *pdev) |
| 197 | { |
| 198 | struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; |
Dmitry Baryshkov | a33466e | 2008-05-07 16:30:15 -0400 | [diff] [blame] | 199 | struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); |
| 200 | struct input_dev *input = ddata->input; |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 201 | int i; |
| 202 | |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 203 | device_init_wakeup(&pdev->dev, 0); |
| 204 | |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 205 | for (i = 0; i < pdata->nbuttons; i++) { |
Philipp Zabel | 0d98f6b | 2007-02-18 01:40:46 -0500 | [diff] [blame] | 206 | int irq = gpio_to_irq(pdata->buttons[i].gpio); |
Uwe Kleine-König | 57ffe9d | 2008-08-08 12:14:34 -0400 | [diff] [blame] | 207 | free_irq(irq, &ddata->data[i]); |
Jani Nikula | ca865a7 | 2009-06-28 22:38:44 -0700 | [diff] [blame] | 208 | if (pdata->buttons[i].debounce_interval) |
| 209 | del_timer_sync(&ddata->data[i].timer); |
Jani Nikula | da0d03f | 2009-06-28 22:38:56 -0700 | [diff] [blame] | 210 | cancel_work_sync(&ddata->data[i].work); |
Herbert Valerio Riedel | 6a2e391 | 2007-11-21 14:42:33 -0500 | [diff] [blame] | 211 | gpio_free(pdata->buttons[i].gpio); |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | input_unregister_device(input); |
| 215 | |
| 216 | return 0; |
| 217 | } |
| 218 | |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 219 | |
| 220 | #ifdef CONFIG_PM |
Mike Rapoport | ae78e0e | 2009-07-22 23:02:54 -0700 | [diff] [blame] | 221 | static int gpio_keys_suspend(struct device *dev) |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 222 | { |
Mike Rapoport | ae78e0e | 2009-07-22 23:02:54 -0700 | [diff] [blame] | 223 | struct platform_device *pdev = to_platform_device(dev); |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 224 | struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; |
| 225 | int i; |
| 226 | |
| 227 | if (device_may_wakeup(&pdev->dev)) { |
| 228 | for (i = 0; i < pdata->nbuttons; i++) { |
| 229 | struct gpio_keys_button *button = &pdata->buttons[i]; |
| 230 | if (button->wakeup) { |
| 231 | int irq = gpio_to_irq(button->gpio); |
| 232 | enable_irq_wake(irq); |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | return 0; |
| 238 | } |
| 239 | |
Mike Rapoport | ae78e0e | 2009-07-22 23:02:54 -0700 | [diff] [blame] | 240 | static int gpio_keys_resume(struct device *dev) |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 241 | { |
Mike Rapoport | ae78e0e | 2009-07-22 23:02:54 -0700 | [diff] [blame] | 242 | struct platform_device *pdev = to_platform_device(dev); |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 243 | struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; |
| 244 | int i; |
| 245 | |
| 246 | if (device_may_wakeup(&pdev->dev)) { |
| 247 | for (i = 0; i < pdata->nbuttons; i++) { |
| 248 | struct gpio_keys_button *button = &pdata->buttons[i]; |
| 249 | if (button->wakeup) { |
| 250 | int irq = gpio_to_irq(button->gpio); |
| 251 | disable_irq_wake(irq); |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | return 0; |
| 257 | } |
Mike Rapoport | ae78e0e | 2009-07-22 23:02:54 -0700 | [diff] [blame] | 258 | |
| 259 | static const struct dev_pm_ops gpio_keys_pm_ops = { |
| 260 | .suspend = gpio_keys_suspend, |
| 261 | .resume = gpio_keys_resume, |
| 262 | }; |
Anti Sullin | e15b021 | 2007-09-26 00:01:17 -0400 | [diff] [blame] | 263 | #endif |
| 264 | |
Uwe Kleine-König | 9b07044 | 2008-07-30 10:34:02 -0400 | [diff] [blame] | 265 | static struct platform_driver gpio_keys_device_driver = { |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 266 | .probe = gpio_keys_probe, |
| 267 | .remove = __devexit_p(gpio_keys_remove), |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 268 | .driver = { |
| 269 | .name = "gpio-keys", |
Kay Sievers | d7b5247 | 2008-04-18 00:24:42 -0400 | [diff] [blame] | 270 | .owner = THIS_MODULE, |
Mike Rapoport | ae78e0e | 2009-07-22 23:02:54 -0700 | [diff] [blame] | 271 | #ifdef CONFIG_PM |
| 272 | .pm = &gpio_keys_pm_ops, |
| 273 | #endif |
Phil Blundell | 78a56aa | 2007-01-18 00:44:09 -0500 | [diff] [blame] | 274 | } |
| 275 | }; |
| 276 | |
| 277 | static int __init gpio_keys_init(void) |
| 278 | { |
| 279 | return platform_driver_register(&gpio_keys_device_driver); |
| 280 | } |
| 281 | |
| 282 | static void __exit gpio_keys_exit(void) |
| 283 | { |
| 284 | platform_driver_unregister(&gpio_keys_device_driver); |
| 285 | } |
| 286 | |
| 287 | module_init(gpio_keys_init); |
| 288 | module_exit(gpio_keys_exit); |
| 289 | |
| 290 | MODULE_LICENSE("GPL"); |
| 291 | MODULE_AUTHOR("Phil Blundell <pb@handhelds.org>"); |
| 292 | MODULE_DESCRIPTION("Keyboard driver for CPU GPIOs"); |
Kay Sievers | d7b5247 | 2008-04-18 00:24:42 -0400 | [diff] [blame] | 293 | MODULE_ALIAS("platform:gpio-keys"); |