remove disable-nls, not available here
[openwrt.git] / openwrt / target / linux / linux-2.6 / patches / brcm / 002-diag_led.patch
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
4 @@ -41,6 +41,11 @@
5 Instead of 'dummy', the devices will then be called 'dummy0',
6 'dummy1' etc.
7
8 +config DIAG_LED
9 + tristate "Led driver for Broadcom BCM97xx"
10 + ---help---
11 + Say m if you like the led to signal status of operation.
12 +
13 config BONDING
14 tristate "Bonding driver support"
15 depends on NETDEVICES
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
19 @@ -1,6 +1,7 @@
20 #
21 # Makefile for the Linux network (ethercard) device drivers.
22 #
23 +obj-$(CONFIG_DIAG_LED) += diag/
24
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
30 @@ -0,0 +1,5 @@
31 +#$Id$
32 +
33 +EXTRA_CFLAGS := -I$(TOPDIR)/arch/mips/bcm947xx/include -DBCMDRIVER
34 +
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
39 @@ -0,0 +1,249 @@
40 +/*
41 + * diag_led.c - replacement diag module
42 + *
43 + * Copyright (C) 2004 Mike Baker,
44 + * Imre Kaloz <kaloz@dune.hu>
45 + *
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.
50 + *
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.
55 + *
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.
59 + *
60 + * $Id$
61 + */
62 +
63 +/*
64 + * ChangeLog:
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
70 + */
71 +
72 +#include <linux/module.h>
73 +#include <linux/init.h>
74 +#include <linux/kernel.h>
75 +#include <linux/sysctl.h>
76 +#include <asm/io.h>
77 +#include <typedefs.h>
78 +#include <bcmdevs.h>
79 +#include <sbutils.h>
80 +
81 +extern char * nvram_get(const char *name);
82 +static void *sbh;
83 +
84 +// v2.x - - - - -
85 +#define DIAG_GPIO (1<<1)
86 +#define DMZ_GPIO (1<<7)
87 +
88 +/*
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);
93 +}
94 +
95 +static void v2_set_diag(u8 state) {
96 + set_gpio(DIAG_GPIO,state);
97 +}
98 +static void v2_set_dmz(u8 state) {
99 + set_gpio(DMZ_GPIO,state);
100 +}
101 +*/
102 +
103 +/*
104 +// v1.x - - - - -
105 +#define LED_DIAG 0x13
106 +#define LED_DMZ 0x12
107 +
108 +static void v1_set_diag(u8 state) {
109 + if (!state) {
110 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG)=0xFF;
111 + } else {
112 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DIAG);
113 + }
114 +}
115 +static void v1_set_dmz(u8 state) {
116 + if (!state) {
117 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ)=0xFF;
118 + } else {
119 + *(volatile u8*)(KSEG1ADDR(BCM4710_EUART)+LED_DMZ);
120 + }
121 +}
122 +*/
123 +
124 +// - - - - -
125 +static void ignore(u8 ignored) {};
126 +
127 +// - - - - -
128 +#define BIT_DMZ 0x01
129 +#define BIT_DIAG 0x04
130 +
131 +void (*set_diag)(u8 state);
132 +void (*set_dmz)(u8 state);
133 +
134 +static unsigned int diag = 0;
135 +
136 +static void diag_change()
137 +{
138 + set_diag(0xFF); // off
139 + set_dmz(0xFF); // off
140 +
141 + if(diag & BIT_DIAG)
142 + set_diag(0x00); // on
143 + if(diag & BIT_DMZ)
144 + set_dmz(0x00); // on
145 +}
146 +
147 +static int proc_diag(ctl_table *table, int write, struct file *filp,
148 + void *buffer, size_t *lenp, loff_t *ppos)
149 +{
150 + int r;
151 + r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
152 + if (write && !r) {
153 + diag_change();
154 + }
155 + return r;
156 +}
157 +
158 +// - - - - -
159 +static unsigned char reset_gpio = 0;
160 +static unsigned char reset_polarity = 0;
161 +static unsigned int reset = 0;
162 +
163 +static int proc_reset(ctl_table *table, int write, struct file *filp,
164 + void *buffer, size_t *lenp, loff_t *ppos)
165 +{
166 +
167 + if (reset_gpio) {
168 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
169 + sb_gpioouten(sbh,reset_gpio,0);
170 + reset=!(sb_gpioin(sbh)&reset_gpio);
171 +
172 + if (reset_polarity) reset=!reset;
173 + } else {
174 + reset=0;
175 + }
176 +
177 + return proc_dointvec(table, write, filp, buffer, lenp, ppos);
178 +}
179 +
180 +// - - - - -
181 +static struct ctl_table_header *diag_sysctl_header;
182 +
183 +static ctl_table sys_diag[] = {
184 + {
185 + ctl_name: 2000,
186 + procname: "diag",
187 + data: &diag,
188 + maxlen: sizeof(diag),
189 + mode: 0644,
190 + proc_handler: proc_diag
191 + },
192 + {
193 + ctl_name: 2001,
194 + procname: "reset",
195 + data: &reset,
196 + maxlen: sizeof(reset),
197 + mode: 0444,
198 + proc_handler: proc_reset
199 + },
200 + { 0 }
201 +};
202 +
203 +static int __init diag_init()
204 +{
205 + //char *buf;
206 + u32 board_type;
207 + sbh = sb_kattach();
208 + sb_gpiosetcore(sbh);
209 +
210 + board_type = sb_boardtype(sbh);
211 + printk(KERN_INFO "diag boardtype: %08x\n",board_type);
212 +
213 + set_diag=ignore;
214 + set_dmz=ignore;
215 +
216 + /*
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")) {
223 + // wrt54g v1.x
224 + set_diag=v1_set_diag;
225 + set_dmz=v1_set_dmz;
226 + reset_gpio=(1<<6);
227 + }
228 + if (!strcmp(buf,"asusX")) {
229 + //asus wl-500g
230 + reset_gpio=(1<<6);
231 + }
232 + }
233 + if (!strcmp(buf,"bcm94710ap")) {
234 + buf=nvram_get("boardnum")?:"";
235 + if (!strcmp(buf,"42")) {
236 + // buffalo
237 + set_dmz=v2_set_dmz;
238 + reset_gpio=(1<<4);
239 + }
240 + if (!strcmp(buf,"44")) {
241 + //dell truemobile
242 + set_dmz=v2_set_dmz;
243 + reset_gpio=(1<<0);
244 + }
245 + }
246 + } else {
247 + buf=nvram_get("boardnum")?:"";
248 + if (!strcmp(buf,"42")) {
249 + //linksys
250 + set_diag=v2_set_diag;
251 + set_dmz=v2_set_dmz;
252 + reset_gpio=(1<<6);
253 + }
254 + if (!strcmp(buf,"44")) {
255 + //motorola
256 + reset_gpio=(1<<5);
257 + }
258 + if (!strcmp(buf,"00")) {
259 + //buffalo
260 + reset_gpio=(1<<7);
261 + }
262 + if (!strcmp(buf,"45")) {
263 + //wl-500g deluxe
264 + reset_gpio=(1<<6);
265 + }
266 + }
267 +
268 + */
269 + sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
270 + sb_gpioouten(sbh,reset_gpio,0);
271 + reset_polarity=!(sb_gpioin(sbh)&reset_gpio);
272 +
273 + diag_sysctl_header = register_sysctl_table(sys_diag, 0);
274 + diag_change();
275 +
276 + return 0;
277 +}
278 +
279 +static void __exit diag_exit()
280 +{
281 + unregister_sysctl_table(diag_sysctl_header);
282 +}
283 +
284 +MODULE_AUTHOR("openwrt.org");
285 +MODULE_LICENSE("GPL");
286 +
287 +module_init(diag_init);
288 +module_exit(diag_exit);
This page took 0.074244 seconds and 5 git commands to generate.