adm5120: remove 2.6.32 support
[openwrt/staging/dedeckeh.git] / target / linux / adm5120 / patches-3.3 / a04-use-gpio-keys-polled-driver.patch
1 --- a/arch/mips/adm5120/common/platform.c
2 +++ b/arch/mips/adm5120/common/platform.c
3 @@ -245,31 +245,44 @@ void __init adm5120_add_device_uart(unsi
4 /*
5 * GPIO buttons
6 */
7 -#define ADM5120_BUTTON_INTERVAL 20
8 -struct gpio_buttons_platform_data adm5120_gpio_buttons_data = {
9 - .poll_interval = ADM5120_BUTTON_INTERVAL,
10 -};
11 -
12 -struct platform_device adm5120_gpio_buttons_device = {
13 - .name = "gpio-buttons",
14 - .id = -1,
15 - .dev.platform_data = &adm5120_gpio_buttons_data,
16 -};
17 -
18 -void __init adm5120_add_device_gpio_buttons(unsigned nbuttons,
19 - struct gpio_button *buttons)
20 +void __init adm5120_register_gpio_buttons(int id,
21 + unsigned poll_interval,
22 + unsigned nbuttons,
23 + struct gpio_keys_button *buttons)
24 {
25 - struct gpio_button *p;
26 + struct platform_device *pdev;
27 + struct gpio_keys_platform_data pdata;
28 + struct gpio_keys_button *p;
29 + int err;
30
31 - p = kmalloc(nbuttons * sizeof(*p), GFP_KERNEL);
32 + p = kmemdup(buttons, nbuttons * sizeof(*p), GFP_KERNEL);
33 if (!p)
34 return;
35
36 - memcpy(p, buttons, nbuttons * sizeof(*p));
37 - adm5120_gpio_buttons_data.nbuttons = nbuttons;
38 - adm5120_gpio_buttons_data.buttons = p;
39 + pdev = platform_device_alloc("gpio-keys-polled", id);
40 + if (!pdev)
41 + goto err_free_buttons;
42 +
43 + memset(&pdata, 0, sizeof(pdata));
44 + pdata.poll_interval = poll_interval;
45 + pdata.nbuttons = nbuttons;
46 + pdata.buttons = p;
47 +
48 + err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
49 + if (err)
50 + goto err_put_pdev;
51 +
52 + err = platform_device_add(pdev);
53 + if (err)
54 + goto err_put_pdev;
55 +
56 + return;
57 +
58 +err_put_pdev:
59 + platform_device_put(pdev);
60
61 - platform_device_register(&adm5120_gpio_buttons_device);
62 +err_free_buttons:
63 + kfree(p);
64 }
65
66 /*
67 --- a/arch/mips/include/asm/mach-adm5120/adm5120_platform.h
68 +++ b/arch/mips/include/asm/mach-adm5120/adm5120_platform.h
69 @@ -20,7 +20,8 @@
70 #include <linux/mtd/map.h>
71 #include <linux/mtd/partitions.h>
72 #include <linux/mtd/nand.h>
73 -#include <linux/gpio_buttons.h>
74 +#include <linux/input.h>
75 +#include <linux/gpio_keys.h>
76 #include <linux/amba/bus.h>
77 #include <linux/amba/serial.h>
78
79 @@ -66,8 +67,10 @@ extern void adm5120_add_device_uart(unsi
80 extern void adm5120_add_device_nand(struct platform_nand_data *pdata) __init;
81 extern void adm5120_add_device_switch(unsigned num_ports, u8 *vlan_map) __init;
82 extern void adm5120_add_device_gpio(u32 disable_mask) __init;
83 -extern void adm5120_add_device_gpio_buttons(unsigned nbuttons,
84 - struct gpio_button *buttons) __init;
85 +extern void adm5120_register_gpio_buttons(int id,
86 + unsigned poll_interval,
87 + unsigned nbuttons,
88 + struct gpio_keys_button *buttons);
89
90 #define GPIO_LED_DEF(g, n, t, a) { \
91 .name = (n), \
92 --- a/arch/mips/adm5120/compex/wp54.c
93 +++ b/arch/mips/adm5120/compex/wp54.c
94 @@ -11,6 +11,9 @@
95
96 #include "compex.h"
97
98 +#define WP54_KEYS_POLL_INTERVAL 20
99 +#define WP54_KEYS_DEBOUNCE_INTERVAL (3 * WP54_KEYS_POLL_INTERVAL)
100 +
101 static struct mtd_partition wp54g_wrt_partitions[] = {
102 {
103 .name = "cfe",
104 @@ -32,12 +35,12 @@ static struct adm5120_pci_irq wp54_pci_i
105 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
106 };
107
108 -static struct gpio_button wp54_gpio_buttons[] __initdata = {
109 +static struct gpio_keys_button wp54_gpio_buttons[] __initdata = {
110 {
111 .desc = "reset_button",
112 .type = EV_KEY,
113 - .code = BTN_0,
114 - .threshold = 5,
115 + .code = KEY_RESTART,
116 + .debounce_interval = WP54_KEYS_DEBOUNCE_INTERVAL,
117 .gpio = ADM5120_GPIO_PIN4,
118 }
119 };
120 @@ -69,8 +72,9 @@ static void __init wp54_setup(void)
121 adm5120_board_reset = wp54_reset;
122
123 adm5120_add_device_switch(2, wp54_vlans);
124 - adm5120_add_device_gpio_buttons(ARRAY_SIZE(wp54_gpio_buttons),
125 - wp54_gpio_buttons);
126 + adm5120_register_gpio_buttons(-1, WP54_KEYS_POLL_INTERVAL,
127 + ARRAY_SIZE(wp54_gpio_buttons),
128 + wp54_gpio_buttons);
129 adm5120_add_device_gpio_leds(ARRAY_SIZE(wp54_gpio_leds),
130 wp54_gpio_leds);
131
132 --- a/arch/mips/adm5120/mikrotik/rb-1xx.c
133 +++ b/arch/mips/adm5120/mikrotik/rb-1xx.c
134 @@ -19,6 +19,9 @@
135
136 #define RB1XX_NAND_CHIP_DELAY 25
137
138 +#define RB1XX_KEYS_POLL_INTERVAL 20
139 +#define RB1XX_KEYS_DEBOUNCE_INTERVAL (3 * RB1XX_KEYS_POLL_INTERVAL)
140 +
141 static struct adm5120_pci_irq rb1xx_pci_irqs[] __initdata = {
142 PCIIRQ(1, 0, 1, ADM5120_IRQ_PCI0),
143 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI1),
144 @@ -85,12 +88,12 @@ struct platform_nand_data rb1xx_nand_dat
145 },
146 };
147
148 -struct gpio_button rb1xx_gpio_buttons[] __initdata = {
149 +struct gpio_keys_button rb1xx_gpio_buttons[] __initdata = {
150 {
151 .desc = "reset_button",
152 .type = EV_KEY,
153 - .code = BTN_0,
154 - .threshold = 5,
155 + .code = KEY_RESTART,
156 + .debounce_interval = RB1XX_KEYS_DEBOUNCE_INTERVAL,
157 .gpio = ADM5120_GPIO_PIN7,
158 }
159 };
160 @@ -138,8 +141,9 @@ void __init rb1xx_generic_setup(void)
161 adm5120_add_device_uart(0);
162 adm5120_add_device_uart(1);
163
164 - adm5120_add_device_gpio_buttons(ARRAY_SIZE(rb1xx_gpio_buttons),
165 - rb1xx_gpio_buttons);
166 + adm5120_register_gpio_buttons(-1, RB1XX_KEYS_POLL_INTERVAL,
167 + ARRAY_SIZE(rb1xx_gpio_buttons),
168 + rb1xx_gpio_buttons);
169
170 rb1xx_add_device_flash();
171 rb1xx_mac_setup();
172 --- a/arch/mips/adm5120/generic/eb-214a.c
173 +++ b/arch/mips/adm5120/generic/eb-214a.c
174 @@ -28,6 +28,9 @@
175 #define EB214A_GPIO_DEV_MASK 0
176 #define EB214A_CONFIG_OFFSET 0x4000
177
178 +#define EB214A_KEYS_POLL_INTERVAL 20
179 +#define EB214A_KEYS_DEBOUNCE_INTERVAL (3 * EB214A_KEYS_POLL_INTERVAL)
180 +
181 static struct mtd_partition eb214a_partitions[] = {
182 {
183 .name = "bootloader",
184 @@ -60,12 +63,12 @@ static struct gpio_led eb214a_gpio_leds[
185 GPIO_LED_INV(ADM5120_GPIO_P3L0, "usb4", NULL),
186 };
187
188 -static struct gpio_button eb214a_gpio_buttons[] __initdata = {
189 +static struct gpio_keys_button eb214a_gpio_buttons[] __initdata = {
190 {
191 .desc = "reset",
192 .type = EV_KEY,
193 - .code = BTN_0,
194 - .threshold = 5,
195 + .code = KEY_RESTART,
196 + .debounce_interval = EB214A_KEYS_DEBOUNCE_INTERVAL,
197 .gpio = ADM5120_GPIO_PIN1,
198 }
199 };
200 @@ -105,8 +108,9 @@ static void __init eb214a_setup(void)
201
202 eb214a_mac_setup();
203
204 - adm5120_add_device_gpio_buttons(ARRAY_SIZE(eb214a_gpio_buttons),
205 - eb214a_gpio_buttons);
206 + adm5120_register_gpio_buttons(-1, EB214A_KEYS_POLL_INTERVAL,
207 + ARRAY_SIZE(eb214a_gpio_buttons),
208 + eb214a_gpio_buttons);
209
210 adm5120_add_device_gpio_leds(ARRAY_SIZE(eb214a_gpio_leds),
211 eb214a_gpio_leds);
212 --- a/arch/mips/adm5120/edimax/br-61xx.c
213 +++ b/arch/mips/adm5120/edimax/br-61xx.c
214 @@ -18,6 +18,9 @@
215 #define BR61XX_CONFIG_OFFSET 0x8000
216 #define BR61XX_CONFIG_SIZE 0x1000
217
218 +#define BR61XX_KEYS_POLL_INTERVAL 20
219 +#define BR61XX_KEYS_DEBOUNCE_INTERVAL (3 * BR61XX_KEYS_POLL_INTERVAL)
220 +
221 static struct mtd_partition br61xx_partitions[] = {
222 {
223 .name = "admboot",
224 @@ -35,12 +38,12 @@ static struct mtd_partition br61xx_parti
225 }
226 };
227
228 -static struct gpio_button br61xx_gpio_buttons[] __initdata = {
229 +static struct gpio_keys_button br61xx_gpio_buttons[] __initdata = {
230 {
231 .desc = "reset_button",
232 .type = EV_KEY,
233 - .code = BTN_0,
234 - .threshold = 5,
235 + .code = KEY_RESTART,
236 + .debounce_interval = BR61XX_KEYS_DEBOUNCE_INTERVAL,
237 .gpio = ADM5120_GPIO_PIN2,
238 }
239 };
240 @@ -76,8 +79,10 @@ void __init br61xx_generic_setup(void)
241 adm5120_add_device_uart(1);
242
243 adm5120_add_device_switch(5, br61xx_vlans);
244 - adm5120_add_device_gpio_buttons(ARRAY_SIZE(br61xx_gpio_buttons),
245 - br61xx_gpio_buttons);
246 +
247 + adm5120_register_gpio_buttons(-1, BR61XX_KEYS_POLL_INTERVAL,
248 + ARRAY_SIZE(br61xx_gpio_buttons),
249 + br61xx_gpio_buttons);
250
251 br61xx_mac_setup();
252 }
253 --- a/arch/mips/adm5120/mikrotik/rb-1xx.h
254 +++ b/arch/mips/adm5120/mikrotik/rb-1xx.h
255 @@ -26,7 +26,7 @@
256 #include <prom/routerboot.h>
257
258 extern struct platform_nand_data rb1xx_nand_data __initdata;
259 -extern struct gpio_button rb1xx_gpio_buttons[] __initdata;
260 +extern struct gpio_keys_button rb1xx_gpio_buttons[] __initdata;
261
262 extern void rb1xx_add_device_flash(void) __init;
263 extern void rb1xx_add_device_nand(void) __init;