xref: /linux/arch/mips/bcm47xx/buttons.c (revision 4e0ae876f77bc01a7e77724dea57b4b82bd53244)
1 // SPDX-License-Identifier: GPL-2.0
2 #include "bcm47xx_private.h"
3 
4 #include <linux/input.h>
5 #include <linux/gpio_keys.h>
6 #include <linux/interrupt.h>
7 #include <bcm47xx_board.h>
8 #include <bcm47xx.h>
9 
10 /**************************************************
11  * Database
12  **************************************************/
13 
14 #define BCM47XX_GPIO_KEY(_gpio, _code)					\
15 	{								\
16 		.code		= _code,				\
17 		.gpio		= _gpio,				\
18 		.active_low	= 1,					\
19 	}
20 
21 #define BCM47XX_GPIO_KEY_H(_gpio, _code)				\
22 	{								\
23 		.code		= _code,				\
24 		.gpio		= _gpio,				\
25 	}
26 
27 /* Asus */
28 
29 static const struct gpio_keys_button
30 bcm47xx_buttons_asus_rtn12[] __initconst = {
31 	BCM47XX_GPIO_KEY(0, KEY_WPS_BUTTON),
32 	BCM47XX_GPIO_KEY(1, KEY_RESTART),
33 	BCM47XX_GPIO_KEY(4, BTN_0), /* Router mode */
34 	BCM47XX_GPIO_KEY(5, BTN_1), /* Repeater mode */
35 	BCM47XX_GPIO_KEY(6, BTN_2), /* AP mode */
36 };
37 
38 static const struct gpio_keys_button
39 bcm47xx_buttons_asus_rtn16[] __initconst = {
40 	BCM47XX_GPIO_KEY(6, KEY_WPS_BUTTON),
41 	BCM47XX_GPIO_KEY(8, KEY_RESTART),
42 };
43 
44 static const struct gpio_keys_button
45 bcm47xx_buttons_asus_rtn66u[] __initconst = {
46 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
47 	BCM47XX_GPIO_KEY(9, KEY_RESTART),
48 };
49 
50 static const struct gpio_keys_button
51 bcm47xx_buttons_asus_wl300g[] __initconst = {
52 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
53 };
54 
55 static const struct gpio_keys_button
56 bcm47xx_buttons_asus_wl320ge[] __initconst = {
57 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
58 };
59 
60 static const struct gpio_keys_button
61 bcm47xx_buttons_asus_wl330ge[] __initconst = {
62 	BCM47XX_GPIO_KEY(2, KEY_RESTART),
63 };
64 
65 static const struct gpio_keys_button
66 bcm47xx_buttons_asus_wl500g[] __initconst = {
67 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
68 };
69 
70 static const struct gpio_keys_button
71 bcm47xx_buttons_asus_wl500gd[] __initconst = {
72 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
73 };
74 
75 static const struct gpio_keys_button
76 bcm47xx_buttons_asus_wl500gpv1[] __initconst = {
77 	BCM47XX_GPIO_KEY(0, KEY_RESTART),
78 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
79 };
80 
81 static const struct gpio_keys_button
82 bcm47xx_buttons_asus_wl500gpv2[] __initconst = {
83 	BCM47XX_GPIO_KEY(2, KEY_RESTART),
84 	BCM47XX_GPIO_KEY(3, KEY_WPS_BUTTON),
85 };
86 
87 static const struct gpio_keys_button
88 bcm47xx_buttons_asus_wl500w[] __initconst = {
89 	BCM47XX_GPIO_KEY_H(6, KEY_RESTART),
90 	BCM47XX_GPIO_KEY_H(7, KEY_WPS_BUTTON),
91 };
92 
93 static const struct gpio_keys_button
94 bcm47xx_buttons_asus_wl520gc[] __initconst = {
95 	BCM47XX_GPIO_KEY(2, KEY_RESTART),
96 	BCM47XX_GPIO_KEY(3, KEY_WPS_BUTTON),
97 };
98 
99 static const struct gpio_keys_button
100 bcm47xx_buttons_asus_wl520gu[] __initconst = {
101 	BCM47XX_GPIO_KEY(2, KEY_RESTART),
102 	BCM47XX_GPIO_KEY(3, KEY_WPS_BUTTON),
103 };
104 
105 static const struct gpio_keys_button
106 bcm47xx_buttons_asus_wl700ge[] __initconst = {
107 	BCM47XX_GPIO_KEY(0, KEY_POWER), /* Hard disk power switch */
108 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON), /* EZSetup */
109 	BCM47XX_GPIO_KEY(6, KEY_COPY), /* Copy data from USB to internal disk */
110 	BCM47XX_GPIO_KEY(7, KEY_RESTART), /* Hard reset */
111 };
112 
113 static const struct gpio_keys_button
114 bcm47xx_buttons_asus_wlhdd[] __initconst = {
115 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
116 };
117 
118 /* Huawei */
119 
120 static const struct gpio_keys_button
121 bcm47xx_buttons_huawei_e970[] __initconst = {
122 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
123 };
124 
125 /* Belkin */
126 
127 static const struct gpio_keys_button
128 bcm47xx_buttons_belkin_f7d4301[] __initconst = {
129 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
130 	BCM47XX_GPIO_KEY(8, KEY_WPS_BUTTON),
131 };
132 
133 /* Buffalo */
134 
135 static const struct gpio_keys_button
136 bcm47xx_buttons_buffalo_whr2_a54g54[] __initconst = {
137 	BCM47XX_GPIO_KEY(4, KEY_RESTART),
138 };
139 
140 static const struct gpio_keys_button
141 bcm47xx_buttons_buffalo_whr_g125[] __initconst = {
142 	BCM47XX_GPIO_KEY(0, KEY_WPS_BUTTON),
143 	BCM47XX_GPIO_KEY(4, KEY_RESTART),
144 	BCM47XX_GPIO_KEY(5, BTN_0), /* Router / AP mode swtich */
145 };
146 
147 static const struct gpio_keys_button
148 bcm47xx_buttons_buffalo_whr_g54s[] __initconst = {
149 	BCM47XX_GPIO_KEY(0, KEY_WPS_BUTTON),
150 	BCM47XX_GPIO_KEY_H(4, KEY_RESTART),
151 	BCM47XX_GPIO_KEY(5, BTN_0), /* Router / AP mode swtich */
152 };
153 
154 static const struct gpio_keys_button
155 bcm47xx_buttons_buffalo_whr_hp_g54[] __initconst = {
156 	BCM47XX_GPIO_KEY(0, KEY_WPS_BUTTON),
157 	BCM47XX_GPIO_KEY(4, KEY_RESTART),
158 	BCM47XX_GPIO_KEY(5, BTN_0), /* Router / AP mode swtich */
159 };
160 
161 static const struct gpio_keys_button
162 bcm47xx_buttons_buffalo_wzr_g300n[] __initconst = {
163 	BCM47XX_GPIO_KEY(4, KEY_RESTART),
164 };
165 
166 static const struct gpio_keys_button
167 bcm47xx_buttons_buffalo_wzr_rs_g54[] __initconst = {
168 	BCM47XX_GPIO_KEY(0, KEY_WPS_BUTTON),
169 	BCM47XX_GPIO_KEY(4, KEY_RESTART),
170 };
171 
172 static const struct gpio_keys_button
173 bcm47xx_buttons_buffalo_wzr_rs_g54hp[] __initconst = {
174 	BCM47XX_GPIO_KEY(0, KEY_WPS_BUTTON),
175 	BCM47XX_GPIO_KEY(4, KEY_RESTART),
176 };
177 
178 /* Dell */
179 
180 static const struct gpio_keys_button
181 bcm47xx_buttons_dell_tm2300[] __initconst = {
182 	BCM47XX_GPIO_KEY(0, KEY_RESTART),
183 };
184 
185 /* D-Link */
186 
187 static const struct gpio_keys_button
188 bcm47xx_buttons_dlink_dir130[] __initconst = {
189 	BCM47XX_GPIO_KEY(3, KEY_RESTART),
190 	BCM47XX_GPIO_KEY(7, KEY_UNKNOWN),
191 };
192 
193 static const struct gpio_keys_button
194 bcm47xx_buttons_dlink_dir330[] __initconst = {
195 	BCM47XX_GPIO_KEY(3, KEY_RESTART),
196 	BCM47XX_GPIO_KEY(7, KEY_UNKNOWN),
197 };
198 
199 /* Linksys */
200 
201 static const struct gpio_keys_button
202 bcm47xx_buttons_linksys_e1000v1[] __initconst = {
203 	BCM47XX_GPIO_KEY(5, KEY_WPS_BUTTON),
204 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
205 };
206 
207 static const struct gpio_keys_button
208 bcm47xx_buttons_linksys_e1000v21[] __initconst = {
209 	BCM47XX_GPIO_KEY(9, KEY_WPS_BUTTON),
210 	BCM47XX_GPIO_KEY(10, KEY_RESTART),
211 };
212 
213 static const struct gpio_keys_button
214 bcm47xx_buttons_linksys_e2000v1[] __initconst = {
215 	BCM47XX_GPIO_KEY(5, KEY_WPS_BUTTON),
216 	BCM47XX_GPIO_KEY(8, KEY_RESTART),
217 };
218 
219 static const struct gpio_keys_button
220 bcm47xx_buttons_linksys_e3000v1[] __initconst = {
221 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
222 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
223 };
224 
225 static const struct gpio_keys_button
226 bcm47xx_buttons_linksys_e3200v1[] __initconst = {
227 	BCM47XX_GPIO_KEY(5, KEY_RESTART),
228 	BCM47XX_GPIO_KEY(8, KEY_WPS_BUTTON),
229 };
230 
231 static const struct gpio_keys_button
232 bcm47xx_buttons_linksys_e4200v1[] __initconst = {
233 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
234 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
235 };
236 
237 static const struct gpio_keys_button
238 bcm47xx_buttons_linksys_wrt150nv1[] __initconst = {
239 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
240 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
241 };
242 
243 static const struct gpio_keys_button
244 bcm47xx_buttons_linksys_wrt150nv11[] __initconst = {
245 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
246 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
247 };
248 
249 static const struct gpio_keys_button
250 bcm47xx_buttons_linksys_wrt160nv1[] __initconst = {
251 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
252 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
253 };
254 
255 static const struct gpio_keys_button
256 bcm47xx_buttons_linksys_wrt160nv3[] __initconst = {
257 	BCM47XX_GPIO_KEY(5, KEY_WPS_BUTTON),
258 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
259 };
260 
261 static const struct gpio_keys_button
262 bcm47xx_buttons_linksys_wrt300n_v1[] __initconst = {
263 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
264 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
265 };
266 
267 static const struct gpio_keys_button
268 bcm47xx_buttons_linksys_wrt300nv11[] __initconst = {
269 	BCM47XX_GPIO_KEY(4, KEY_UNKNOWN),
270 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
271 };
272 
273 static const struct gpio_keys_button
274 bcm47xx_buttons_linksys_wrt310nv1[] __initconst = {
275 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
276 	BCM47XX_GPIO_KEY(8, KEY_UNKNOWN),
277 };
278 
279 static const struct gpio_keys_button
280 bcm47xx_buttons_linksys_wrt54g3gv2[] __initconst = {
281 	BCM47XX_GPIO_KEY(5, KEY_WIMAX),
282 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
283 };
284 
285 static const struct gpio_keys_button
286 bcm47xx_buttons_linksys_wrt54g_generic[] __initconst = {
287 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
288 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
289 };
290 
291 static const struct gpio_keys_button
292 bcm47xx_buttons_linksys_wrt610nv1[] __initconst = {
293 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
294 	BCM47XX_GPIO_KEY(8, KEY_WPS_BUTTON),
295 };
296 
297 static const struct gpio_keys_button
298 bcm47xx_buttons_linksys_wrt610nv2[] __initconst = {
299 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
300 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
301 };
302 
303 static const struct gpio_keys_button
304 bcm47xx_buttons_linksys_wrtsl54gs[] __initconst = {
305 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
306 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
307 };
308 
309 /* Luxul */
310 
311 static const struct gpio_keys_button
312 bcm47xx_buttons_luxul_abr_4400_v1[] = {
313 	BCM47XX_GPIO_KEY(14, KEY_RESTART),
314 };
315 
316 static const struct gpio_keys_button
317 bcm47xx_buttons_luxul_xap_310_v1[] = {
318 	BCM47XX_GPIO_KEY(20, KEY_RESTART),
319 };
320 
321 static const struct gpio_keys_button
322 bcm47xx_buttons_luxul_xap_1210_v1[] = {
323 	BCM47XX_GPIO_KEY(8, KEY_RESTART),
324 };
325 
326 static const struct gpio_keys_button
327 bcm47xx_buttons_luxul_xap_1230_v1[] = {
328 	BCM47XX_GPIO_KEY(8, KEY_RESTART),
329 };
330 
331 static const struct gpio_keys_button
332 bcm47xx_buttons_luxul_xap_1240_v1[] = {
333 	BCM47XX_GPIO_KEY(8, KEY_RESTART),
334 };
335 
336 static const struct gpio_keys_button
337 bcm47xx_buttons_luxul_xap_1500_v1[] = {
338 	BCM47XX_GPIO_KEY(14, KEY_RESTART),
339 };
340 
341 static const struct gpio_keys_button
342 bcm47xx_buttons_luxul_xbr_4400_v1[] = {
343 	BCM47XX_GPIO_KEY(14, KEY_RESTART),
344 };
345 
346 static const struct gpio_keys_button
347 bcm47xx_buttons_luxul_xvw_p30_v1[] = {
348 	BCM47XX_GPIO_KEY(20, KEY_RESTART),
349 };
350 
351 static const struct gpio_keys_button
352 bcm47xx_buttons_luxul_xwr_600_v1[] = {
353 	BCM47XX_GPIO_KEY(8, KEY_RESTART),
354 };
355 
356 static const struct gpio_keys_button
357 bcm47xx_buttons_luxul_xwr_1750_v1[] = {
358 	BCM47XX_GPIO_KEY(14, KEY_RESTART),
359 };
360 
361 /* Microsoft */
362 
363 static const struct gpio_keys_button
364 bcm47xx_buttons_microsoft_nm700[] __initconst = {
365 	BCM47XX_GPIO_KEY(7, KEY_RESTART),
366 };
367 
368 /* Motorola */
369 
370 static const struct gpio_keys_button
371 bcm47xx_buttons_motorola_we800g[] __initconst = {
372 	BCM47XX_GPIO_KEY(0, KEY_RESTART),
373 };
374 
375 static const struct gpio_keys_button
376 bcm47xx_buttons_motorola_wr850gp[] __initconst = {
377 	BCM47XX_GPIO_KEY(5, KEY_RESTART),
378 };
379 
380 static const struct gpio_keys_button
381 bcm47xx_buttons_motorola_wr850gv2v3[] __initconst = {
382 	BCM47XX_GPIO_KEY(5, KEY_RESTART),
383 };
384 
385 /* Netgear */
386 
387 static const struct gpio_keys_button
388 bcm47xx_buttons_netgear_wndr3400v1[] __initconst = {
389 	BCM47XX_GPIO_KEY(4, KEY_RESTART),
390 	BCM47XX_GPIO_KEY(6, KEY_WPS_BUTTON),
391 	BCM47XX_GPIO_KEY(8, KEY_RFKILL),
392 };
393 
394 static const struct gpio_keys_button
395 bcm47xx_buttons_netgear_wndr3400_v3[] __initconst = {
396 	BCM47XX_GPIO_KEY(12, KEY_RESTART),
397 	BCM47XX_GPIO_KEY(23, KEY_WPS_BUTTON),
398 };
399 
400 static const struct gpio_keys_button
401 bcm47xx_buttons_netgear_wndr3700v3[] __initconst = {
402 	BCM47XX_GPIO_KEY(2, KEY_RFKILL),
403 	BCM47XX_GPIO_KEY(3, KEY_RESTART),
404 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
405 };
406 
407 static const struct gpio_keys_button
408 bcm47xx_buttons_netgear_wndr4500v1[] __initconst = {
409 	BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON),
410 	BCM47XX_GPIO_KEY(5, KEY_RFKILL),
411 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
412 };
413 
414 static const struct gpio_keys_button
415 bcm47xx_buttons_netgear_wnr1000_v3[] __initconst = {
416 	BCM47XX_GPIO_KEY(2, KEY_WPS_BUTTON),
417 	BCM47XX_GPIO_KEY(3, KEY_RESTART),
418 };
419 
420 static const struct gpio_keys_button
421 bcm47xx_buttons_netgear_wnr3500lv1[] __initconst = {
422 	BCM47XX_GPIO_KEY(4, KEY_RESTART),
423 	BCM47XX_GPIO_KEY(6, KEY_WPS_BUTTON),
424 };
425 
426 static const struct gpio_keys_button
427 bcm47xx_buttons_netgear_wnr834bv2[] __initconst = {
428 	BCM47XX_GPIO_KEY(6, KEY_RESTART),
429 };
430 
431 /* SimpleTech */
432 
433 static const struct gpio_keys_button
434 bcm47xx_buttons_simpletech_simpleshare[] __initconst = {
435 	BCM47XX_GPIO_KEY(0, KEY_RESTART),
436 };
437 
438 /**************************************************
439  * Init
440  **************************************************/
441 
442 static struct gpio_keys_platform_data bcm47xx_button_pdata;
443 
444 static struct platform_device bcm47xx_buttons_gpio_keys = {
445 	.name = "gpio-keys",
446 	.dev = {
447 		.platform_data = &bcm47xx_button_pdata,
448 	}
449 };
450 
451 /* Copy data from __initconst */
452 static int __init bcm47xx_buttons_copy(const struct gpio_keys_button *buttons,
453 				       size_t nbuttons)
454 {
455 	size_t size = nbuttons * sizeof(*buttons);
456 
457 	bcm47xx_button_pdata.buttons = kmemdup(buttons, size, GFP_KERNEL);
458 	if (!bcm47xx_button_pdata.buttons)
459 		return -ENOMEM;
460 	bcm47xx_button_pdata.nbuttons = nbuttons;
461 
462 	return 0;
463 }
464 
465 #define bcm47xx_copy_bdata(dev_buttons)					\
466 	bcm47xx_buttons_copy(dev_buttons, ARRAY_SIZE(dev_buttons));
467 
468 int __init bcm47xx_buttons_register(void)
469 {
470 	enum bcm47xx_board board = bcm47xx_board_get();
471 	int err;
472 
473 	switch (board) {
474 	case BCM47XX_BOARD_ASUS_RTN12:
475 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_rtn12);
476 		break;
477 	case BCM47XX_BOARD_ASUS_RTN16:
478 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_rtn16);
479 		break;
480 	case BCM47XX_BOARD_ASUS_RTN66U:
481 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_rtn66u);
482 		break;
483 	case BCM47XX_BOARD_ASUS_WL300G:
484 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl300g);
485 		break;
486 	case BCM47XX_BOARD_ASUS_WL320GE:
487 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl320ge);
488 		break;
489 	case BCM47XX_BOARD_ASUS_WL330GE:
490 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl330ge);
491 		break;
492 	case BCM47XX_BOARD_ASUS_WL500G:
493 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500g);
494 		break;
495 	case BCM47XX_BOARD_ASUS_WL500GD:
496 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500gd);
497 		break;
498 	case BCM47XX_BOARD_ASUS_WL500GPV1:
499 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500gpv1);
500 		break;
501 	case BCM47XX_BOARD_ASUS_WL500GPV2:
502 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500gpv2);
503 		break;
504 	case BCM47XX_BOARD_ASUS_WL500W:
505 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500w);
506 		break;
507 	case BCM47XX_BOARD_ASUS_WL520GC:
508 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl520gc);
509 		break;
510 	case BCM47XX_BOARD_ASUS_WL520GU:
511 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl520gu);
512 		break;
513 	case BCM47XX_BOARD_ASUS_WL700GE:
514 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl700ge);
515 		break;
516 	case BCM47XX_BOARD_ASUS_WLHDD:
517 		err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wlhdd);
518 		break;
519 
520 	case BCM47XX_BOARD_BELKIN_F7D3301:
521 	case BCM47XX_BOARD_BELKIN_F7D3302:
522 	case BCM47XX_BOARD_BELKIN_F7D4301:
523 	case BCM47XX_BOARD_BELKIN_F7D4302:
524 	case BCM47XX_BOARD_BELKIN_F7D4401:
525 		err = bcm47xx_copy_bdata(bcm47xx_buttons_belkin_f7d4301);
526 		break;
527 
528 	case BCM47XX_BOARD_BUFFALO_WHR2_A54G54:
529 		err = bcm47xx_copy_bdata(bcm47xx_buttons_buffalo_whr2_a54g54);
530 		break;
531 	case BCM47XX_BOARD_BUFFALO_WHR_G125:
532 		err = bcm47xx_copy_bdata(bcm47xx_buttons_buffalo_whr_g125);
533 		break;
534 	case BCM47XX_BOARD_BUFFALO_WHR_G54S:
535 		err = bcm47xx_copy_bdata(bcm47xx_buttons_buffalo_whr_g54s);
536 		break;
537 	case BCM47XX_BOARD_BUFFALO_WHR_HP_G54:
538 		err = bcm47xx_copy_bdata(bcm47xx_buttons_buffalo_whr_hp_g54);
539 		break;
540 	case BCM47XX_BOARD_BUFFALO_WZR_G300N:
541 		err = bcm47xx_copy_bdata(bcm47xx_buttons_buffalo_wzr_g300n);
542 		break;
543 	case BCM47XX_BOARD_BUFFALO_WZR_RS_G54:
544 		err = bcm47xx_copy_bdata(bcm47xx_buttons_buffalo_wzr_rs_g54);
545 		break;
546 	case BCM47XX_BOARD_BUFFALO_WZR_RS_G54HP:
547 		err = bcm47xx_copy_bdata(bcm47xx_buttons_buffalo_wzr_rs_g54hp);
548 		break;
549 
550 	case BCM47XX_BOARD_DELL_TM2300:
551 		err = bcm47xx_copy_bdata(bcm47xx_buttons_dell_tm2300);
552 		break;
553 
554 	case BCM47XX_BOARD_DLINK_DIR130:
555 		err = bcm47xx_copy_bdata(bcm47xx_buttons_dlink_dir130);
556 		break;
557 	case BCM47XX_BOARD_DLINK_DIR330:
558 		err = bcm47xx_copy_bdata(bcm47xx_buttons_dlink_dir330);
559 		break;
560 
561 	case BCM47XX_BOARD_HUAWEI_E970:
562 		err = bcm47xx_copy_bdata(bcm47xx_buttons_huawei_e970);
563 		break;
564 
565 	case BCM47XX_BOARD_LINKSYS_E1000V1:
566 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_e1000v1);
567 		break;
568 	case BCM47XX_BOARD_LINKSYS_E1000V21:
569 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_e1000v21);
570 		break;
571 	case BCM47XX_BOARD_LINKSYS_E2000V1:
572 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_e2000v1);
573 		break;
574 	case BCM47XX_BOARD_LINKSYS_E3000V1:
575 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_e3000v1);
576 		break;
577 	case BCM47XX_BOARD_LINKSYS_E3200V1:
578 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_e3200v1);
579 		break;
580 	case BCM47XX_BOARD_LINKSYS_E4200V1:
581 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_e4200v1);
582 		break;
583 	case BCM47XX_BOARD_LINKSYS_WRT150NV1:
584 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt150nv1);
585 		break;
586 	case BCM47XX_BOARD_LINKSYS_WRT150NV11:
587 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt150nv11);
588 		break;
589 	case BCM47XX_BOARD_LINKSYS_WRT160NV1:
590 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt160nv1);
591 		break;
592 	case BCM47XX_BOARD_LINKSYS_WRT160NV3:
593 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt160nv3);
594 		break;
595 	case BCM47XX_BOARD_LINKSYS_WRT300N_V1:
596 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt300n_v1);
597 		break;
598 	case BCM47XX_BOARD_LINKSYS_WRT300NV11:
599 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt300nv11);
600 		break;
601 	case BCM47XX_BOARD_LINKSYS_WRT310NV1:
602 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt310nv1);
603 		break;
604 	case BCM47XX_BOARD_LINKSYS_WRT54G3GV2:
605 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt54g3gv2);
606 		break;
607 	case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0101:
608 	case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0467:
609 	case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0708:
610 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt54g_generic);
611 		break;
612 	case BCM47XX_BOARD_LINKSYS_WRT610NV1:
613 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt610nv1);
614 		break;
615 	case BCM47XX_BOARD_LINKSYS_WRT610NV2:
616 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt610nv2);
617 		break;
618 	case BCM47XX_BOARD_LINKSYS_WRTSL54GS:
619 		err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrtsl54gs);
620 		break;
621 
622 	case BCM47XX_BOARD_LUXUL_ABR_4400_V1:
623 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_abr_4400_v1);
624 		break;
625 	case BCM47XX_BOARD_LUXUL_XAP_310_V1:
626 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xap_310_v1);
627 		break;
628 	case BCM47XX_BOARD_LUXUL_XAP_1210_V1:
629 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xap_1210_v1);
630 		break;
631 	case BCM47XX_BOARD_LUXUL_XAP_1230_V1:
632 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xap_1230_v1);
633 		break;
634 	case BCM47XX_BOARD_LUXUL_XAP_1240_V1:
635 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xap_1240_v1);
636 		break;
637 	case BCM47XX_BOARD_LUXUL_XAP_1500_V1:
638 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xap_1500_v1);
639 		break;
640 	case BCM47XX_BOARD_LUXUL_XBR_4400_V1:
641 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xbr_4400_v1);
642 		break;
643 	case BCM47XX_BOARD_LUXUL_XVW_P30_V1:
644 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xvw_p30_v1);
645 		break;
646 	case BCM47XX_BOARD_LUXUL_XWR_600_V1:
647 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xwr_600_v1);
648 		break;
649 	case BCM47XX_BOARD_LUXUL_XWR_1750_V1:
650 		err = bcm47xx_copy_bdata(bcm47xx_buttons_luxul_xwr_1750_v1);
651 		break;
652 
653 	case BCM47XX_BOARD_MICROSOFT_MN700:
654 		err = bcm47xx_copy_bdata(bcm47xx_buttons_microsoft_nm700);
655 		break;
656 
657 	case BCM47XX_BOARD_MOTOROLA_WE800G:
658 		err = bcm47xx_copy_bdata(bcm47xx_buttons_motorola_we800g);
659 		break;
660 	case BCM47XX_BOARD_MOTOROLA_WR850GP:
661 		err = bcm47xx_copy_bdata(bcm47xx_buttons_motorola_wr850gp);
662 		break;
663 	case BCM47XX_BOARD_MOTOROLA_WR850GV2V3:
664 		err = bcm47xx_copy_bdata(bcm47xx_buttons_motorola_wr850gv2v3);
665 		break;
666 
667 	case BCM47XX_BOARD_NETGEAR_WNDR3400V1:
668 		err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wndr3400v1);
669 		break;
670 	case BCM47XX_BOARD_NETGEAR_WNDR3400_V3:
671 		err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wndr3400_v3);
672 		break;
673 	case BCM47XX_BOARD_NETGEAR_WNDR3700V3:
674 		err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wndr3700v3);
675 		break;
676 	case BCM47XX_BOARD_NETGEAR_WNDR4500V1:
677 		err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wndr4500v1);
678 		break;
679 	case BCM47XX_BOARD_NETGEAR_WNR1000_V3:
680 		err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr1000_v3);
681 		break;
682 	case BCM47XX_BOARD_NETGEAR_WNR3500L:
683 		err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr3500lv1);
684 		break;
685 	case BCM47XX_BOARD_NETGEAR_WNR834BV2:
686 		err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr834bv2);
687 		break;
688 
689 	case BCM47XX_BOARD_SIMPLETECH_SIMPLESHARE:
690 		err = bcm47xx_copy_bdata(bcm47xx_buttons_simpletech_simpleshare);
691 		break;
692 
693 	default:
694 		pr_debug("No buttons configuration found for this device\n");
695 		return -ENOTSUPP;
696 	}
697 
698 	if (err)
699 		return -ENOMEM;
700 
701 	err = platform_device_register(&bcm47xx_buttons_gpio_keys);
702 	if (err) {
703 		pr_err("Failed to register platform device: %d\n", err);
704 		return err;
705 	}
706 
707 	return 0;
708 }
709