7b4162988e6452570db7f9e7d7d7369bbdfa6f87
1 // replacement diag module
5 // initial release 2004/03/28
7 // 2004/08/26 asus & buffalo support added
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/sysctl.h>
18 extern char * nvram_get(const char *name
);
22 #define DIAG_GPIO (1<<1)
23 #define DMZ_GPIO (1<<7)
25 static void set_gpio(uint32 mask
, uint32 value
) {
26 sb_gpiocontrol(sbh
,mask
,0);
27 sb_gpioouten(sbh
,mask
,mask
);
28 sb_gpioout(sbh
,mask
,value
);
31 static void v2_set_diag(u8 state
) {
32 set_gpio(DIAG_GPIO
,state
);
34 static void v2_set_dmz(u8 state
) {
35 set_gpio(DMZ_GPIO
,state
);
42 static void v1_set_diag(u8 state
) {
44 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
)=0xFF;
46 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
);
49 static void v1_set_dmz(u8 state
) {
51 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
)=0xFF;
53 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
);
58 static void ignore(u8 ignored
) {};
64 void (*set_diag
)(u8 state
);
65 void (*set_dmz
)(u8 state
);
67 static unsigned int diag
= 0;
69 static void diag_change()
71 printk(KERN_INFO
"led -> %02x\n",diag
);
73 set_diag(0xFF); // off
82 static int proc_diag(ctl_table
*table
, int write
, struct file
*filp
,
83 void *buffer
, size_t *lenp
)
86 r
= proc_dointvec(table
, write
, filp
, buffer
, lenp
);
94 static unsigned char reset_gpio
= 0;
95 static unsigned char reset_polarity
= 0;
96 static unsigned int reset
= 0;
98 static int proc_reset(ctl_table
*table
, int write
, struct file
*filp
,
99 void *buffer
, size_t *lenp
)
103 sb_gpiocontrol(sbh
,reset_gpio
,reset_gpio
);
104 sb_gpioouten(sbh
,reset_gpio
,0);
105 reset
=!(sb_gpioin(sbh
)&reset_gpio
);
107 if (reset_polarity
) reset
=!reset
;
112 return proc_dointvec(table
, write
, filp
, buffer
, lenp
);
116 static struct ctl_table_header
*diag_sysctl_header
;
118 static ctl_table sys_diag
[] = {
123 maxlen
: sizeof(diag
),
125 proc_handler
: proc_diag
131 maxlen
: sizeof(reset
),
133 proc_handler
: proc_reset
138 static int __init
diag_init()
145 board_type
= sb_boardtype(sbh
);
146 printk(KERN_INFO
"diag boardtype: %08x\n",board_type
);
151 if (board_type
& 0x400) {
153 buf
=nvram_get("boardtype")?:"";
154 if (!strcmp(buf
,"bcm94710dev")) {
155 buf
=nvram_get("boardnum")?:"";
156 if (!strcmp(buf
,"42")) {
158 set_diag
=v1_set_diag
;
162 } else if (!strcmp(buf
,"asusX")) {
168 } else if (!strcmp(buf
,"bcm94710ap")) {
177 set_diag
=v2_set_diag
;
182 printk(KERN_INFO
"using v%d hardware\n",board_type
);
184 diag_sysctl_header
= register_sysctl_table(sys_diag
, 0);
190 static void __exit
diag_exit()
192 unregister_sysctl_table(diag_sysctl_header
);
195 module_init(diag_init
);
196 module_exit(diag_exit
);
This page took 0.053072 seconds and 3 git commands to generate.