Linux Audio

Check our new training course

Yocto / OpenEmbedded training

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