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/timer.h>
11 #include <linux/sysctl.h>
20 #define DIAG_GPIO (1<<1)
21 #define DMZ_GPIO (1<<7)
23 static void set_gpio(uint32 mask
, uint32 value
) {
24 sb_gpiocontrol(sbh
,mask
,0);
25 sb_gpioouten(sbh
,mask
,mask
);
26 sb_gpioout(sbh
,mask
,value
);
29 static void v2_set_diag(u8 state
) {
30 set_gpio(DIAG_GPIO
,state
);
32 static void v2_set_dmz(u8 state
) {
33 set_gpio(DMZ_GPIO
,state
);
40 static void v1_set_diag(u8 state
) {
42 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
)=0xFF;
44 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DIAG
);
47 static void v1_set_dmz(u8 state
) {
49 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
)=0xFF;
51 *(volatile u8
*)(KSEG1ADDR(BCM4710_EUART
)+LED_DMZ
);
59 void (*set_diag
)(u8 state
);
60 void (*set_dmz
)(u8 state
);
62 static unsigned int diag
= 0;
63 static struct timer_list timer
;
65 static void diag_change()
67 printk(KERN_INFO
"led -> %02x\n",diag
);
69 set_diag(0xFF); // off
78 static int proc_diag(ctl_table
*table
, int write
, struct file
*filp
,
79 void *buffer
, size_t *lenp
)
82 r
= proc_dointvec(table
, write
, filp
, buffer
, lenp
);
90 static struct ctl_table_header
*diag_sysctl_header
;
92 static ctl_table sys_diag
[] = {
99 proc_handler
: proc_diag
104 static int __init
diag_init()
110 board_type
= sb_boardtype(sbh
);
111 printk(KERN_INFO
"diag board_type: %08x\n",board_type
);
113 if (board_type
& 0x400) {
115 set_diag
=v1_set_diag
;
119 set_diag
=v2_set_diag
;
122 printk(KERN_INFO
"using v%d hardware\n",board_type
);
124 diag_sysctl_header
= register_sysctl_table(sys_diag
, 0);
130 static void __exit
diag_exit()
132 unregister_sysctl_table(diag_sysctl_header
);
136 module_init(diag_init
);
137 module_exit(diag_exit
);
This page took 0.050896 seconds and 5 git commands to generate.