1 // replacement diag module
5 // initial release 2004/03/28
7 // 2004/08/26 asus & buffalo support added
8 // 2005/03/14 asus wl-500g deluxe and buffalo v2 support added
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/kernel.h>
13 #include <linux/sysctl.h>
19 extern char * nvram_get(const char *name
);
23 #define DIAG_GPIO (1<<1)
24 #define DMZ_GPIO (1<<7)
26 static void set_gpio(uint32 mask
, uint32 value
) {
27 sb_gpiocontrol(sbh
,mask
,0);
28 sb_gpioouten(sbh
,mask
,mask
);
29 sb_gpioout(sbh
,mask
,value
);
32 static void v2_set_diag(u8 state
) {
33 set_gpio(DIAG_GPIO
,state
);
35 static void v2_set_dmz(u8 state
) {
36 set_gpio(DMZ_GPIO
,state
);
43 static void v1_set_diag(u8 state
) {
45 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
)=0xFF;
47 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
);
50 static void v1_set_dmz(u8 state
) {
52 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
)=0xFF;
54 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
);
59 static void ignore(u8 ignored
) {};
65 void (*set_diag
)(u8 state
);
66 void (*set_dmz
)(u8 state
);
68 static unsigned int diag
= 0;
70 static void diag_change()
72 //printk(KERN_INFO "led -> %02x\n",diag);
74 set_diag(0xFF); // off
83 static int proc_diag(ctl_table
*table
, int write
, struct file
*filp
,
84 void *buffer
, size_t *lenp
)
87 r
= proc_dointvec(table
, write
, filp
, buffer
, lenp
);
95 static unsigned char reset_gpio
= 0;
96 static unsigned char reset_polarity
= 0;
97 static unsigned int reset
= 0;
99 static int proc_reset(ctl_table
*table
, int write
, struct file
*filp
,
100 void *buffer
, size_t *lenp
)
104 sb_gpiocontrol(sbh
,reset_gpio
,reset_gpio
);
105 sb_gpioouten(sbh
,reset_gpio
,0);
106 reset
=!(sb_gpioin(sbh
)&reset_gpio
);
108 if (reset_polarity
) reset
=!reset
;
113 return proc_dointvec(table
, write
, filp
, buffer
, lenp
);
117 static struct ctl_table_header
*diag_sysctl_header
;
119 static ctl_table sys_diag
[] = {
124 maxlen
: sizeof(diag
),
126 proc_handler
: proc_diag
132 maxlen
: sizeof(reset
),
134 proc_handler
: proc_reset
139 static int __init
diag_init()
146 board_type
= sb_boardtype(sbh
);
147 printk(KERN_INFO
"diag boardtype: %08x\n",board_type
);
152 if ((board_type
& 0xf00) == 0x400) {
154 buf
=nvram_get("boardtype")?:"";
155 if (!strcmp(buf
,"bcm94710dev")) {
156 buf
=nvram_get("boardnum")?:"";
157 if (!strcmp(buf
,"42")) {
159 set_diag
=v1_set_diag
;
163 } else if (!strcmp(buf
,"asusX")) {
169 } else if (!strcmp(buf
,"bcm94710ap")) {
170 buf
=nvram_get("boardnum")?:"";
171 if (!strcmp(buf
,"42")) {
176 } else if (!strcmp(buf
,"44")) {
185 set_diag
=v2_set_diag
;
189 buf
=nvram_get("boardnum")?:"";
190 if (!strcmp(buf
,"44")) {
197 if (!strcmp(buf
,"00")) {
204 if (!strcmp(buf
,"45")) {
212 printk(KERN_INFO
"using v%d hardware\n",board_type
);
214 diag_sysctl_header
= register_sysctl_table(sys_diag
, 0);
220 static void __exit
diag_exit()
222 unregister_sysctl_table(diag_sysctl_header
);
225 module_init(diag_init
);
226 module_exit(diag_exit
);
This page took 0.060685 seconds and 5 git commands to generate.