1 // replacement diag module
5 // initial release 2004/03/28
7 #include <linux/module.h>
8 #include <linux/init.h>
9 #include <linux/kernel.h>
10 #include <linux/sysctl.h>
19 #define DIAG_GPIO (1<<1)
20 #define DMZ_GPIO (1<<7)
22 static void set_gpio(uint32 mask
, uint32 value
) {
23 sb_gpiocontrol(sbh
,mask
,0);
24 sb_gpioouten(sbh
,mask
,mask
);
25 sb_gpioout(sbh
,mask
,value
);
28 static void v2_set_diag(u8 state
) {
29 set_gpio(DIAG_GPIO
,state
);
31 static void v2_set_dmz(u8 state
) {
32 set_gpio(DMZ_GPIO
,state
);
39 static void v1_set_diag(u8 state
) {
41 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
)=0xFF;
43 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
);
46 static void v1_set_dmz(u8 state
) {
48 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
)=0xFF;
50 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
);
55 static void ignore(u8 ignored
) {};
61 void (*set_diag
)(u8 state
);
62 void (*set_dmz
)(u8 state
);
64 static unsigned int diag
= 0;
66 static void diag_change()
68 printk(KERN_INFO
"led -> %02x\n",diag
);
70 set_diag(0xFF); // off
79 static int proc_diag(ctl_table
*table
, int write
, struct file
*filp
,
80 void *buffer
, size_t *lenp
)
83 r
= proc_dointvec(table
, write
, filp
, buffer
, lenp
);
91 static unsigned char reset_gpio
= 0;
92 static unsigned char reset_polarity
= 0;
93 static unsigned int reset
= 0;
95 static int proc_reset(ctl_table
*table
, int write
, struct file
*filp
,
96 void *buffer
, size_t *lenp
)
100 sb_gpiocontrol(sbh
,reset_gpio
,reset_gpio
);
101 sb_gpioouten(sbh
,reset_gpio
,0);
102 reset
=!(sb_gpioin(sbh
)&reset_gpio
);
104 if (reset_polarity
) reset
=!reset
;
109 return proc_dointvec(table
, write
, filp
, buffer
, lenp
);
113 static struct ctl_table_header
*diag_sysctl_header
;
115 static ctl_table sys_diag
[] = {
120 maxlen
: sizeof(diag
),
122 proc_handler
: proc_diag
128 maxlen
: sizeof(reset
),
130 proc_handler
: proc_reset
135 static int __init
diag_init()
142 board_type
= sb_boardtype(sbh
);
143 printk(KERN_INFO
"diag boardtype: %08x\n",board_type
);
148 if (board_type
& 0x400) {
150 set_diag
=v1_set_diag
;
153 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 (!strcmp(buf
,"asusX")) {
169 } else if (!strcmp(buf
,"bcm94710ap")) {
178 set_diag
=v2_set_diag
;
183 printk(KERN_INFO
"using v%d hardware\n",board_type
);
185 diag_sysctl_header
= register_sysctl_table(sys_diag
, 0);
191 static void __exit
diag_exit()
193 unregister_sysctl_table(diag_sysctl_header
);
196 module_init(diag_init
);
197 module_exit(diag_exit
);
This page took 0.047358 seconds and 5 git commands to generate.