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);
106 static void __init wl700ge_init(void) {
109 /* Enables GPIO 3 that controls HDD and led power on ASUS WL-700gE */
110 printk(MODULE_NAME ": Spinning up HDD and enabling leds\n");
111 gpio_outen(pin, pin);
112 gpio_control(pin, 0);
115 /* Wait 5s, so the HDD can spin up */
116 set_current_state(TASK_INTERRUPTIBLE);
117 schedule_timeout(HZ * 5);
120 static struct platform_t __initdata platforms[] = {
123 .name = "Linksys WAP54G V1",
125 { .name = "reset", .gpio = 1 << 0 },
128 { .name = "diag", .gpio = 1 << 3 },
129 { .name = "wlan", .gpio = 1 << 4 },
133 .name = "Linksys WAP54G V3",
135 /* FIXME: verify this */
136 { .name = "reset", .gpio = 1 << 7 },
137 { .name = "ses", .gpio = 1 << 0 },
141 { .name = "ses", .gpio = 1 << 1 },
145 .name = "Linksys WRT54G V1.x",
147 { .name = "reset", .gpio = 1 << 6 },
150 { .name = "diag", .gpio = 0x13 | GPIO_TYPE_EXTIF, .polarity = NORMAL },
151 { .name = "dmz", .gpio = 0x12 | GPIO_TYPE_EXTIF, .polarity = NORMAL },
155 .name = "Linksys WRT54G/GS/GL",
157 { .name = "reset", .gpio = 1 << 6 },
158 { .name = "ses", .gpio = 1 << 4 },
161 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
162 { .name = "dmz", .gpio = 1 << 7, .polarity = REVERSE },
163 { .name = "ses_white", .gpio = 1 << 2, .polarity = REVERSE },
164 { .name = "ses_orange", .gpio = 1 << 3, .polarity = REVERSE },
165 { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
169 .name = "Linksys WRTSL54GS",
171 { .name = "reset", .gpio = 1 << 6 },
172 { .name = "ses", .gpio = 1 << 4 },
175 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
176 { .name = "dmz", .gpio = 1 << 0, .polarity = REVERSE },
177 { .name = "ses_white", .gpio = 1 << 5, .polarity = REVERSE },
178 { .name = "ses_orange", .gpio = 1 << 7, .polarity = REVERSE },
182 .name = "Linksys WRT54G3G",
184 { .name = "reset", .gpio = 1 << 6 },
185 { .name = "3g", .gpio = 1 << 4 },
188 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
189 { .name = "dmz", .gpio = 1 << 7, .polarity = REVERSE },
190 { .name = "3g_green", .gpio = 1 << 2, .polarity = NORMAL },
191 { .name = "3g_blue", .gpio = 1 << 3, .polarity = NORMAL },
192 { .name = "3g_blink", .gpio = 1 << 5, .polarity = NORMAL },
196 .name = "Linksys WRT350N",
198 { .name = "reset", .gpio = 1 << 6 },
199 { .name = "ses", .gpio = 1 << 8 },
202 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
203 { .name = "ses", .gpio = 1 << 3, .polarity = REVERSE },
208 .name = "ASUS WL-HDD",
210 { .name = "reset", .gpio = 1 << 6 },
213 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
214 { .name = "usb", .gpio = 1 << 2, .polarity = NORMAL },
218 .name = "ASUS WL-300g",
220 { .name = "reset", .gpio = 1 << 6 },
223 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
227 .name = "ASUS WL-500g",
229 { .name = "reset", .gpio = 1 << 6 },
232 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
236 .name = "ASUS WL-500g Deluxe",
238 { .name = "reset", .gpio = 1 << 6 },
241 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
245 .name = "ASUS WL-500g Premium",
247 { .name = "reset", .gpio = 1 << 0 },
248 { .name = "ses", .gpio = 1 << 4 },
251 { .name = "power", .gpio = 1 << 1, .polarity = REVERSE },
255 .name = "ASUS WL-500W",
257 { .name = "reset", .gpio = 1 << 6 },
258 { .name = "ses", .gpio = 1 << 7 },
261 { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
265 .name = "ASUS (unknown, BCM4702)",
267 { .name = "reset", .gpio = 1 << 6 },
270 { .name = "power", .gpio = 1 << 0, .polarity = REVERSE },
274 .name = "ASUS WL-700gE",
276 { .name = "reset", .gpio = 1 << 7 }, // on back, hardwired, always resets device regardless OS state
277 { .name = "ses", .gpio = 1 << 4 }, // on back, actual name ezsetup
278 { .name = "power", .gpio = 1 << 0 }, // on front
279 { .name = "copy", .gpio = 1 << 6 }, // on front
283 // GPIO that controls power led also enables/disables some essential functions
286 { .name = "power", .gpio = 1 << 3, .polarity = NORMAL }, // actual name power
288 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE }, // actual name ready
290 .platform_init = wl700ge_init,
294 .name = "Buffalo WHR-G54S",
296 { .name = "reset", .gpio = 1 << 4 },
297 { .name = "bridge", .gpio = 1 << 5 },
298 { .name = "ses", .gpio = 1 << 0 },
301 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
302 { .name = "internal", .gpio = 1 << 3, .polarity = REVERSE },
303 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
304 { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
308 .name = "Buffalo WBR2-G54",
311 { .name = "reset", .gpio = 1 << 7 },
314 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
318 .name = "Buffalo WHR-HP-G54",
320 { .name = "reset", .gpio = 1 << 4 },
321 { .name = "bridge", .gpio = 1 << 5 },
322 { .name = "ses", .gpio = 1 << 0 },
325 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
326 { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
327 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
331 .name = "Buffalo WHR2-A54G54",
333 { .name = "reset", .gpio = 1 << 4 },
336 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
340 .name = "Buffalo WLA2-G54L",
343 { .name = "reset", .gpio = 1 << 7 },
346 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
350 .name = "Buffalo WZR-G300N",
352 { .name = "reset", .gpio = 1 << 4 },
355 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
356 { .name = "bridge", .gpio = 1 << 1, .polarity = REVERSE },
357 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
361 .name = "Buffalo WZR-RS-G54",
363 { .name = "ses", .gpio = 1 << 0 },
364 { .name = "reset", .gpio = 1 << 4 },
367 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
368 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
369 { .name = "vpn", .gpio = 1 << 1, .polarity = REVERSE },
373 .name = "Buffalo WZR-RS-G54HP",
375 { .name = "ses", .gpio = 1 << 0 },
376 { .name = "reset", .gpio = 1 << 4 },
379 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
380 { .name = "ses", .gpio = 1 << 6, .polarity = REVERSE },
381 { .name = "vpn", .gpio = 1 << 1, .polarity = REVERSE },
384 [BUFFALO_UNKNOWN] = {
385 .name = "Buffalo (unknown)",
387 { .name = "reset", .gpio = 1 << 7 },
390 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
393 [BUFFALO_UNKNOWN_4710] = {
394 .name = "Buffalo (unknown, BCM4710)",
396 { .name = "reset", .gpio = 1 << 4 },
399 { .name = "diag", .gpio = 1 << 1, .polarity = REVERSE },
404 .name = "Siemens SE505 V1",
406 /* No usable buttons */
409 { .name = "dmz", .gpio = 1 << 4, .polarity = REVERSE },
410 { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
414 .name = "Siemens SE505 V2",
416 /* No usable buttons */
419 { .name = "power", .gpio = 1 << 5, .polarity = REVERSE },
420 { .name = "dmz", .gpio = 1 << 0, .polarity = REVERSE },
421 { .name = "wlan", .gpio = 1 << 3, .polarity = REVERSE },
426 .name = "U.S. Robotics USR5461",
428 /* No usable buttons */
431 { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
432 { .name = "printer", .gpio = 1 << 1, .polarity = REVERSE },
437 .name = "Dell TrueMobile 2300",
439 { .name = "reset", .gpio = 1 << 0 },
442 { .name = "wlan", .gpio = 1 << 6, .polarity = REVERSE },
443 { .name = "power", .gpio = 1 << 7, .polarity = REVERSE },
448 .name = "Motorola WE800G",
450 { .name = "reset", .gpio = 1 << 0 },
453 { .name = "power", .gpio = 1 << 4, .polarity = NORMAL },
454 { .name = "diag", .gpio = 1 << 2, .polarity = REVERSE },
455 { .name = "wlan_amber", .gpio = 1 << 1, .polarity = NORMAL },
459 .name = "Motorola WR850G V1",
461 { .name = "reset", .gpio = 1 << 0 },
464 { .name = "power", .gpio = 1 << 4, .polarity = NORMAL },
465 { .name = "diag", .gpio = 1 << 3, .polarity = REVERSE },
466 { .name = "dmz", .gpio = 1 << 6, .polarity = NORMAL },
467 { .name = "wlan_red", .gpio = 1 << 5, .polarity = REVERSE },
468 { .name = "wlan_green", .gpio = 1 << 7, .polarity = REVERSE },
472 .name = "Motorola WR850G V2/V3",
474 { .name = "reset", .gpio = 1 << 5 },
477 { .name = "power", .gpio = 1 << 1, .polarity = NORMAL },
478 { .name = "wlan", .gpio = 1 << 0, .polarity = REVERSE },
479 { .name = "dmz", .gpio = 1 << 6, .polarity = REVERSE },
480 { .name = "diag", .gpio = 1 << 7, .polarity = REVERSE },
485 .name = "Belkin (unknown)",
486 /* FIXME: verify & add detection */
488 { .name = "reset", .gpio = 1 << 7 },
491 { .name = "power", .gpio = 1 << 5, .polarity = NORMAL },
492 { .name = "wlan", .gpio = 1 << 3, .polarity = NORMAL },
493 { .name = "connected", .gpio = 1 << 0, .polarity = NORMAL },
498 .name = "Netgear WGT634U",
500 { .name = "reset", .gpio = 1 << 2 },
503 { .name = "power", .gpio = 1 << 3, .polarity = REVERSE },
508 .name = "Trendware TEW411BRP+",
510 { /* No usable buttons */ },
513 { .name = "power", .gpio = 1 << 7, .polarity = NORMAL },
514 { .name = "wlan", .gpio = 1 << 1, .polarity = NORMAL },
515 { .name = "bridge", .gpio = 1 << 6, .polarity = NORMAL },
520 static struct platform_t __init *platform_detect(void)
522 char *boardnum, *boardtype, *buf;
524 boardnum = getvar("boardnum");
525 boardtype = getvar("boardtype");
527 if (strncmp(getvar("model_no"), "WL700",5) == 0) {
528 return &platforms[WL700GE]; }
530 if (strncmp(getvar("pmon_ver"), "CFE", 3) == 0) {
531 /* CFE based - newer hardware */
532 if (!strcmp(boardnum, "42")) { /* Linksys */
533 if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "1"))
534 return &platforms[WRT350N];
536 if (!strcmp(boardtype, "0x0101") && !strcmp(getvar("boot_ver"), "v3.6"))
537 return &platforms[WRT54G3G];
539 if (!strcmp(getvar("et1phyaddr"),"5") && !strcmp(getvar("et1mdcport"), "1"))
540 return &platforms[WRTSL54GS];
542 /* default to WRT54G */
543 return &platforms[WRT54G];
546 if (!strcmp(boardnum, "45")) { /* ASUS */
547 if (!strcmp(boardtype,"0x042f"))
548 return &platforms[WL500GP];
549 else if (!strcmp(boardtype,"0x0472"))
550 return &platforms[WL500W];
552 return &platforms[WL500GD];
555 if (!strcmp(boardnum, "10496"))
556 return &platforms[USR5461];
557 } else { /* PMON based - old stuff */
559 /* Dell TrueMobile 2300 */
560 if (!strcmp(getvar("ModelId"),"WX-5565"))
561 return &platforms[TM2300];
563 if ((simple_strtoul(getvar("GemtekPmonVer"), NULL, 0) == 9) &&
564 (simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 30)) {
565 if (!strncmp(getvar("ModelId"),"WE800G", 6))
566 return &platforms[WE800G];
568 return &platforms[WR850GV1];
570 if (!strncmp(boardtype, "bcm94710dev", 11)) {
571 if (!strcmp(boardnum, "42"))
572 return &platforms[WRT54GV1];
573 if (simple_strtoul(boardnum, NULL, 0) == 2)
574 return &platforms[WAP54GV1];
576 if (!strncmp(getvar("hardware_version"), "WL500-", 6))
577 return &platforms[WL500G];
578 if (!strncmp(getvar("hardware_version"), "WL300-", 6)) {
579 /* Either WL-300g or WL-HDD, do more extensive checks */
580 if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
581 (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 1))
582 return &platforms[WLHDD];
583 if ((simple_strtoul(getvar("et0phyaddr"), NULL, 0) == 0) &&
584 (simple_strtoul(getvar("et1phyaddr"), NULL, 0) == 10))
585 return &platforms[WL300G];
588 /* unknown asus stuff, probably bcm4702 */
589 if (!strncmp(boardnum, "asusX", 5))
590 return &platforms[ASUS_4702];
593 if ((buf = (nvram_get("melco_id") ?: nvram_get("buffalo_id")))) {
594 /* Buffalo hardware, check id for specific hardware matches */
595 if (!strcmp(buf, "29bb0332"))
596 return &platforms[WBR2_G54];
597 if (!strcmp(buf, "29129"))
598 return &platforms[WLA2_G54L];
599 if (!strcmp(buf, "30189"))
600 return &platforms[WHR_HP_G54];
601 if (!strcmp(buf, "30182"))
602 return &platforms[WHR_G54S];
603 if (!strcmp(buf, "290441dd"))
604 return &platforms[WHR2_A54G54];
605 if (!strcmp(buf, "31120"))
606 return &platforms[WZR_G300N];
607 if (!strcmp(buf, "30083"))
608 return &platforms[WZR_RS_G54];
609 if (!strcmp(buf, "30103"))
610 return &platforms[WZR_RS_G54HP];
613 if (buf || !strcmp(boardnum, "00")) {/* probably buffalo */
614 if (!strncmp(boardtype, "bcm94710ap", 10))
615 return &platforms[BUFFALO_UNKNOWN_4710];
617 return &platforms[BUFFALO_UNKNOWN];
620 if (!strcmp(getvar("CFEver"), "MotoWRv203") ||
621 !strcmp(getvar("MOTO_BOARD_TYPE"), "WR_FEM1")) {
623 return &platforms[WR850GV2V3];
626 if (!strcmp(boardnum, "44")) { /* Trendware TEW-411BRP+ */
627 return &platforms[TEW411BRPP];
634 static void register_buttons(struct button_t *b)
637 platform.button_mask |= b->gpio;
639 platform.button_mask &= ~gpiomask;
641 gpio_outen(platform.button_mask, 0);
642 gpio_control(platform.button_mask, 0);
643 platform.button_polarity = gpio_in() & platform.button_mask;
644 gpio_intpolarity(platform.button_mask, platform.button_polarity);
645 gpio_intmask(platform.button_mask, platform.button_mask);
647 gpio_set_irqenable(1, button_handler);
650 static void unregister_buttons(struct button_t *b)
652 gpio_intmask(platform.button_mask, 0);
654 gpio_set_irqenable(0, button_handler);
657 static void hotplug_button(struct event_t *event)
659 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
660 call_usermodehelper (event->argv[0], event->argv, event->envp, 1);
662 call_usermodehelper (event->argv[0], event->argv, event->envp);
667 static irqreturn_t button_handler(int irq, void *dev_id, struct pt_regs *regs)
672 in = gpio_in() & platform.button_mask;
673 gpio_intpolarity(platform.button_mask, in);
674 changed = platform.button_polarity ^ in;
675 platform.button_polarity = in;
677 changed &= ~gpio_outen(0, 0);
679 for (b = platform.buttons; b->name; b++) {
680 struct event_t *event;
682 if (!(b->gpio & changed)) continue;
686 if ((event = (struct event_t *)kmalloc (sizeof(struct event_t), GFP_ATOMIC))) {
688 char *scratch = event->buf;
691 event->argv[i++] = hotplug_path;
692 event->argv[i++] = "button";
696 event->envp[i++] = "HOME=/";
697 event->envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
698 event->envp[i++] = scratch;
699 scratch += sprintf (scratch, "ACTION=%s", b->pressed?"pressed":"released") + 1;
700 event->envp[i++] = scratch;
701 scratch += sprintf (scratch, "BUTTON=%s", b->name) + 1;
702 event->envp[i++] = scratch;
703 scratch += sprintf (scratch, "SEEN=%ld", (jiffies - b->seen)/HZ) + 1;
706 INIT_WORK(&event->wq, (void *)(void *)hotplug_button, (void *)event);
707 schedule_work(&event->wq);
715 static void register_leds(struct led_t *l)
717 struct proc_dir_entry *p;
721 leds = proc_mkdir("led", diag);
725 for(; l->name; l++) {
726 if (l->gpio & gpiomask)
729 if (l->gpio & GPIO_TYPE_EXTIF) {
734 val |= (l->polarity == NORMAL)?0:l->gpio;
737 if ((p = create_proc_entry(l->name, S_IRUSR, leds))) {
738 l->proc.type = PROC_LED;
740 p->data = (void *) &l->proc;
741 p->proc_fops = &diag_proc_fops;
745 gpio_outen(mask, mask);
746 gpio_control(mask, 0);
750 static void unregister_leds(struct led_t *l)
753 remove_proc_entry(l->name, leds);
755 remove_proc_entry("led", diag);
758 static void set_led_extif(struct led_t *led)
760 gpio_set_extif(led->gpio, led->state);
763 static void led_flash(unsigned long dummy) {
768 for (l = platform.leds; l->name; l++) {
770 if (l->gpio & GPIO_TYPE_EXTIF) {
772 l->state = !l->state;
782 u32 val = ~gpio_in();
784 gpio_outen(mask, mask);
785 gpio_control(mask, 0);
788 if (mask || extif_blink) {
789 mod_timer(&led_timer, jiffies + FLASH_TIME);
793 static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos)
796 struct inode *inode = file->f_dentry->d_inode;
797 struct proc_dir_entry *dent = inode->u.generic_ip;
799 struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
804 if ((page = kmalloc(1024, GFP_KERNEL)) == NULL)
807 if (dent->data != NULL) {
808 struct prochandler_t *handler = (struct prochandler_t *) dent->data;
809 switch (handler->type) {
811 struct led_t * led = (struct led_t *) handler->ptr;
813 len = sprintf(page, "f\n");
815 if (led->gpio & GPIO_TYPE_EXTIF) {
816 len = sprintf(page, "%d\n", led->state);
818 u32 in = (gpio_in() & led->gpio ? 1 : 0);
819 u8 p = (led->polarity == NORMAL ? 0 : 1);
820 len = sprintf(page, "%d\n", ((in ^ p) ? 1 : 0));
826 len = sprintf(page, "%s\n", platform.name);
829 len = sprintf(page, "0x%04x\n", gpiomask);
836 len = min_t(int, len - *ppos, count);
837 if (copy_to_user(buf, (page + *ppos), len)) {
850 static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
853 struct inode *inode = file->f_dentry->d_inode;
854 struct proc_dir_entry *dent = inode->u.generic_ip;
856 struct proc_dir_entry *dent = PDE(file->f_dentry->d_inode);
861 if ((page = kmalloc(count + 1, GFP_KERNEL)) == NULL)
864 if (copy_from_user(page, buf, count)) {
870 if (dent->data != NULL) {
871 struct prochandler_t *handler = (struct prochandler_t *) dent->data;
872 switch (handler->type) {
874 struct led_t *led = (struct led_t *) handler->ptr;
875 int p = (led->polarity == NORMAL ? 0 : 1);
877 if (page[0] == 'f') {
882 if (led->gpio & GPIO_TYPE_EXTIF) {
883 led->state = p ^ ((page[0] == '1') ? 1 : 0);
886 gpio_outen(led->gpio, led->gpio);
887 gpio_control(led->gpio, 0);
888 gpio_out(led->gpio, ((p ^ (page[0] == '1')) ? led->gpio : 0));
894 gpiomask = simple_strtoul(page, NULL, 0);
896 if (platform.buttons) {
897 unregister_buttons(platform.buttons);
898 register_buttons(platform.buttons);
902 unregister_leds(platform.leds);
903 register_leds(platform.leds);
914 static int __init diag_init(void)
916 static struct proc_dir_entry *p;
917 static struct platform_t *detected;
919 detected = platform_detect();
921 printk(MODULE_NAME ": Router model not detected.\n");
924 memcpy(&platform, detected, sizeof(struct platform_t));
926 printk(MODULE_NAME ": Detected '%s'\n", platform.name);
927 if (platform.platform_init != NULL) {
928 platform.platform_init();
931 if (!(diag = proc_mkdir("diag", NULL))) {
932 printk(MODULE_NAME ": proc_mkdir on /proc/diag failed\n");
936 if ((p = create_proc_entry("model", S_IRUSR, diag))) {
937 p->data = (void *) &proc_model;
938 p->proc_fops = &diag_proc_fops;
941 if ((p = create_proc_entry("gpiomask", S_IRUSR | S_IWUSR, diag))) {
942 p->data = (void *) &proc_gpiomask;
943 p->proc_fops = &diag_proc_fops;
946 if (platform.buttons)
947 register_buttons(platform.buttons);
950 register_leds(platform.leds);
955 static void __exit diag_exit(void)
958 del_timer(&led_timer);
960 if (platform.buttons)
961 unregister_buttons(platform.buttons);
964 unregister_leds(platform.leds);
966 remove_proc_entry("model", diag);
967 remove_proc_entry("gpiomask", diag);
968 remove_proc_entry("diag", NULL);
971 module_init(diag_init);
972 module_exit(diag_exit);
974 MODULE_AUTHOR("Mike Baker, Felix Fietkau / OpenWrt.org");
975 MODULE_LICENSE("GPL");