fix bcm47xx patch (remove duplicate flash chip patch)
[openwrt.git] / target / linux / linux-2.4 / patches / brcm / 004-diag_led.patch
1 diff -urN linux-2.4.30.dev/drivers/net/Makefile linux-2.4.30.dev2/drivers/net/Makefile
2 --- linux-2.4.30.dev/drivers/net/Makefile 2005-08-22 01:41:45.930653216 +0200
3 +++ linux-2.4.30.dev2/drivers/net/Makefile 2005-08-22 01:58:04.162939304 +0200
4 @@ -41,6 +41,8 @@
5 obj-$(CONFIG_ISDN) += slhc.o
6 endif
7
8 +subdir-m += diag
9 +
10 subdir-$(CONFIG_HND) += hnd
11 subdir-$(CONFIG_ET) += et
12 subdir-$(CONFIG_WL) += wl
13 diff -urN linux-2.4.30.dev/drivers/net/diag/Makefile linux-2.4.30.dev2/drivers/net/diag/Makefile
14 --- linux-2.4.30.dev/drivers/net/diag/Makefile 1970-01-01 01:00:00.000000000 +0100
15 +++ linux-2.4.30.dev2/drivers/net/diag/Makefile 2005-08-22 00:12:23.655170000 +0200
16 @@ -0,0 +1,13 @@
17 +#$Id: 005-diag_led.patch,v 1.1.2.1 2005/08/22 01:56:06 nbd Exp $
18 +
19 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
20 +
21 +O_TARGET := diag.o
22 +
23 +MAC_OBJS := diag_led.o
24 +
25 +export-objs :=
26 +obj-y := $(MAC_OBJS)
27 +obj-m := $(O_TARGET)
28 +
29 +include $(TOPDIR)/Rules.make
30 diff -urN linux-2.4.30.dev/drivers/net/diag/diag_led.c linux-2.4.30.dev2/drivers/net/diag/diag_led.c
31 --- linux-2.4.30.dev/drivers/net/diag/diag_led.c 1970-01-01 01:00:00.000000000 +0100
32 +++ linux-2.4.30.dev2/drivers/net/diag/diag_led.c 2005-08-22 03:37:58.112053448 +0200
33 @@ -0,0 +1,245 @@
34 +/*
35 + * diag_led.c - replacement diag module
36 + *
37 + * Copyright (C) 2004 Mike Baker,
38 + * Imre Kaloz <kaloz@dune.hu>
39 + *
40 + * This program is free software; you can redistribute it and/or
41 + * modify it under the terms of the GNU General Public License
42 + * as published by the Free Software Foundation; either version 2
43 + * of the License, or (at your option) any later version.
44 + *
45 + * This program is distributed in the hope that it will be useful,
46 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 + * GNU General Public License for more details.
49 + *
50 + * You should have received a copy of the GNU General Public License
51 + * along with this program; if not, write to the Free Software
52 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
53 + *
54 + * $Id: 005-diag_led.patch,v 1.1.2.1 2005/08/22 01:56:06 nbd Exp $
55 + */
56 +
57 +/*
58 + * ChangeLog:
59 + * 2004/03/28 initial release
60 + * 2004/08/26 asus & buffalo support added
61 + * 2005/03/14 asus wl-500g deluxe and buffalo v2 support added
62 + * 2005/04/13 added licensing informations
63 + * 2005/04/18 base reset polarity off initial readings
64 + */
65 +
66 +#include <linux/module.h>
67 +#include <linux/init.h>
68 +#include <linux/kernel.h>
69 +#include <linux/sysctl.h>
70 +#include <asm/io.h>
71 +#include <typedefs.h>
72 +#include <bcmdevs.h>
73 +#include <sbutils.h>
74 +
75 +extern char * nvram_get(const char *name);
76 +static void *sbh;
77 +
78 +// v2.x - - - - -
79 +#define DIAG_GPIO (1<<1)
80 +#define DMZ_GPIO (1<<7)
81 +
82 +static void set_gpio(uint32 mask, uint32 value) {
83 + sb_gpiocontrol(sbh,mask,0);
84 + sb_gpioouten(sbh,mask,mask);
85 + sb_gpioout(sbh,mask,value);
86 +}
87 +
88 +static void v2_set_diag(u8 state) {
89 + set_gpio(DIAG_GPIO,state);
90 +}
91 +static void v2_set_dmz(u8 state) {
92 + set_gpio(DMZ_GPIO,state);
93 +}
94 +
95 +// v1.x - - - - -
96 +#define LED_DIAG 0x13
97 +#define LED_DMZ 0x12
98 +
99 +static void v1_set_diag(u8 state) {
100 + if (!state) {
101 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG)=0xFF;
102 + } else {
103 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG);
104 + }
105 +}
106 +static void v1_set_dmz(u8 state) {
107 + if (!state) {
108 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ)=0xFF;
109 + } else {
110 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ);
111 + }
112 +}
113 +
114 +// - - - - -
115 +static void ignore(u8 ignored) {};
116 +
117 +// - - - - -
118 +#define BIT_DMZ 0x01
119 +#define BIT_DIAG 0x04
120 +
121 +void (*set_diag)(u8 state);
122 +void (*set_dmz)(u8 state);
123 +
124 +static unsigned int diag = 0;
125 +
126 +static void diag_change()
127 +{
128 + set_diag(0xFF); // off
129 + set_dmz(0xFF); // off
130 +
131 + if(diag & BIT_DIAG)
132 + set_diag(0x00); // on
133 + if(diag & BIT_DMZ)
134 + set_dmz(0x00); // on
135 +}
136 +
137 +static int proc_diag(ctl_table *table, int write, struct file *filp,
138 + void *buffer, size_t *lenp)
139 +{
140 + int r;
141 + r = proc_dointvec(table, write, filp, buffer, lenp);
142 + if (write && !r) {
143 + diag_change();
144 + }
145 + return r;
146 +}
147 +
148 +// - - - - -
149 +static unsigned char reset_gpio = 0;
150 +static unsigned char reset_polarity = 0;
151 +static unsigned int reset = 0;
152 +
153 +static int proc_reset(ctl_table *table, int write, struct file *filp,
154 + void *buffer, size_t *lenp)
155 +{
156 +
157 + if (reset_gpio) {
158 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
159 + sb_gpioouten(sbh,reset_gpio,0);
160 + reset=!(sb_gpioin(sbh)&reset_gpio);
161 +
162 + if (reset_polarity) reset=!reset;
163 + } else {
164 + reset=0;
165 + }
166 +
167 + return proc_dointvec(table, write, filp, buffer, lenp);
168 +}
169 +
170 +// - - - - -
171 +static struct ctl_table_header *diag_sysctl_header;
172 +
173 +static ctl_table sys_diag[] = {
174 + {
175 + ctl_name: 2000,
176 + procname: "diag",
177 + data: &diag,
178 + maxlen: sizeof(diag),
179 + mode: 0644,
180 + proc_handler: proc_diag
181 + },
182 + {
183 + ctl_name: 2001,
184 + procname: "reset",
185 + data: &reset,
186 + maxlen: sizeof(reset),
187 + mode: 0444,
188 + proc_handler: proc_reset
189 + },
190 + { 0 }
191 +};
192 +
193 +static int __init diag_init()
194 +{
195 + char *buf;
196 + u32 board_type;
197 + sbh = sb_kattach();
198 + sb_gpiosetcore(sbh);
199 +
200 + board_type = sb_boardtype(sbh);
201 + printk(KERN_INFO "diag boardtype: %08x\n",board_type);
202 +
203 + set_diag=ignore;
204 + set_dmz=ignore;
205 +
206 + buf=nvram_get("boardrev");
207 + if (((board_type & 0xf00) == 0x400) && strcmp(buf,"0x10")) {
208 + buf=nvram_get("boardtype")?:"";
209 + if (!strcmp(buf,"bcm94710dev")) {
210 + buf=nvram_get("boardnum")?:"";
211 + if (!strcmp(buf,"42")) {
212 + // wrt54g v1.x
213 + set_diag=v1_set_diag;
214 + set_dmz=v1_set_dmz;
215 + reset_gpio=(1<<6);
216 + }
217 + if (!strcmp(buf,"asusX")) {
218 + //asus wl-500g
219 + reset_gpio=(1<<6);
220 + }
221 + }
222 + if (!strcmp(buf,"bcm94710ap")) {
223 + buf=nvram_get("boardnum")?:"";
224 + if (!strcmp(buf,"42")) {
225 + // buffalo
226 + set_dmz=v2_set_dmz;
227 + reset_gpio=(1<<4);
228 + }
229 + if (!strcmp(buf,"44")) {
230 + //dell truemobile
231 + set_dmz=v2_set_dmz;
232 + reset_gpio=(1<<0);
233 + }
234 + }
235 + } else {
236 + buf=nvram_get("boardnum")?:"";
237 + if (!strcmp(buf,"42")) {
238 + //linksys
239 + set_diag=v2_set_diag;
240 + set_dmz=v2_set_dmz;
241 + reset_gpio=(1<<6);
242 + }
243 + if (!strcmp(buf,"44")) {
244 + //motorola
245 + reset_gpio=(1<<5);
246 + }
247 + if (!strcmp(buf,"00")) {
248 + //buffalo
249 + reset_gpio=(1<<7);
250 + }
251 + if (!strcmp(buf,"45")) {
252 + //wl-500g deluxe
253 + reset_gpio=(1<<6);
254 + }
255 + }
256 +
257 +
258 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
259 + sb_gpioouten(sbh,reset_gpio,0);
260 + reset_polarity=!(sb_gpioin(sbh)&reset_gpio);
261 +
262 + diag_sysctl_header = register_sysctl_table(sys_diag, 0);
263 + diag_change();
264 +
265 + return 0;
266 +}
267 +
268 +static void __exit diag_exit()
269 +{
270 + unregister_sysctl_table(diag_sysctl_header);
271 +}
272 +
273 +EXPORT_NO_SYMBOLS;
274 +MODULE_AUTHOR("openwrt.org");
275 +MODULE_LICENSE("GPL");
276 +
277 +module_init(diag_init);
278 +module_exit(diag_exit);
This page took 0.060673 seconds and 5 git commands to generate.