2 * diag.c - GPIO interface driver for Broadcom boards
4 * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
5 * Felix Fietkau <nbd@openwrt.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <linux/module.h>
24 #include <linux/pci.h>
25 #include <linux/kmod.h>
26 #include <linux/proc_fs.h>
27 #include <linux/timer.h>
28 #include <linux/version.h>
29 #include <asm/uaccess.h>
31 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
32 #include <linux/kobject.h>
33 #include <linux/workqueue.h>
34 #define hotplug_path uevent_helper
36 #include <linux/tqueue.h>
37 #define INIT_WORK INIT_TQUEUE
38 #define schedule_work schedule_task
39 #define work_struct tq_struct
44 #define getvar(str) (nvram_get(str)?:"")
46 static unsigned int gpiomask = 0;
47 module_param(gpiomask, int, 0644);
105 static void __init wl700ge_init(void) {
108 /* Enables GPIO 3 that controls HDD and led power on ASUS WL-700gE */
109 printk(MODULE_NAME ": Spinning up HDD and enabling leds\n");
110 gpio_outen(pin, pin);
111 gpio_control(pin, 0);
114 /* Wait 5s, so the HDD can spin up */
115 set_current_state(TASK_INTERRUPTIBLE);
116 schedule_timeout(HZ * 5);
119 static struct platform_t __initdata platforms[] = {
122 .name = "Linksys WAP54G V1",
124 { .name = "reset", .gpio = 1 << 0 },
127 { .name = "diag", .gpio = 1 << 3 },
128 { .name = "wlan", .gpio = 1 << 4 },
132 .name = "Linksys WAP54G V3",
134 /* FIXME: verify this */
135 { .name = "reset", .gpio = 1 << 7 },
136 { .name = "ses", .gpio = 1 << 0 },
140 { .name = "ses", .gpio = 1 << 1 },
144 .name = "Linksys WRT54G V1.x",
146 { .name = "reset", .gpio = 1 << 6 },
149 { .name = "diag", .gpio = 0x13 | GPIO_TYPE_EXTIF, .polarity = NORMAL },
150 { .name = "dmz", .gpio = 0x12 | GPIO_TYPE_EXTIF, .polarity = NORMAL },
154 .name = "Linksys WRT54G/GS/GL",
156 { .name = "reset", .gpio = 1 << 6 },
157 { .name = "ses", .gpio = 1 << 4 },
160 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
161 { .name = "dmz", .gpio = 1 << 7, .polarity = REVERSE },
162 { .name = "ses_white", .gpio = 1 << 2, .polarity = REVERSE },
163 { .name = "ses_orange", .gpio = 1 << 3, .polarity = REVERSE },
164 { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
168 .name = "Linksys WRTSL54GS",
170 { .name = "reset", .gpio = 1 << 6 },
171 { .name = "ses", .gpio = 1 << 4 },
174 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
175 { .name = "dmz", .gpio = 1 << 0, .polarity = REVERSE },
176 { .name = "ses_white", .gpio = 1 << 5, .polarity = REVERSE },
177 { .name = "ses_orange", .gpio = 1 << 7, .polarity = REVERSE },
181 .name = "Linksys WRT54G3G",
183 { .name = "reset", .gpio = 1 << 6 },
184 { .name = "3g", .gpio = 1 << 4 },
187 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
188 { .name = "dmz", .gpio = 1 << 7, .polarity = REVERSE },
189 { .name = "3g_green", .gpio = 1 << 2, .polarity = NORMAL },
190 { .name = "3g_blue", .gpio = 1 << 3, .polarity = NORMAL },
191 { .name = "3g_blink", .gpio = 1 << 5, .polarity = NORMAL },
195 .name = "Linksys WRT350N",
197 { .name = "reset", .gpio = 1 << 6 },
198 { .name = "ses", .gpio = 1 << 8 },
201 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
202 { .name = "ses", .gpio = 1 << 3, .polarity = REVERSE },
207 .name = "ASUS WL-HDD",
209 { .name = "reset", .gpio = 1 << 6 },
212 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
213 { .name = "usb", .gpio = 1 << 2, .polarity = NORMAL },
217 .name = "ASUS WL-300g",
219 { .name = "reset", .gpio = 1 << 6 },
222 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
226 .name = "ASUS WL-500g",
228 { .name = "reset", .gpio = 1 << 6 },
231 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
235 .name = "ASUS WL-500g Deluxe",
237 { .name = "reset", .gpio = 1 << 6 },
240 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
244 .name = "ASUS WL-500g Premium",
246 { .name = "reset", .gpio = 1 << 0 },
247 { .name = "ses", .gpio = 1 << 4 },
250 { .name = "power", .gpio = 1 << 1, .polarity = REVERSE },
254 .name = "ASUS (unknown, BCM4702)",
256 { .name = "reset", .gpio = 1 << 6 },
259 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
263 .name = "ASUS WL-700gE",
265 { .name = "reset", .gpio = 1 << 7 }, // on back, hardwired, always resets device regardless OS state
266 { .name = "ses", .gpio = 1 << 4 }, // on back, actual name ezsetup
267 { .name = "power", .gpio = 1 << 0 }, // on front
268 { .name = "copy", .gpio = 1 << 6 }, // on front
272 // GPIO that controls power led also enables/disables some essential functions
275 { .name = "power", .gpio = 1 << 3, .polarity = NORMAL }, // actual name power
277 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE }, // actual name ready
279 .platform_init = wl700ge_init,
283 .name = "Buffalo WHR-G54S",
285 { .name = "reset", .gpio = 1 << 4 },
286 { .name = "bridge", .gpio = 1 << 5 },
287 { .name = "ses", .gpio = 1 << 0 },
290 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
291 { .name = "internal", .gpio = 1 << 3, .polarity = REVERSE },
292 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
293 { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
297 .name = "Buffalo WBR2-G54",
300 { .name = "reset", .gpio = 1 << 7 },
303 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
307 .name = "Buffalo WHR-HP-G54",
309 { .name = "reset", .gpio = 1 << 4 },
310 { .name = "bridge", .gpio = 1 << 5 },
311 { .name = "ses", .gpio = 1 << 0 },
314 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
315 { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
316 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
320 .name = "Buffalo WHR2-A54G54",
322 { .name = "reset", .gpio = 1 << 4 },
325 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
329 .name = "Buffalo WLA2-G54L",
332 { .name = "reset", .gpio = 1 << 7 },
335 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
339 .name = "Buffalo WZR-G300N",
341 { .name = "reset", .gpio = 1 << 4 },
344 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
345 { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
346 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
350 .name = "Buffalo WZR-RS-G54",
352 { .name = "ses", .gpio = 1 << 0 },
353 { .name = "reset", .gpio = 1 << 4 },
356 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
357 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
358 { .name = "vpn", .gpio = 1 << 1, .polarity = REVERSE },
362 .name = "Buffalo WZR-RS-G54HP",
364 { .name = "ses", .gpio = 1 << 0 },
365 { .name = "reset", .gpio = 1 << 4 },
368 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
369 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
370 { .name = "vpn", .gpio = 1 << 1, .polarity = REVERSE },
373 [BUFFALO_UNKNOWN] = {
374 .name = "Buffalo (unknown)",
376 { .name = "reset", .gpio = 1 << 7 },
379 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
382 [BUFFALO_UNKNOWN_4710] = {
383 .name = "Buffalo (unknown, BCM4710)",
385 { .name = "reset", .gpio = 1 << 4 },
388 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
393 .name = "Siemens SE505 V1",
395 /* No usable buttons */
398 { .name = "dmz", .gpio = 1 << 4, .polarity = REVERSE },
399 { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
403 .name = "Siemens SE505 V2",
405 /* No usable buttons */
408 { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
409 { .name = "dmz", .gpio = 1 << 0, .polarity = REVERSE },
410 { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
415 .name = "U.S. Robotics USR5461",
417 /* No usable buttons */
420 { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
421 { .name = "printer", .gpio = 1 << 1, .polarity = REVERSE },
426 .name = "Dell TrueMobile 2300",
428 { .name = "reset", .gpio = 1 << 0 },
431 { .name = "wlan", .gpio = 1 << 6, .polarity = REVERSE },
432 { .name = "power", .gpio = 1 << 7, .polarity = REVERSE },
437 .name = "Motorola WE800G",
439 { .name = "reset", .gpio = 1 << 0 },
442 { .name = "power", .gpio = 1 << 4, .polarity = NORMAL },
443 { .name = "diag", .gpio = 1 << 2, .polarity = REVERSE },
444 { .name = "wlan_amber", .gpio = 1 << 1, .polarity = NORMAL },
448 .name = "Motorola WR850G V1",
450 { .name = "reset", .gpio = 1 << 0 },
453 { .name = "power", .gpio = 1 << 4, .polarity = NORMAL },
454 { .name = "diag", .gpio = 1 << 3, .polarity = REVERSE },
455 { .name = "dmz", .gpio = 1 << 6, .polarity = NORMAL },
456 { .name = "wlan_red", .gpio = 1 << 5, .polarity = REVERSE },
457 { .name = "wlan_green", .gpio = 1 << 7, .polarity = REVERSE },
461 .name = "Motorola WR850G V2/V3",
463 { .name = "reset", .gpio = 1 << 5 },
466 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
467 { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
468 { .name = "dmz", .gpio = 1 << 6, .polarity = REVERSE },
469 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
474 .name = "Belkin (unknown)",
475 /* FIXME: verify & add detection */
477 { .name = "reset", .gpio = 1 << 7 },
480 { .name = "power", .gpio = 1 << 5, .polarity = NORMAL },
481 { .name = "wlan", .gpio = 1 << 3, .polarity = NORMAL },
482 { .name = "connected", .gpio = 1 << 0, .polarity = NORMAL },
487 .name = "Netgear WGT634U",
489 { .name = "reset", .gpio = 1 << 2 },
492 { .name = "power", .gpio = 1 << 3, .polarity = REVERSE },
497 .name = "Trendware TEW411BRP+",
499 { /* No usable buttons */ },
502 { .name = "power", .gpio = 1 << 7, .polarity = NORMAL },
503 { .name = "wlan", .gpio = 1 << 1, .polarity = NORMAL },
504 { .name = "bridge", .gpio = 1 << 6, .polarity = NORMAL },
509 static struct platform_t __init *platform_detect(void)
511 char *boardnum, *boardtype, *buf;
513 boardnum = getvar("boardnum");
514 boardtype = getvar("boardtype");
516 if (strncmp(getvar("model_no"), "WL700",5) == 0) {
517 return &platforms[WL700GE]; }
519 if (strncmp(getvar("pmon_ver"), "CFE", 3) == 0) {
520 /* CFE based - newer hardware */
521 if (!strcmp(boardnum, "42")) { /* Linksys */
522 if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "1"))
523 return &platforms[WRT350N];
525 if (!strcmp(boardtype, "0x0101") && !strcmp(getvar("boot_ver"), "v3.6"))
526 return &platforms[WRT54G3G];
528 if (!strcmp(getvar("et1phyaddr"),"5") && !strcmp(getvar("et1mdcport"), "1"))
529 return &platforms[WRTSL54GS];
531 /* default to WRT54G */
532 return &platforms[WRT54G];
535 if (!strcmp(boardnum, "45")) { /* ASUS */
536 if (!strcmp(boardtype,"0x042f"))
537 return &platforms[WL500GP];
539 return &platforms[WL500GD];
542 if (!strcmp(boardnum, "10496"))
543 return &platforms[USR5461];
544 } else { /* PMON based - old stuff */
546 /* Dell TrueMobile 2300 */
547 if (!strcmp(getvar("ModelId"),"WX-5565"))
548 return &platforms[TM2300];
550 if ((simple_strtoul(getvar("GemtekPmonVer"), NULL, 0) == 9) &&
551 (simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 30)) {
552 if (!strncmp(getvar("ModelId"),"WE800G", 6))
553 return &platforms[WE800G];
555 return &platforms[WR850GV1];
557 if (!strncmp(boardtype, "bcm94710dev", 11)) {
558 if (!strcmp(boardnum, "42"))
559 return &platforms[WRT54GV1];
560 if (simple_strtoul(boardnum, NULL, 0) == 2)
561 return &platforms[WAP54GV1];
563 if (!strncmp(getvar("hardware_version"), "WL500-", 6))
564 return &platforms[WL500G];
565 if (!strncmp(getvar("hardware_version"), "WL300-", 6)) {
566 /* Either WL-300g or WL-HDD, do more extensive checks */
567 if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
568 (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 1))
569 return &platforms[WLHDD];
570 if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
571 (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 10))
572 return &platforms[WL300G];
575 /* unknown asus stuff, probably bcm4702 */
576 if (!strncmp(boardnum, "asusX", 5))
577 return &platforms[ASUS_4702];
580 if ((buf = (nvram_get("melco_id") ?: nvram_get("buffalo_id")))) {
581 /* Buffalo hardware, check id for specific hardware matches */
582 if (!strcmp(buf, "29bb0332"))
583 return &platforms[WBR2_G54];
584 if (!strcmp(buf, "29129"))
585 return &platforms[WLA2_G54L];
586 if (!strcmp(buf, "30189"))
587 return &platforms[WHR_HP_G54];
588 if (!strcmp(buf, "30182"))
589 return &platforms[WHR_G54S];
590 if (!strcmp(buf, "290441dd"))
591 return &platforms[WHR2_A54G54];
592 if (!strcmp(buf, "31120"))
593 return &platforms[WZR_G300N];
594 if (!strcmp(buf, "30083"))
595 return &platforms[WZR_RS_G54];
596 if (!strcmp(buf, "30103"))
597 return &platforms[WZR_RS_G54HP];
600 if (buf || !strcmp(boardnum, "00")) {/* probably buffalo */
601 if (!strncmp(boardtype, "bcm94710ap", 10))
602 return &platforms[BUFFALO_UNKNOWN_4710];
604 return &platforms[BUFFALO_UNKNOWN];
607 if (!strcmp(getvar("CFEver"), "MotoWRv203") ||
608 !strcmp(getvar("MOTO_BOARD_TYPE"), "WR_FEM1")) {
610 return &platforms[WR850GV2V3];
613 if (!strcmp(boardnum, "44")) { /* Trendware TEW-411BRP+ */
614 return &platforms[TEW411BRPP];
621 static void register_buttons(struct button_t *b)
624 platform.button_mask |= b->gpio;
626 platform.button_mask &= ~gpiomask;
628 gpio_outen(platform.button_mask, 0);
629 gpio_control(platform.button_mask, 0);
630 platform.button_polarity = gpio_in() & platform.button_mask;
631 gpio_intpolarity(platform.button_mask, platform.button_polarity);
632 gpio_intmask(platform.button_mask, platform.button_mask);
634 gpio_set_irqenable(1, button_handler);
637 static void unregister_buttons(struct button_t *b)
639 gpio_intmask(platform.button_mask, 0);
641 gpio_set_irqenable(0, button_handler);
644 static void hotplug_button(struct event_t *event)
646 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
647 call_usermodehelper (event->argv[0], event->argv, event->envp, 1);
649 call_usermodehelper (event->argv[0], event->argv, event->envp);
654 static irqreturn_t button_handler(int irq, void *dev_id, struct pt_regs *regs)
659 in = gpio_in() & platform.button_mask;
660 gpio_intpolarity(platform.button_mask, in);
661 changed = platform.button_polarity ^ in;
662 platform.button_polarity = in;
664 changed &= ~gpio_outen(0, 0);
666 for (b = platform.buttons; b->name; b++) {
667 struct event_t *event;
669 if (!(b->gpio & changed)) continue;
673 if ((event = (struct event_t *)kmalloc (sizeof(struct event_t), GFP_ATOMIC))) {
675 char *scratch = event->buf;
678 event->argv[i++] = hotplug_path;
679 event->argv[i++] = "button";
683 event->envp[i++] = "HOME=/";
684 event->envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
685 event->envp[i++] = scratch;
686 scratch += sprintf (scratch, "ACTION=%s", b->pressed?"pressed":"released") + 1;
687 event->envp[i++] = scratch;
688 scratch += sprintf (scratch, "BUTTON=%s", b->name) + 1;
689 event->envp[i++] = scratch;
690 scratch += sprintf (scratch, "SEEN=%ld", (jiffies - b->seen)/HZ) + 1;
693 INIT_WORK(&event->wq, (void *)(void *)hotplug_button, (void *)event);
694 schedule_work(&event->wq);
702 static void register_leds(struct led_t *l)
704 struct proc_dir_entry *p;
708 leds = proc_mkdir("led", diag);
712 for(; l->name; l++) {
713 if (l->gpio & gpiomask)
716 if (l->gpio & GPIO_TYPE_EXTIF) {
721 val |= (l->polarity == NORMAL)?0:l->gpio;
724 if ((p = create_proc_entry(l->name, S_IRUSR, leds))) {
725 l->proc.type = PROC_LED;
727 p->data = (void *) &l->proc;
728 p->proc_fops = &diag_proc_fops;
732 gpio_outen(mask, mask);
733 gpio_control(mask, 0);
737 static void unregister_leds(struct led_t *l)
740 remove_proc_entry(l->name, leds);
742 remove_proc_entry("led", diag);
745 static void set_led_extif(struct led_t *led)
747 gpio_set_extif(led->gpio, led->state);
750 static void led_flash(unsigned long dummy) {
755 for (l = platform.leds; l->name; l++) {
757 if (l->gpio & GPIO_TYPE_EXTIF) {
759 l->state = !l->state;
769 u32 val = ~gpio_in();
771 gpio_outen(mask, mask);
772 gpio_control(mask, 0);
775 if (mask || extif_blink) {
776 mod_timer(&led_timer, jiffies + FLASH_TIME);
780 static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos)
783 struct inode *inode = file->f_dentry->d_inode;
784 struct proc_dir_entry *dent = inode->u.generic_ip;
786 struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
791 if ((page = kmalloc(1024, GFP_KERNEL)) == NULL)
794 if (dent->data != NULL) {
795 struct prochandler_t *handler = (struct prochandler_t *) dent->data;
796 switch (handler->type) {
798 struct led_t * led = (struct led_t *) handler->ptr;
800 len = sprintf(page, "f\n");
802 if (led->gpio & GPIO_TYPE_EXTIF) {
803 len = sprintf(page, "%d\n", led->state);
805 u32 in = (gpio_in() & led->gpio ? 1 : 0);
806 u8 p = (led->polarity == NORMAL ? 0 : 1);
807 len = sprintf(page, "%d\n", ((in ^ p) ? 1 : 0));
813 len = sprintf(page, "%s\n", platform.name);
816 len = sprintf(page, "0x%04x\n", gpiomask);
823 len = min_t(int, len - *ppos, count);
824 if (copy_to_user(buf, (page + *ppos), len)) {
837 static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
840 struct inode *inode = file->f_dentry->d_inode;
841 struct proc_dir_entry *dent = inode->u.generic_ip;
843 struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
848 if ((page = kmalloc(count + 1, GFP_KERNEL)) == NULL)
851 if (copy_from_user(page, buf, count)) {
857 if (dent->data != NULL) {
858 struct prochandler_t *handler = (struct prochandler_t *) dent->data;
859 switch (handler->type) {
861 struct led_t *led = (struct led_t *) handler->ptr;
862 int p = (led->polarity == NORMAL ? 0 : 1);
864 if (page[0] == 'f') {
869 if (led->gpio & GPIO_TYPE_EXTIF) {
870 led->state = p ^ ((page[0] == '1') ? 1 : 0);
873 gpio_outen(led->gpio, led->gpio);
874 gpio_control(led->gpio, 0);
875 gpio_out(led->gpio, ((p ^ (page[0] == '1')) ? led->gpio : 0));
881 gpiomask = simple_strtoul(page, NULL, 0);
883 if (platform.buttons) {
884 unregister_buttons(platform.buttons);
885 register_buttons(platform.buttons);
889 unregister_leds(platform.leds);
890 register_leds(platform.leds);
901 static int __init diag_init(void)
903 static struct proc_dir_entry *p;
904 static struct platform_t *detected;
906 detected = platform_detect();
908 printk(MODULE_NAME ": Router model not detected.\n");
911 memcpy(&platform, detected, sizeof(struct platform_t));
913 printk(MODULE_NAME ": Detected '%s'\n", platform.name);
914 if (platform.platform_init != NULL) {
915 platform.platform_init();
918 if (!(diag = proc_mkdir("diag", NULL))) {
919 printk(MODULE_NAME ": proc_mkdir on /proc/diag failed\n");
923 if ((p = create_proc_entry("model", S_IRUSR, diag))) {
924 p->data = (void *) &proc_model;
925 p->proc_fops = &diag_proc_fops;
928 if ((p = create_proc_entry("gpiomask", S_IRUSR | S_IWUSR, diag))) {
929 p->data = (void *) &proc_gpiomask;
930 p->proc_fops = &diag_proc_fops;
933 if (platform.buttons)
934 register_buttons(platform.buttons);
937 register_leds(platform.leds);
942 static void __exit diag_exit(void)
945 del_timer(&led_timer);
947 if (platform.buttons)
948 unregister_buttons(platform.buttons);
951 unregister_leds(platform.leds);
953 remove_proc_entry("model", diag);
954 remove_proc_entry("gpiomask", diag);
955 remove_proc_entry("diag", NULL);
958 module_init(diag_init);
959 module_exit(diag_exit);
961 MODULE_AUTHOR("Mike Baker, Felix Fietkau / OpenWrt.org");
962 MODULE_LICENSE("GPL");