2 * diag.h - GPIO interface driver for Broadcom boards
4 * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
5 * Felix Fietkau <nbd@openwrt.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <linux/irq.h>
25 #define MODULE_NAME "diag"
28 #define FLASH_TIME HZ/6
43 struct prochandler_t
{
49 struct prochandler_t proc
;
57 struct prochandler_t proc
;
68 struct button_t buttons
[MAX_GPIO
];
71 void (*platform_init
)(void);
73 struct led_t leds
[MAX_GPIO
];
77 struct work_struct wq
;
80 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
90 extern char *nvram_get(char *str
);
92 static struct platform_t platform
;
96 static void register_buttons(struct button_t
*b
);
97 static void unregister_buttons(struct button_t
*b
);
100 static void hotplug_button(struct work_struct
*work
);
101 static irqreturn_t
button_handler(int irq
, void *dev_id
);
103 static void hotplug_button(struct event_t
*event
);
104 static irqreturn_t
button_handler(int irq
, void *dev_id
, struct pt_regs
*regs
);
109 static void register_leds(struct led_t
*l
);
110 static void unregister_leds(struct led_t
*l
);
112 static void set_led_extif(struct led_t
*led
);
113 static void led_flash(unsigned long dummy
);
115 /* 2.4 compatibility */
116 #ifndef TIMER_INITIALIZER
117 #define TIMER_INITIALIZER(_function, _expires, _data) \
119 /* _expires and _data currently unused */ \
120 function: _function \
124 static struct timer_list led_timer
= TIMER_INITIALIZER(&led_flash
, 0, 0);
128 static struct proc_dir_entry
*diag
, *leds
;
130 static ssize_t
diag_proc_read(struct file
*file
, char *buf
, size_t count
, loff_t
*ppos
);
131 static ssize_t
diag_proc_write(struct file
*file
, const char *buf
, size_t count
, loff_t
*ppos
);
133 static struct file_operations diag_proc_fops
= {
134 read
: diag_proc_read
,
135 write
: diag_proc_write
138 static struct prochandler_t proc_model
= { .type
= PROC_MODEL
};
139 static struct prochandler_t proc_gpiomask
= { .type
= PROC_GPIOMASK
};