[package] hostapd: introduce options to configure the logging behaviour.
[openwrt.git] / package / broadcom-diag / src / diag.h
1 /*
2 * diag.h - GPIO interface driver for Broadcom boards
3 *
4 * Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
5 * Felix Fietkau <nbd@openwrt.org>
6 *
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.
11 *
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.
16 *
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.
20 *
21 */
22
23 #include <linux/irq.h>
24 #define MODULE_NAME "diag"
25
26 #define MAX_GPIO 16
27 #define FLASH_TIME HZ/6
28
29 enum polarity_t {
30 REVERSE = 0,
31 NORMAL = 1,
32 INPUT = 2,
33 };
34
35 enum {
36 PROC_BUTTON,
37 PROC_LED,
38 PROC_MODEL,
39 PROC_GPIOMASK
40 };
41
42 struct prochandler_t {
43 int type;
44 void *ptr;
45 };
46
47 struct button_t {
48 struct prochandler_t proc;
49 char *name;
50 u32 gpio;
51 unsigned long seen;
52 u8 pressed;
53 };
54
55 struct led_t {
56 struct prochandler_t proc;
57 char *name;
58 u32 gpio;
59 u8 polarity;
60 u8 flash;
61 u8 state;
62 };
63
64 struct platform_t {
65 char *name;
66
67 struct button_t buttons[MAX_GPIO];
68 u32 button_mask;
69 u32 button_polarity;
70 void (*platform_init)(void);
71
72 struct led_t leds[MAX_GPIO];
73 };
74
75 struct event_t {
76 struct work_struct wq;
77 unsigned long seen;
78 char *name, *action;
79 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
80 struct sk_buff *skb;
81 #else
82 char *scratch;
83 char *argv[4];
84 char *envp[7];
85 u8 enr, anr;
86 #endif
87 };
88
89 extern char *nvram_get(char *str);
90
91 static struct platform_t platform;
92
93 /* buttons */
94
95 static void register_buttons(struct button_t *b);
96 static void unregister_buttons(struct button_t *b);
97
98 static void hotplug_button(struct work_struct *work);
99 static irqreturn_t button_handler(int irq, void *dev_id);
100
101 /* leds */
102
103 static void register_leds(struct led_t *l);
104 static void unregister_leds(struct led_t *l);
105
106 static void set_led_extif(struct led_t *led);
107 static void led_flash(unsigned long dummy);
108
109 /* 2.4 compatibility */
110 #ifndef TIMER_INITIALIZER
111 #define TIMER_INITIALIZER(_function, _expires, _data) \
112 { \
113 /* _expires and _data currently unused */ \
114 function: _function \
115 }
116 #endif
117
118 static struct timer_list led_timer = TIMER_INITIALIZER(&led_flash, 0, 0);
119
120 /* proc */
121
122 static struct proc_dir_entry *diag, *leds;
123
124 static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos);
125 static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
126
127 static struct file_operations diag_proc_fops = {
128 read: diag_proc_read,
129 write: diag_proc_write
130 };
131
132 static struct prochandler_t proc_model = { .type = PROC_MODEL };
133 static struct prochandler_t proc_gpiomask = { .type = PROC_GPIOMASK };
134
This page took 0.055996 seconds and 5 git commands to generate.