b9f589d529f0dce0c9b00bc43b006e00d5896175
[openwrt.git] / target / linux / ixp4xx / patches / 997-fsg3_buttons.patch
1 ---
2 arch/arm/mach-ixp4xx/Makefile | 2
3 arch/arm/mach-ixp4xx/fsg-power.c | 168 +++++++++++++++++++++++++++++++++++++++
4 2 files changed, 169 insertions(+), 1 deletion(-)
5
6 Index: linux-2.6.21.6-armeb/arch/arm/mach-ixp4xx/fsg-power.c
7 ===================================================================
8 --- /dev/null
9 +++ linux-2.6.21.6-armeb/arch/arm/mach-ixp4xx/fsg-power.c
10 @@ -0,0 +1,168 @@
11 +/*
12 + * arch/arm/mach-ixp4xx/fsg-power.c
13 + *
14 + * FSG buttons driver
15 + *
16 + * This program is free software; you can redistribute it and/or modify
17 + * it under the terms of the GNU General Public License version 2 as
18 + * published by the Free Software Foundation.
19 + *
20 + */
21 +
22 +#include <linux/module.h>
23 +#include <linux/reboot.h>
24 +#include <linux/irq.h>
25 +#include <linux/interrupt.h>
26 +#include <asm/mach-types.h>
27 +#include <linux/kernel.h>
28 +
29 +struct event_t {
30 + struct work_struct wq;
31 + char *button_name;
32 + int action;
33 +};
34 +
35 +static void hotplug_button(struct event_t *event)
36 +{
37 + static char buf[128];
38 + char *argv[3], *envp[6], *action;
39 + int i;
40 +
41 + i = 0;
42 + argv[i++] = "/sbin/hotplug";
43 + argv[i++] = "button";
44 + argv[i] = 0;
45 +
46 + i = 0;
47 + /* minimal command environment */
48 + envp [i++] = "HOME=/";
49 + envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
50 + envp [i++] = "SUBSYSTEM=button";
51 +
52 + snprintf(buf, 128, "BUTTON=%s", event->button_name);
53 + envp [i++] = buf;
54 +
55 + action = event->action ? "released" : "pressed";
56 + snprintf(buf, 128, "ACTION=%s", action);
57 + envp [i++] = buf;
58 +
59 + envp [i] = 0;
60 +
61 + // create hotplug event
62 + call_usermodehelper (argv[0], argv, envp, 0);
63 +
64 + //destroy event structure
65 + kfree(event);
66 +}
67 +
68 +static irqreturn_t fsg_sync_button_handler(int irq, void *dev_id)
69 +{
70 + int holdkey;
71 + struct event_t *event;
72 +
73 + //check button status
74 + gpio_line_get(FSG_SB_GPIO, &holdkey);
75 +
76 + //create event
77 + if ((event = (struct event_t *)kzalloc (sizeof(struct event_t), GFP_ATOMIC))) {
78 + event->action = holdkey;
79 + event->button_name = "sync";
80 +
81 + INIT_WORK(&event->wq, (void *)(void *)hotplug_button);
82 + schedule_work(&event->wq);
83 + }
84 +
85 + return IRQ_HANDLED;
86 +}
87 +
88 +static irqreturn_t fsg_reset_button_handler(int irq, void *dev_id)
89 +{
90 + int holdkey;
91 + struct event_t *event;
92 +
93 + //check button status
94 + gpio_line_get(FSG_RB_GPIO, &holdkey);
95 +
96 + //create event
97 + if ((event = (struct event_t *)kzalloc (sizeof(struct event_t), GFP_ATOMIC))) {
98 + event->action = holdkey;
99 + event->button_name = "reset";
100 +
101 + INIT_WORK(&event->wq, (void *)(void *)hotplug_button);
102 + schedule_work(&event->wq);
103 + }
104 +
105 + return IRQ_HANDLED;
106 +}
107 +
108 +static irqreturn_t fsg_unplug_button_handler(int irq, void *dev_id)
109 +{
110 + int holdkey;
111 + struct event_t *event;
112 +
113 + //check button status
114 + gpio_line_get(FSG_UB_GPIO, &holdkey);
115 +
116 + //create event
117 + if ((event = (struct event_t *)kzalloc (sizeof(struct event_t), GFP_ATOMIC))) {
118 + event->action = holdkey;
119 + event->button_name = "unplug";
120 +
121 + INIT_WORK(&event->wq, (void *)(void *)hotplug_button);
122 + schedule_work(&event->wq);
123 + }
124 +
125 + return IRQ_HANDLED;
126 +}
127 +
128 +static int __init fsg_buttons_init(void)
129 +{
130 + if (!(machine_is_fsg()))
131 + return 0;
132 +
133 + /* Configure interrupt input for SYNC button */
134 + set_irq_type(FSG_SB_IRQ, IRQT_BOTHEDGE);
135 + if (request_irq(FSG_SB_IRQ, &fsg_sync_button_handler, IRQF_DISABLED, "SYNC", NULL) < 0) {
136 + printk(KERN_DEBUG "SYNC button IRQ %d not available\n", FSG_SB_IRQ);
137 + return -EIO;
138 + }
139 + else
140 + printk("SYNC button registered on IRQ%d\n", FSG_SB_IRQ);
141 +
142 + /* Configure interrupt input for RESET button */
143 + set_irq_type(FSG_RB_IRQ, IRQT_BOTHEDGE);
144 + if (request_irq(FSG_RB_IRQ, &fsg_reset_button_handler, IRQF_DISABLED, "RESET", NULL) < 0) {
145 + printk(KERN_DEBUG "RESET button IRQ %d not available\n", FSG_RB_IRQ);
146 + return -EIO;
147 + }
148 + else
149 + printk("RESET button registered on IRQ%d\n", FSG_RB_IRQ);
150 +
151 + /* Configure interrupt input for UNPLUG button */
152 + set_irq_type(FSG_UB_IRQ, IRQT_BOTHEDGE);
153 + if (request_irq(FSG_UB_IRQ, &fsg_unplug_button_handler, IRQF_DISABLED, "RESET", NULL) < 0) {
154 + printk(KERN_DEBUG "UNPLUG button IRQ %d not available\n", FSG_UB_IRQ);
155 + return -EIO;
156 + }
157 + else
158 + printk("UNPLUG button registered on IRQ%d\n", FSG_UB_IRQ);
159 +
160 + return 0;
161 +}
162 +
163 +static void __exit fsg_buttons_exit(void)
164 +{
165 + if (!(machine_is_fsg()))
166 + return;
167 +
168 + free_irq(FSG_SB_IRQ, NULL);
169 + free_irq(FSG_RB_IRQ, NULL);
170 + free_irq(FSG_UB_IRQ, NULL);
171 +}
172 +
173 +module_init(fsg_buttons_init);
174 +module_exit(fsg_buttons_exit);
175 +
176 +MODULE_AUTHOR("Zintis Petersons <Zintis.Petersons@e-mail.lv>");
177 +MODULE_DESCRIPTION("FSG buttons driver");
178 +MODULE_LICENSE("GPL");
179 Index: linux-2.6.21.6-armeb/arch/arm/mach-ixp4xx/Makefile
180 ===================================================================
181 --- linux-2.6.21.6-armeb.orig/arch/arm/mach-ixp4xx/Makefile
182 +++ linux-2.6.21.6-armeb/arch/arm/mach-ixp4xx/Makefile
183 @@ -30,7 +30,7 @@
184 obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o nslu2-power.o
185 obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
186 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
187 -obj-$(CONFIG_MACH_FSG) += fsg-setup.o
188 +obj-$(CONFIG_MACH_FSG) += fsg-setup.o fsg-power.o
189 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
190 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
191 obj-$(CONFIG_MACH_PRONGHORNMETRO) += pronghornmetro-setup.o
This page took 0.046191 seconds and 3 git commands to generate.