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