1 diff -Nur linux-2.6.12.5/drivers/net/Kconfig linux-2.6.12.5-diag/drivers/net/Kconfig
2 --- linux-2.6.12.5/drivers/net/Kconfig 2005-08-15 02:20:18.000000000 +0200
3 +++ linux-2.6.12.5-diag/drivers/net/Kconfig 2005-09-10 23:08:53.209908656 +0200
5 Instead of 'dummy', the devices will then be called 'dummy0',
9 + tristate "Led driver for Broadcom BCM97xx"
11 + Say m if you like the led to signal status of operation.
14 tristate "Bonding driver support"
16 diff -Nur linux-2.6.12.5/drivers/net/Makefile linux-2.6.12.5-diag/drivers/net/Makefile
17 --- linux-2.6.12.5/drivers/net/Makefile 2005-08-15 02:20:18.000000000 +0200
18 +++ linux-2.6.12.5-diag/drivers/net/Makefile 2005-09-08 17:49:02.249278160 +0200
21 # Makefile for the Linux network (ethercard) device drivers.
23 +obj-$(CONFIG_DIAG_LED) += diag/
25 ifeq ($(CONFIG_ISDN_PPP),y)
26 obj-$(CONFIG_ISDN) += slhc.o
27 diff -Nur linux-2.6.12.5/drivers/net/diag/Makefile linux-2.6.12.5-diag/drivers/net/diag/Makefile
28 --- linux-2.6.12.5/drivers/net/diag/Makefile 1970-01-01 01:00:00.000000000 +0100
29 +++ linux-2.6.12.5-diag/drivers/net/diag/Makefile 2005-09-10 19:45:26.596290216 +0200
33 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
35 +obj-$(CONFIG_DIAG_LED) += diag.o
36 diff -Nur linux-2.6.12.5/drivers/net/diag/diag.c linux-2.6.12.5-diag/drivers/net/diag/diag.c
37 --- linux-2.6.12.5/drivers/net/diag/diag.c 1970-01-01 01:00:00.000000000 +0100
38 +++ linux-2.6.12.5-diag/drivers/net/diag/diag.c 2005-09-10 18:51:02.727849016 +0200
41 + * diag_led.c - replacement diag module
43 + * Copyright (C) 2004 Mike Baker,
44 + * Imre Kaloz <kaloz@dune.hu>
46 + * This program is free software; you can redistribute it and/or
47 + * modify it under the terms of the GNU General Public License
48 + * as published by the Free Software Foundation; either version 2
49 + * of the License, or (at your option) any later version.
51 + * This program is distributed in the hope that it will be useful,
52 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
53 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54 + * GNU General Public License for more details.
56 + * You should have received a copy of the GNU General Public License
57 + * along with this program; if not, write to the Free Software
58 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
65 + * 2004/03/28 initial release
66 + * 2004/08/26 asus & buffalo support added
67 + * 2005/03/14 asus wl-500g deluxe and buffalo v2 support added
68 + * 2005/04/13 added licensing informations
69 + * 2005/04/18 base reset polarity off initial readings
72 +#include <linux/module.h>
73 +#include <linux/init.h>
74 +#include <linux/kernel.h>
75 +#include <linux/sysctl.h>
77 +#include <typedefs.h>
81 +extern char * nvram_get(const char *name);
85 +#define DIAG_GPIO (1<<1)
86 +#define DMZ_GPIO (1<<7)
89 +static void set_gpio(uint32 mask, uint32 value) {
90 + sb_gpiocontrol(sbh,mask,0);
91 + sb_gpioouten(sbh,mask,mask);
92 + sb_gpioout(sbh,mask,value);
95 +static void v2_set_diag(u8 state) {
96 + set_gpio(DIAG_GPIO,state);
98 +static void v2_set_dmz(u8 state) {
99 + set_gpio(DMZ_GPIO,state);
105 +#define LED_DIAG 0x13
106 +#define LED_DMZ 0x12
108 +static void v1_set_diag(u8 state) {
110 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG)=0xFF;
112 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG);
115 +static void v1_set_dmz(u8 state) {
117 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ)=0xFF;
119 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ);
125 +static void ignore(u8 ignored) {};
128 +#define BIT_DMZ 0x01
129 +#define BIT_DIAG 0x04
131 +void (*set_diag)(u8 state);
132 +void (*set_dmz)(u8 state);
134 +static unsigned int diag = 0;
136 +static void diag_change()
138 + set_diag(0xFF); // off
139 + set_dmz(0xFF); // off
141 + if(diag & BIT_DIAG)
142 + set_diag(0x00); // on
144 + set_dmz(0x00); // on
147 +static int proc_diag(ctl_table *table, int write, struct file *filp,
148 + void *buffer, size_t *lenp, loff_t *ppos)
151 + r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
159 +static unsigned char reset_gpio = 0;
160 +static unsigned char reset_polarity = 0;
161 +static unsigned int reset = 0;
163 +static int proc_reset(ctl_table *table, int write, struct file *filp,
164 + void *buffer, size_t *lenp, loff_t *ppos)
168 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
169 + sb_gpioouten(sbh,reset_gpio,0);
170 + reset=!(sb_gpioin(sbh)&reset_gpio);
172 + if (reset_polarity) reset=!reset;
177 + return proc_dointvec(table, write, filp, buffer, lenp, ppos);
181 +static struct ctl_table_header *diag_sysctl_header;
183 +static ctl_table sys_diag[] = {
188 + maxlen: sizeof(diag),
190 + proc_handler: proc_diag
196 + maxlen: sizeof(reset),
198 + proc_handler: proc_reset
203 +static int __init diag_init()
207 + sbh = sb_kattach();
208 + sb_gpiosetcore(sbh);
210 + board_type = sb_boardtype(sbh);
211 + printk(KERN_INFO "diag boardtype: %08x\n",board_type);
217 + buf=nvram_get("boardrev");
218 + if (((board_type & 0xf00) == 0x400) && strcmp(buf,"0x10")) {
219 + buf=nvram_get("boardtype")?:"";
220 + if (!strcmp(buf,"bcm94710dev")) {
221 + buf=nvram_get("boardnum")?:"";
222 + if (!strcmp(buf,"42")) {
224 + set_diag=v1_set_diag;
225 + set_dmz=v1_set_dmz;
228 + if (!strcmp(buf,"asusX")) {
233 + if (!strcmp(buf,"bcm94710ap")) {
234 + buf=nvram_get("boardnum")?:"";
235 + if (!strcmp(buf,"42")) {
237 + set_dmz=v2_set_dmz;
240 + if (!strcmp(buf,"44")) {
242 + set_dmz=v2_set_dmz;
247 + buf=nvram_get("boardnum")?:"";
248 + if (!strcmp(buf,"42")) {
250 + set_diag=v2_set_diag;
251 + set_dmz=v2_set_dmz;
254 + if (!strcmp(buf,"44")) {
258 + if (!strcmp(buf,"00")) {
262 + if (!strcmp(buf,"45")) {
269 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
270 + sb_gpioouten(sbh,reset_gpio,0);
271 + reset_polarity=!(sb_gpioin(sbh)&reset_gpio);
273 + diag_sysctl_header = register_sysctl_table(sys_diag, 0);
279 +static void __exit diag_exit()
281 + unregister_sysctl_table(diag_sysctl_header);
284 +MODULE_AUTHOR("openwrt.org");
285 +MODULE_LICENSE("GPL");
287 +module_init(diag_init);
288 +module_exit(diag_exit);