1 diff -Nur linux-2.4.30/drivers/net/diag/Makefile linux-2.4.30.openwrt/drivers/net/diag/Makefile
2 --- linux-2.4.30/drivers/net/diag/Makefile 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.4.30.openwrt/drivers/net/diag/Makefile 2005-06-28 11:35:26.000000000 +0200
7 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
11 +MAC_OBJS := diag_led.o
17 +include $(TOPDIR)/Rules.make
18 diff -Nur linux-2.4.30/drivers/net/diag/diag_led.c linux-2.4.30.openwrt/drivers/net/diag/diag_led.c
19 --- linux-2.4.30/drivers/net/diag/diag_led.c 1970-01-01 01:00:00.000000000 +0100
20 +++ linux-2.4.30.openwrt/drivers/net/diag/diag_led.c 2005-06-28 11:35:26.000000000 +0200
23 + * diag_led.c - replacement diag module
25 + * Copyright (C) 2004 Mike Baker,
26 + * Imre Kaloz <kaloz@dune.hu>
28 + * This program is free software; you can redistribute it and/or
29 + * modify it under the terms of the GNU General Public License
30 + * as published by the Free Software Foundation; either version 2
31 + * of the License, or (at your option) any later version.
33 + * This program is distributed in the hope that it will be useful,
34 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 + * GNU General Public License for more details.
38 + * You should have received a copy of the GNU General Public License
39 + * along with this program; if not, write to the Free Software
40 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42 + * $Id: diag_led.c,v 1.5 2005/04/18 09:05:24 mbm Exp $
47 + * 2004/03/28 initial release
48 + * 2004/08/26 asus & buffalo support added
49 + * 2005/03/14 asus wl-500g deluxe and buffalo v2 support added
50 + * 2005/04/13 added licensing informations
51 + * 2005/04/18 base reset polarity off initial readings
54 +#include <linux/module.h>
55 +#include <linux/init.h>
56 +#include <linux/kernel.h>
57 +#include <linux/sysctl.h>
59 +#include <typedefs.h>
63 +extern char * nvram_get(const char *name);
67 +#define DIAG_GPIO (1<<1)
68 +#define DMZ_GPIO (1<<7)
70 +static void set_gpio(uint32 mask, uint32 value) {
71 + sb_gpiocontrol(sbh,mask,0);
72 + sb_gpioouten(sbh,mask,mask);
73 + sb_gpioout(sbh,mask,value);
76 +static void v2_set_diag(u8 state) {
77 + set_gpio(DIAG_GPIO,state);
79 +static void v2_set_dmz(u8 state) {
80 + set_gpio(DMZ_GPIO,state);
84 +#define LED_DIAG 0x13
87 +static void v1_set_diag(u8 state) {
89 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG)=0xFF;
91 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG);
94 +static void v1_set_dmz(u8 state) {
96 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ)=0xFF;
98 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ);
103 +static void ignore(u8 ignored) {};
106 +#define BIT_DMZ 0x01
107 +#define BIT_DIAG 0x04
109 +void (*set_diag)(u8 state);
110 +void (*set_dmz)(u8 state);
112 +static unsigned int diag = 0;
114 +static void diag_change()
116 + set_diag(0xFF); // off
117 + set_dmz(0xFF); // off
119 + if(diag & BIT_DIAG)
120 + set_diag(0x00); // on
122 + set_dmz(0x00); // on
125 +static int proc_diag(ctl_table *table, int write, struct file *filp,
126 + void *buffer, size_t *lenp)
129 + r = proc_dointvec(table, write, filp, buffer, lenp);
137 +static unsigned char reset_gpio = 0;
138 +static unsigned char reset_polarity = 0;
139 +static unsigned int reset = 0;
141 +static int proc_reset(ctl_table *table, int write, struct file *filp,
142 + void *buffer, size_t *lenp)
146 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
147 + sb_gpioouten(sbh,reset_gpio,0);
148 + reset=!(sb_gpioin(sbh)&reset_gpio);
150 + if (reset_polarity) reset=!reset;
155 + return proc_dointvec(table, write, filp, buffer, lenp);
159 +static struct ctl_table_header *diag_sysctl_header;
161 +static ctl_table sys_diag[] = {
166 + maxlen: sizeof(diag),
168 + proc_handler: proc_diag
174 + maxlen: sizeof(reset),
176 + proc_handler: proc_reset
181 +static int __init diag_init()
185 + sbh = sb_kattach();
186 + sb_gpiosetcore(sbh);
188 + board_type = sb_boardtype(sbh);
189 + printk(KERN_INFO "diag boardtype: %08x\n",board_type);
194 + if ((board_type & 0xf00) == 0x400) {
195 + buf=nvram_get("boardtype")?:"";
196 + if (!strcmp(buf,"bcm94710dev")) {
197 + buf=nvram_get("boardnum")?:"";
198 + if (!strcmp(buf,"42")) {
200 + set_diag=v1_set_diag;
201 + set_dmz=v1_set_dmz;
204 + if (!strcmp(buf,"asusX")) {
209 + if (!strcmp(buf,"bcm94710ap")) {
210 + buf=nvram_get("boardnum")?:"";
211 + if (!strcmp(buf,"42")) {
213 + set_dmz=v2_set_dmz;
216 + if (!strcmp(buf,"44")) {
218 + set_dmz=v2_set_dmz;
223 + buf=nvram_get("boardnum")?:"";
224 + if (!strcmp(buf,"42")) {
226 + set_diag=v2_set_diag;
227 + set_dmz=v2_set_dmz;
230 + if (!strcmp(buf,"44")) {
234 + if (!strcmp(buf,"00")) {
238 + if (!strcmp(buf,"45")) {
245 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
246 + sb_gpioouten(sbh,reset_gpio,0);
247 + reset_polarity=!(sb_gpioin(sbh)&reset_gpio);
249 + diag_sysctl_header = register_sysctl_table(sys_diag, 0);
255 +static void __exit diag_exit()
257 + unregister_sysctl_table(diag_sysctl_header);
261 +MODULE_AUTHOR("openwrt.org");
262 +MODULE_LICENSE("GPL");
264 +module_init(diag_init);
265 +module_exit(diag_exit);