| 1 | --- a/arch/mips/lantiq/Makefile |
| 2 | +++ b/arch/mips/lantiq/Makefile |
| 3 | @@ -4,7 +4,7 @@ |
| 4 | # under the terms of the GNU General Public License version 2 as published |
| 5 | # by the Free Software Foundation. |
| 6 | |
| 7 | -obj-y := irq.o setup.o clk.o prom.o devices.o |
| 8 | +obj-y := irq.o setup.o clk.o prom.o devices.o dev-gpio-buttons.o |
| 9 | |
| 10 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
| 11 | |
| 12 | --- /dev/null |
| 13 | +++ b/arch/mips/lantiq/dev-gpio-buttons.c |
| 14 | @@ -0,0 +1,58 @@ |
| 15 | +/* |
| 16 | + * Lantiq GPIO button support |
| 17 | + * |
| 18 | + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org> |
| 19 | + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> |
| 20 | + * |
| 21 | + * This program is free software; you can redistribute it and/or modify it |
| 22 | + * under the terms of the GNU General Public License version 2 as published |
| 23 | + * by the Free Software Foundation. |
| 24 | + */ |
| 25 | + |
| 26 | +#include "linux/init.h" |
| 27 | +#include "linux/slab.h" |
| 28 | +#include <linux/platform_device.h> |
| 29 | + |
| 30 | +#include "dev-gpio-buttons.h" |
| 31 | + |
| 32 | +void __init ltq_register_gpio_keys_polled(int id, |
| 33 | + unsigned poll_interval, |
| 34 | + unsigned nbuttons, |
| 35 | + struct gpio_keys_button *buttons) |
| 36 | +{ |
| 37 | + struct platform_device *pdev; |
| 38 | + struct gpio_keys_platform_data pdata; |
| 39 | + struct gpio_keys_button *p; |
| 40 | + int err; |
| 41 | + |
| 42 | + p = kmalloc(nbuttons * sizeof(*p), GFP_KERNEL); |
| 43 | + if (!p) |
| 44 | + return; |
| 45 | + |
| 46 | + memcpy(p, buttons, nbuttons * sizeof(*p)); |
| 47 | + |
| 48 | + pdev = platform_device_alloc("gpio-keys-polled", id); |
| 49 | + if (!pdev) |
| 50 | + goto err_free_buttons; |
| 51 | + |
| 52 | + memset(&pdata, 0, sizeof(pdata)); |
| 53 | + pdata.poll_interval = poll_interval; |
| 54 | + pdata.nbuttons = nbuttons; |
| 55 | + pdata.buttons = p; |
| 56 | + |
| 57 | + err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); |
| 58 | + if (err) |
| 59 | + goto err_put_pdev; |
| 60 | + |
| 61 | + err = platform_device_add(pdev); |
| 62 | + if (err) |
| 63 | + goto err_put_pdev; |
| 64 | + |
| 65 | + return; |
| 66 | + |
| 67 | +err_put_pdev: |
| 68 | + platform_device_put(pdev); |
| 69 | + |
| 70 | +err_free_buttons: |
| 71 | + kfree(p); |
| 72 | +} |
| 73 | --- /dev/null |
| 74 | +++ b/arch/mips/lantiq/dev-gpio-buttons.h |
| 75 | @@ -0,0 +1,26 @@ |
| 76 | +/* |
| 77 | + * Lantiq GPIO button support |
| 78 | + * |
| 79 | + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org> |
| 80 | + * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> |
| 81 | + * |
| 82 | + * This program is free software; you can redistribute it and/or modify it |
| 83 | + * under the terms of the GNU General Public License version 2 as published |
| 84 | + * by the Free Software Foundation. |
| 85 | + */ |
| 86 | + |
| 87 | +#ifndef _LANTIQ_DEV_GPIO_BUTTONS_H |
| 88 | +#define _LANTIQ_DEV_GPIO_BUTTONS_H |
| 89 | + |
| 90 | +#include <linux/input.h> |
| 91 | +#include <linux/gpio_keys.h> |
| 92 | + |
| 93 | +#define LTQ_KEYS_POLL_INTERVAL 20 /* msecs */ |
| 94 | +#define LTQ_KEYS_DEBOUNCE_INTERVAL (3 * LTQ_KEYS_POLL_INTERVAL) |
| 95 | + |
| 96 | +void ltq_register_gpio_keys_polled(int id, |
| 97 | + unsigned poll_interval, |
| 98 | + unsigned nbuttons, |
| 99 | + struct gpio_keys_button *buttons); |
| 100 | + |
| 101 | +#endif /* _LANTIQ_DEV_GPIO_BUTTONS_H */ |
| 102 | |