2 * Driver for keys on GPIO lines capable of generating interrupts.
4 * Copyright 2005 Phil Blundell
5 * Copyright 2010, 2011 David Jander <david@protonic.nl>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/module.h>
14 #include <linux/init.h>
16 #include <linux/interrupt.h>
17 #include <linux/irq.h>
18 #include <linux/sched.h>
20 #include <linux/slab.h>
21 #include <linux/sysctl.h>
22 #include <linux/proc_fs.h>
23 #include <linux/delay.h>
24 #include <linux/platform_device.h>
25 #include <linux/input.h>
26 #include <linux/gpio_keys.h>
27 #include <linux/workqueue.h>
28 #include <linux/gpio.h>
29 #include <linux/gpio/consumer.h>
31 #include <linux/of_irq.h>
32 #include <linux/spinlock.h>
34 struct gpio_button_data
{
35 const struct gpio_keys_button
*button
;
36 struct input_dev
*input
;
37 struct gpio_desc
*gpiod
;
41 struct timer_list release_timer
;
42 unsigned int release_delay
; /* in msecs, for IRQ-only buttons */
44 struct delayed_work work
;
45 unsigned int software_debounce
; /* in msecs, for GPIO-driven buttons */
54 struct gpio_keys_drvdata
{
55 const struct gpio_keys_platform_data
*pdata
;
56 struct input_dev
*input
;
57 struct mutex disable_lock
;
58 unsigned short *keymap
;
59 struct gpio_button_data data
[0];
63 * SYSFS interface for enabling/disabling keys and switches:
65 * There are 4 attributes under /sys/devices/platform/gpio-keys/
66 * keys [ro] - bitmap of keys (EV_KEY) which can be
68 * switches [ro] - bitmap of switches (EV_SW) which can be
70 * disabled_keys [rw] - bitmap of keys currently disabled
71 * disabled_switches [rw] - bitmap of switches currently disabled
73 * Userland can change these values and hence disable event generation
74 * for each key (or switch). Disabling a key means its interrupt line
77 * For example, if we have following switches set up as gpio-keys:
79 * SW_CAMERA_LENS_COVER = 9
80 * SW_KEYPAD_SLIDE = 10
81 * SW_FRONT_PROXIMITY = 11
82 * This is read from switches:
84 * Next we want to disable proximity (11) and dock (5), we write:
86 * to file disabled_switches. Now proximity and dock IRQs are disabled.
87 * This can be verified by reading the file disabled_switches:
89 * If we now want to enable proximity (11) switch we write:
91 * to disabled_switches.
93 * We can disable only those keys which don't allow sharing the irq.
97 * get_n_events_by_type() - returns maximum number of events per @type
98 * @type: type of button (%EV_KEY, %EV_SW)
100 * Return value of this function can be used to allocate bitmap
101 * large enough to hold all bits for given type.
103 static int get_n_events_by_type(int type
)
105 BUG_ON(type
!= EV_SW
&& type
!= EV_KEY
);
107 return (type
== EV_KEY
) ? KEY_CNT
: SW_CNT
;
111 * get_bm_events_by_type() - returns bitmap of supported events per @type
112 * @input: input device from which bitmap is retrieved
113 * @type: type of button (%EV_KEY, %EV_SW)
115 * Return value of this function can be used to allocate bitmap
116 * large enough to hold all bits for given type.
118 static const unsigned long *get_bm_events_by_type(struct input_dev
*dev
,
121 BUG_ON(type
!= EV_SW
&& type
!= EV_KEY
);
123 return (type
== EV_KEY
) ? dev
->keybit
: dev
->swbit
;
127 * gpio_keys_disable_button() - disables given GPIO button
128 * @bdata: button data for button to be disabled
130 * Disables button pointed by @bdata. This is done by masking
131 * IRQ line. After this function is called, button won't generate
132 * input events anymore. Note that one can only disable buttons
133 * that don't share IRQs.
135 * Make sure that @bdata->disable_lock is locked when entering
136 * this function to avoid races when concurrent threads are
137 * disabling buttons at the same time.
139 static void gpio_keys_disable_button(struct gpio_button_data
*bdata
)
141 if (!bdata
->disabled
) {
143 * Disable IRQ and associated timer/work structure.
145 disable_irq(bdata
->irq
);
148 cancel_delayed_work_sync(&bdata
->work
);
150 del_timer_sync(&bdata
->release_timer
);
152 bdata
->disabled
= true;
157 * gpio_keys_enable_button() - enables given GPIO button
158 * @bdata: button data for button to be disabled
160 * Enables given button pointed by @bdata.
162 * Make sure that @bdata->disable_lock is locked when entering
163 * this function to avoid races with concurrent threads trying
164 * to enable the same button at the same time.
166 static void gpio_keys_enable_button(struct gpio_button_data
*bdata
)
168 if (bdata
->disabled
) {
169 enable_irq(bdata
->irq
);
170 bdata
->disabled
= false;
175 * gpio_keys_attr_show_helper() - fill in stringified bitmap of buttons
176 * @ddata: pointer to drvdata
177 * @buf: buffer where stringified bitmap is written
178 * @type: button type (%EV_KEY, %EV_SW)
179 * @only_disabled: does caller want only those buttons that are
180 * currently disabled or all buttons that can be
183 * This function writes buttons that can be disabled to @buf. If
184 * @only_disabled is true, then @buf contains only those buttons
185 * that are currently disabled. Returns 0 on success or negative
188 static ssize_t
gpio_keys_attr_show_helper(struct gpio_keys_drvdata
*ddata
,
189 char *buf
, unsigned int type
,
192 int n_events
= get_n_events_by_type(type
);
197 bits
= kcalloc(BITS_TO_LONGS(n_events
), sizeof(*bits
), GFP_KERNEL
);
201 for (i
= 0; i
< ddata
->pdata
->nbuttons
; i
++) {
202 struct gpio_button_data
*bdata
= &ddata
->data
[i
];
204 if (bdata
->button
->type
!= type
)
207 if (only_disabled
&& !bdata
->disabled
)
210 __set_bit(*bdata
->code
, bits
);
213 ret
= scnprintf(buf
, PAGE_SIZE
- 1, "%*pbl", n_events
, bits
);
223 * gpio_keys_attr_store_helper() - enable/disable buttons based on given bitmap
224 * @ddata: pointer to drvdata
225 * @buf: buffer from userspace that contains stringified bitmap
226 * @type: button type (%EV_KEY, %EV_SW)
228 * This function parses stringified bitmap from @buf and disables/enables
229 * GPIO buttons accordingly. Returns 0 on success and negative error
232 static ssize_t
gpio_keys_attr_store_helper(struct gpio_keys_drvdata
*ddata
,
233 const char *buf
, unsigned int type
)
235 int n_events
= get_n_events_by_type(type
);
236 const unsigned long *bitmap
= get_bm_events_by_type(ddata
->input
, type
);
241 bits
= kcalloc(BITS_TO_LONGS(n_events
), sizeof(*bits
), GFP_KERNEL
);
245 error
= bitmap_parselist(buf
, bits
, n_events
);
250 if (!bitmap_subset(bits
, bitmap
, n_events
)) {
255 for (i
= 0; i
< ddata
->pdata
->nbuttons
; i
++) {
256 struct gpio_button_data
*bdata
= &ddata
->data
[i
];
258 if (bdata
->button
->type
!= type
)
261 if (test_bit(*bdata
->code
, bits
) &&
262 !bdata
->button
->can_disable
) {
268 mutex_lock(&ddata
->disable_lock
);
270 for (i
= 0; i
< ddata
->pdata
->nbuttons
; i
++) {
271 struct gpio_button_data
*bdata
= &ddata
->data
[i
];
273 if (bdata
->button
->type
!= type
)
276 if (test_bit(*bdata
->code
, bits
))
277 gpio_keys_disable_button(bdata
);
279 gpio_keys_enable_button(bdata
);
282 mutex_unlock(&ddata
->disable_lock
);
289 #define ATTR_SHOW_FN(name, type, only_disabled) \
290 static ssize_t gpio_keys_show_##name(struct device *dev, \
291 struct device_attribute *attr, \
294 struct platform_device *pdev = to_platform_device(dev); \
295 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); \
297 return gpio_keys_attr_show_helper(ddata, buf, \
298 type, only_disabled); \
301 ATTR_SHOW_FN(keys
, EV_KEY
, false);
302 ATTR_SHOW_FN(switches
, EV_SW
, false);
303 ATTR_SHOW_FN(disabled_keys
, EV_KEY
, true);
304 ATTR_SHOW_FN(disabled_switches
, EV_SW
, true);
309 * /sys/devices/platform/gpio-keys/keys [ro]
310 * /sys/devices/platform/gpio-keys/switches [ro]
312 static DEVICE_ATTR(keys
, S_IRUGO
, gpio_keys_show_keys
, NULL
);
313 static DEVICE_ATTR(switches
, S_IRUGO
, gpio_keys_show_switches
, NULL
);
315 #define ATTR_STORE_FN(name, type) \
316 static ssize_t gpio_keys_store_##name(struct device *dev, \
317 struct device_attribute *attr, \
321 struct platform_device *pdev = to_platform_device(dev); \
322 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); \
325 error = gpio_keys_attr_store_helper(ddata, buf, type); \
332 ATTR_STORE_FN(disabled_keys
, EV_KEY
);
333 ATTR_STORE_FN(disabled_switches
, EV_SW
);
338 * /sys/devices/platform/gpio-keys/disabled_keys [rw]
339 * /sys/devices/platform/gpio-keys/disables_switches [rw]
341 static DEVICE_ATTR(disabled_keys
, S_IWUSR
| S_IRUGO
,
342 gpio_keys_show_disabled_keys
,
343 gpio_keys_store_disabled_keys
);
344 static DEVICE_ATTR(disabled_switches
, S_IWUSR
| S_IRUGO
,
345 gpio_keys_show_disabled_switches
,
346 gpio_keys_store_disabled_switches
);
348 static struct attribute
*gpio_keys_attrs
[] = {
350 &dev_attr_switches
.attr
,
351 &dev_attr_disabled_keys
.attr
,
352 &dev_attr_disabled_switches
.attr
,
356 static const struct attribute_group gpio_keys_attr_group
= {
357 .attrs
= gpio_keys_attrs
,
360 static void gpio_keys_gpio_report_event(struct gpio_button_data
*bdata
)
362 const struct gpio_keys_button
*button
= bdata
->button
;
363 struct input_dev
*input
= bdata
->input
;
364 unsigned int type
= button
->type
?: EV_KEY
;
367 state
= gpiod_get_value_cansleep(bdata
->gpiod
);
369 dev_err(input
->dev
.parent
,
370 "failed to get gpio state: %d\n", state
);
374 if (type
== EV_ABS
) {
376 input_event(input
, type
, button
->code
, button
->value
);
378 input_event(input
, type
, *bdata
->code
, state
);
383 static void gpio_keys_gpio_work_func(struct work_struct
*work
)
385 struct gpio_button_data
*bdata
=
386 container_of(work
, struct gpio_button_data
, work
.work
);
388 gpio_keys_gpio_report_event(bdata
);
390 if (bdata
->button
->wakeup
)
391 pm_relax(bdata
->input
->dev
.parent
);
394 static irqreturn_t
gpio_keys_gpio_isr(int irq
, void *dev_id
)
396 struct gpio_button_data
*bdata
= dev_id
;
398 BUG_ON(irq
!= bdata
->irq
);
400 if (bdata
->button
->wakeup
) {
401 const struct gpio_keys_button
*button
= bdata
->button
;
403 pm_stay_awake(bdata
->input
->dev
.parent
);
404 if (bdata
->suspended
&&
405 (button
->type
== 0 || button
->type
== EV_KEY
)) {
407 * Simulate wakeup key press in case the key has
408 * already released by the time we got interrupt
411 input_report_key(bdata
->input
, button
->code
, 1);
415 mod_delayed_work(system_wq
,
417 msecs_to_jiffies(bdata
->software_debounce
));
422 static void gpio_keys_irq_timer(struct timer_list
*t
)
424 struct gpio_button_data
*bdata
= from_timer(bdata
, t
, release_timer
);
425 struct input_dev
*input
= bdata
->input
;
428 spin_lock_irqsave(&bdata
->lock
, flags
);
429 if (bdata
->key_pressed
) {
430 input_event(input
, EV_KEY
, *bdata
->code
, 0);
432 bdata
->key_pressed
= false;
434 spin_unlock_irqrestore(&bdata
->lock
, flags
);
437 static irqreturn_t
gpio_keys_irq_isr(int irq
, void *dev_id
)
439 struct gpio_button_data
*bdata
= dev_id
;
440 struct input_dev
*input
= bdata
->input
;
443 BUG_ON(irq
!= bdata
->irq
);
445 spin_lock_irqsave(&bdata
->lock
, flags
);
447 if (!bdata
->key_pressed
) {
448 if (bdata
->button
->wakeup
)
449 pm_wakeup_event(bdata
->input
->dev
.parent
, 0);
451 input_event(input
, EV_KEY
, *bdata
->code
, 1);
454 if (!bdata
->release_delay
) {
455 input_event(input
, EV_KEY
, *bdata
->code
, 0);
460 bdata
->key_pressed
= true;
463 if (bdata
->release_delay
)
464 mod_timer(&bdata
->release_timer
,
465 jiffies
+ msecs_to_jiffies(bdata
->release_delay
));
467 spin_unlock_irqrestore(&bdata
->lock
, flags
);
471 static void gpio_keys_quiesce_key(void *data
)
473 struct gpio_button_data
*bdata
= data
;
476 cancel_delayed_work_sync(&bdata
->work
);
478 del_timer_sync(&bdata
->release_timer
);
481 static int gpio_keys_setup_key(struct platform_device
*pdev
,
482 struct input_dev
*input
,
483 struct gpio_keys_drvdata
*ddata
,
484 const struct gpio_keys_button
*button
,
486 struct fwnode_handle
*child
)
488 const char *desc
= button
->desc
? button
->desc
: "gpio_keys";
489 struct device
*dev
= &pdev
->dev
;
490 struct gpio_button_data
*bdata
= &ddata
->data
[idx
];
492 unsigned long irqflags
;
496 bdata
->input
= input
;
497 bdata
->button
= button
;
498 spin_lock_init(&bdata
->lock
);
501 bdata
->gpiod
= devm_fwnode_get_gpiod_from_child(dev
, NULL
,
505 if (IS_ERR(bdata
->gpiod
)) {
506 error
= PTR_ERR(bdata
->gpiod
);
507 if (error
== -ENOENT
) {
509 * GPIO is optional, we may be dealing with
510 * purely interrupt-driven setup.
514 if (error
!= -EPROBE_DEFER
)
515 dev_err(dev
, "failed to get gpio: %d\n",
520 } else if (gpio_is_valid(button
->gpio
)) {
522 * Legacy GPIO number, so request the GPIO here and
523 * convert it to descriptor.
525 unsigned flags
= GPIOF_IN
;
527 if (button
->active_low
)
528 flags
|= GPIOF_ACTIVE_LOW
;
530 error
= devm_gpio_request_one(dev
, button
->gpio
, flags
, desc
);
532 dev_err(dev
, "Failed to request GPIO %d, error %d\n",
533 button
->gpio
, error
);
537 bdata
->gpiod
= gpio_to_desc(button
->gpio
);
543 if (button
->debounce_interval
) {
544 error
= gpiod_set_debounce(bdata
->gpiod
,
545 button
->debounce_interval
* 1000);
546 /* use timer if gpiolib doesn't provide debounce */
548 bdata
->software_debounce
=
549 button
->debounce_interval
;
553 bdata
->irq
= button
->irq
;
555 irq
= gpiod_to_irq(bdata
->gpiod
);
559 "Unable to get irq number for GPIO %d, error %d\n",
560 button
->gpio
, error
);
566 INIT_DELAYED_WORK(&bdata
->work
, gpio_keys_gpio_work_func
);
568 isr
= gpio_keys_gpio_isr
;
569 irqflags
= IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING
;
573 dev_err(dev
, "Found button without gpio or irq\n");
577 bdata
->irq
= button
->irq
;
579 if (button
->type
&& button
->type
!= EV_KEY
) {
580 dev_err(dev
, "Only EV_KEY allowed for IRQ buttons.\n");
584 bdata
->release_delay
= button
->debounce_interval
;
585 timer_setup(&bdata
->release_timer
, gpio_keys_irq_timer
, 0);
587 isr
= gpio_keys_irq_isr
;
591 bdata
->code
= &ddata
->keymap
[idx
];
592 *bdata
->code
= button
->code
;
593 input_set_capability(input
, button
->type
?: EV_KEY
, *bdata
->code
);
596 * Install custom action to cancel release timer and
599 error
= devm_add_action(dev
, gpio_keys_quiesce_key
, bdata
);
601 dev_err(dev
, "failed to register quiesce action, error: %d\n",
607 * If platform has specified that the button can be disabled,
608 * we don't want it to share the interrupt line.
610 if (!button
->can_disable
)
611 irqflags
|= IRQF_SHARED
;
613 error
= devm_request_any_context_irq(dev
, bdata
->irq
, isr
, irqflags
,
616 dev_err(dev
, "Unable to claim irq %d; error %d\n",
624 static void gpio_keys_report_state(struct gpio_keys_drvdata
*ddata
)
626 struct input_dev
*input
= ddata
->input
;
629 for (i
= 0; i
< ddata
->pdata
->nbuttons
; i
++) {
630 struct gpio_button_data
*bdata
= &ddata
->data
[i
];
632 gpio_keys_gpio_report_event(bdata
);
637 static int gpio_keys_open(struct input_dev
*input
)
639 struct gpio_keys_drvdata
*ddata
= input_get_drvdata(input
);
640 const struct gpio_keys_platform_data
*pdata
= ddata
->pdata
;
644 error
= pdata
->enable(input
->dev
.parent
);
649 /* Report current state of buttons that are connected to GPIOs */
650 gpio_keys_report_state(ddata
);
655 static void gpio_keys_close(struct input_dev
*input
)
657 struct gpio_keys_drvdata
*ddata
= input_get_drvdata(input
);
658 const struct gpio_keys_platform_data
*pdata
= ddata
->pdata
;
661 pdata
->disable(input
->dev
.parent
);
665 * Handlers for alternative sources of platform_data
669 * Translate properties into platform_data
671 static struct gpio_keys_platform_data
*
672 gpio_keys_get_devtree_pdata(struct device
*dev
)
674 struct gpio_keys_platform_data
*pdata
;
675 struct gpio_keys_button
*button
;
676 struct fwnode_handle
*child
;
679 nbuttons
= device_get_child_node_count(dev
);
681 return ERR_PTR(-ENODEV
);
683 pdata
= devm_kzalloc(dev
,
684 sizeof(*pdata
) + nbuttons
* sizeof(*button
),
687 return ERR_PTR(-ENOMEM
);
689 button
= (struct gpio_keys_button
*)(pdata
+ 1);
691 pdata
->buttons
= button
;
692 pdata
->nbuttons
= nbuttons
;
694 pdata
->rep
= device_property_read_bool(dev
, "autorepeat");
696 device_property_read_string(dev
, "label", &pdata
->name
);
698 device_for_each_child_node(dev
, child
) {
699 if (is_of_node(child
))
701 irq_of_parse_and_map(to_of_node(child
), 0);
703 if (fwnode_property_read_u32(child
, "linux,code",
705 dev_err(dev
, "Button without keycode\n");
706 fwnode_handle_put(child
);
707 return ERR_PTR(-EINVAL
);
710 fwnode_property_read_string(child
, "label", &button
->desc
);
712 if (fwnode_property_read_u32(child
, "linux,input-type",
714 button
->type
= EV_KEY
;
717 fwnode_property_read_bool(child
, "wakeup-source") ||
719 fwnode_property_read_bool(child
, "gpio-key,wakeup");
721 button
->can_disable
=
722 fwnode_property_read_bool(child
, "linux,can-disable");
724 if (fwnode_property_read_u32(child
, "debounce-interval",
725 &button
->debounce_interval
))
726 button
->debounce_interval
= 5;
734 static const struct of_device_id gpio_keys_of_match
[] = {
735 { .compatible
= "gpio-keys", },
738 MODULE_DEVICE_TABLE(of
, gpio_keys_of_match
);
740 static int gpio_keys_probe(struct platform_device
*pdev
)
742 struct device
*dev
= &pdev
->dev
;
743 const struct gpio_keys_platform_data
*pdata
= dev_get_platdata(dev
);
744 struct fwnode_handle
*child
= NULL
;
745 struct gpio_keys_drvdata
*ddata
;
746 struct input_dev
*input
;
752 pdata
= gpio_keys_get_devtree_pdata(dev
);
754 return PTR_ERR(pdata
);
757 size
= sizeof(struct gpio_keys_drvdata
) +
758 pdata
->nbuttons
* sizeof(struct gpio_button_data
);
759 ddata
= devm_kzalloc(dev
, size
, GFP_KERNEL
);
761 dev_err(dev
, "failed to allocate state\n");
765 ddata
->keymap
= devm_kcalloc(dev
,
766 pdata
->nbuttons
, sizeof(ddata
->keymap
[0]),
771 input
= devm_input_allocate_device(dev
);
773 dev_err(dev
, "failed to allocate input device\n");
777 ddata
->pdata
= pdata
;
778 ddata
->input
= input
;
779 mutex_init(&ddata
->disable_lock
);
781 platform_set_drvdata(pdev
, ddata
);
782 input_set_drvdata(input
, ddata
);
784 input
->name
= pdata
->name
? : pdev
->name
;
785 input
->phys
= "gpio-keys/input0";
786 input
->dev
.parent
= dev
;
787 input
->open
= gpio_keys_open
;
788 input
->close
= gpio_keys_close
;
790 input
->id
.bustype
= BUS_HOST
;
791 input
->id
.vendor
= 0x0001;
792 input
->id
.product
= 0x0001;
793 input
->id
.version
= 0x0100;
795 input
->keycode
= ddata
->keymap
;
796 input
->keycodesize
= sizeof(ddata
->keymap
[0]);
797 input
->keycodemax
= pdata
->nbuttons
;
799 /* Enable auto repeat feature of Linux input subsystem */
801 __set_bit(EV_REP
, input
->evbit
);
803 for (i
= 0; i
< pdata
->nbuttons
; i
++) {
804 const struct gpio_keys_button
*button
= &pdata
->buttons
[i
];
806 if (!dev_get_platdata(dev
)) {
807 child
= device_get_next_child_node(dev
, child
);
810 "missing child device node for entry %d\n",
816 error
= gpio_keys_setup_key(pdev
, input
, ddata
,
819 fwnode_handle_put(child
);
827 fwnode_handle_put(child
);
829 error
= devm_device_add_group(dev
, &gpio_keys_attr_group
);
831 dev_err(dev
, "Unable to export keys/switches, error: %d\n",
836 error
= input_register_device(input
);
838 dev_err(dev
, "Unable to register input device, error: %d\n",
843 device_init_wakeup(dev
, wakeup
);
848 static int __maybe_unused
gpio_keys_suspend(struct device
*dev
)
850 struct gpio_keys_drvdata
*ddata
= dev_get_drvdata(dev
);
851 struct input_dev
*input
= ddata
->input
;
854 if (device_may_wakeup(dev
)) {
855 for (i
= 0; i
< ddata
->pdata
->nbuttons
; i
++) {
856 struct gpio_button_data
*bdata
= &ddata
->data
[i
];
857 if (bdata
->button
->wakeup
)
858 enable_irq_wake(bdata
->irq
);
859 bdata
->suspended
= true;
862 mutex_lock(&input
->mutex
);
864 gpio_keys_close(input
);
865 mutex_unlock(&input
->mutex
);
871 static int __maybe_unused
gpio_keys_resume(struct device
*dev
)
873 struct gpio_keys_drvdata
*ddata
= dev_get_drvdata(dev
);
874 struct input_dev
*input
= ddata
->input
;
878 if (device_may_wakeup(dev
)) {
879 for (i
= 0; i
< ddata
->pdata
->nbuttons
; i
++) {
880 struct gpio_button_data
*bdata
= &ddata
->data
[i
];
881 if (bdata
->button
->wakeup
)
882 disable_irq_wake(bdata
->irq
);
883 bdata
->suspended
= false;
886 mutex_lock(&input
->mutex
);
888 error
= gpio_keys_open(input
);
889 mutex_unlock(&input
->mutex
);
895 gpio_keys_report_state(ddata
);
899 static SIMPLE_DEV_PM_OPS(gpio_keys_pm_ops
, gpio_keys_suspend
, gpio_keys_resume
);
901 static struct platform_driver gpio_keys_device_driver
= {
902 .probe
= gpio_keys_probe
,
905 .pm
= &gpio_keys_pm_ops
,
906 .of_match_table
= gpio_keys_of_match
,
910 static int __init
gpio_keys_init(void)
912 return platform_driver_register(&gpio_keys_device_driver
);
915 static void __exit
gpio_keys_exit(void)
917 platform_driver_unregister(&gpio_keys_device_driver
);
920 late_initcall(gpio_keys_init
);
921 module_exit(gpio_keys_exit
);
923 MODULE_LICENSE("GPL");
924 MODULE_AUTHOR("Phil Blundell <pb@handhelds.org>");
925 MODULE_DESCRIPTION("Keyboard driver for GPIOs");
926 MODULE_ALIAS("platform:gpio-keys");