2 * diag_led.c - replacement diag module
4 * Copyright (C) 2004 Mike Baker,
5 * Imre Kaloz <kaloz@dune.hu>
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.
26 * 2004/03/28 initial release
27 * 2004/08/26 asus & buffalo support added
28 * 2005/03/14 asus wl-500g deluxe and buffalo v2 support added
29 * 2005/04/13 added licensing informations
30 * 2005/04/18 base reset polarity off initial readings
33 #include <linux/module.h>
34 #include <linux/init.h>
35 #include <linux/kernel.h>
36 #include <linux/sysctl.h>
42 extern char * nvram_get(const char *name
);
46 #define DIAG_GPIO (1<<1)
47 #define DMZ_GPIO (1<<7)
49 static void set_gpio(uint32 mask
, uint32 value
) {
50 sb_gpiocontrol(sbh
,mask
,0);
51 sb_gpioouten(sbh
,mask
,mask
);
52 sb_gpioout(sbh
,mask
,value
);
55 static void v2_set_diag(u8 state
) {
56 set_gpio(DIAG_GPIO
,state
);
58 static void v2_set_dmz(u8 state
) {
59 set_gpio(DMZ_GPIO
,state
);
66 static void v1_set_diag(u8 state
) {
68 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
)=0xFF;
70 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
);
73 static void v1_set_dmz(u8 state
) {
75 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
)=0xFF;
77 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
);
82 static void ignore(u8 ignored
) {};
88 void (*set_diag
)(u8 state
);
89 void (*set_dmz
)(u8 state
);
91 static unsigned int diag
= 0;
93 static void diag_change()
95 set_diag(0xFF); // off
104 static int proc_diag(ctl_table
*table
, int write
, struct file
*filp
,
105 void *buffer
, size_t *lenp
)
108 r
= proc_dointvec(table
, write
, filp
, buffer
, lenp
);
116 static unsigned char reset_gpio
= 0;
117 static unsigned char reset_polarity
= 0;
118 static unsigned int reset
= 0;
120 static int proc_reset(ctl_table
*table
, int write
, struct file
*filp
,
121 void *buffer
, size_t *lenp
)
125 sb_gpiocontrol(sbh
,reset_gpio
,reset_gpio
);
126 sb_gpioouten(sbh
,reset_gpio
,0);
127 reset
=!(sb_gpioin(sbh
)&reset_gpio
);
129 if (reset_polarity
) reset
=!reset
;
134 return proc_dointvec(table
, write
, filp
, buffer
, lenp
);
138 static struct ctl_table_header
*diag_sysctl_header
;
140 static ctl_table sys_diag
[] = {
145 maxlen
: sizeof(diag
),
147 proc_handler
: proc_diag
153 maxlen
: sizeof(reset
),
155 proc_handler
: proc_reset
160 static int __init
diag_init()
167 board_type
= sb_boardtype(sbh
);
168 printk(KERN_INFO
"diag boardtype: %08x\n",board_type
);
173 if ((board_type
& 0xf00) == 0x400) {
174 buf
=nvram_get("boardtype")?:"";
175 if (!strcmp(buf
,"bcm94710dev")) {
176 buf
=nvram_get("boardnum")?:"";
177 if (!strcmp(buf
,"42")) {
179 set_diag
=v1_set_diag
;
183 if (!strcmp(buf
,"asusX")) {
188 if (!strcmp(buf
,"bcm94710ap")) {
189 buf
=nvram_get("boardnum")?:"";
190 if (!strcmp(buf
,"42")) {
195 if (!strcmp(buf
,"44")) {
202 buf
=nvram_get("boardnum")?:"";
203 if (!strcmp(buf
,"42")) {
205 set_diag
=v2_set_diag
;
209 if (!strcmp(buf
,"44")) {
213 if (!strcmp(buf
,"00")) {
217 if (!strcmp(buf
,"45")) {
224 sb_gpiocontrol(sbh
,reset_gpio
,reset_gpio
);
225 sb_gpioouten(sbh
,reset_gpio
,0);
226 reset_polarity
=!(sb_gpioin(sbh
)&reset_gpio
);
228 diag_sysctl_header
= register_sysctl_table(sys_diag
, 0);
234 static void __exit
diag_exit()
236 unregister_sysctl_table(diag_sysctl_header
);
240 MODULE_AUTHOR("openwrt.org");
241 MODULE_LICENSE("GPL");
243 module_init(diag_init
);
244 module_exit(diag_exit
);
This page took 0.05543 seconds and 5 git commands to generate.