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);
56 static void ignore(u8 ignored) {};
62 void (*set_diag)(u8 state);
63 void (*set_dmz)(u8 state);
65 static unsigned int diag = 0;
66 static struct timer_list timer;
68 static void diag_change()
70 printk(KERN_INFO "led -> %02x\n",diag);
72 set_diag(0xFF); // off
81 static int proc_diag(ctl_table *table, int write, struct file *filp,
82 void *buffer, size_t *lenp)
85 r = proc_dointvec(table, write, filp, buffer, lenp);
93 static struct ctl_table_header *diag_sysctl_header;
95 static ctl_table sys_diag[] = {
100 maxlen: sizeof(diag),
102 proc_handler: proc_diag
107 static int __init diag_init()
113 board_type = sb_boardtype(sbh);
114 printk(KERN_INFO "diag board_type: %08x\n",board_type);
116 if (board_type & 0x400) {
118 set_diag=v1_set_diag;
121 if (board_type==0x41d) {
122 printk(KERN_INFO "buffalo hack.\n");
128 set_diag=v2_set_diag;
131 printk(KERN_INFO "using v%d hardware\n",board_type);
133 diag_sysctl_header = register_sysctl_table(sys_diag, 0);
139 static void __exit diag_exit()
141 unregister_sysctl_table(diag_sysctl_header);
145 module_init(diag_init);
146 module_exit(diag_exit);