apex: Correct fsg3 rootfs location
[nslu2-linux/kernel.git] / patches / 2.6.21 / 97-fsg3-buttons.patch
blob04cb42fe0a668c644df9906d01519bffcae5c662
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(-)
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 + */
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>
29 +struct event_t {
30 + struct work_struct wq;
31 + char *button_name;
32 + int action;
33 +};
35 +static void hotplug_button(struct event_t *event)
37 + static char buf[128];
38 + char *argv[3], *envp[6], *action;
39 + int i;
41 + i = 0;
42 + argv[i++] = "/sbin/hotplug";
43 + argv[i++] = "button";
44 + argv[i] = 0;
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";
52 + snprintf(buf, 128, "BUTTON=%s", event->button_name);
53 + envp [i++] = buf;
55 + action = event->action ? "released" : "pressed";
56 + snprintf(buf, 128, "ACTION=%s", action);
57 + envp [i++] = buf;
59 + envp [i] = 0;
61 + // create hotplug event
62 + call_usermodehelper (argv[0], argv, envp, 0);
64 + //destroy event structure
65 + kfree(event);
68 +static irqreturn_t fsg_sync_button_handler(int irq, void *dev_id)
70 + int holdkey;
71 + struct event_t *event;
73 + //check button status
74 + gpio_line_get(FSG_SB_GPIO, &holdkey);
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";
81 + INIT_WORK(&event->wq, (void *)(void *)hotplug_button);
82 + schedule_work(&event->wq);
83 + }
85 + return IRQ_HANDLED;
88 +static irqreturn_t fsg_reset_button_handler(int irq, void *dev_id)
90 + int holdkey;
91 + struct event_t *event;
93 + //check button status
94 + gpio_line_get(FSG_RB_GPIO, &holdkey);
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";
101 + INIT_WORK(&event->wq, (void *)(void *)hotplug_button);
102 + schedule_work(&event->wq);
105 + return IRQ_HANDLED;
108 +static irqreturn_t fsg_unplug_button_handler(int irq, void *dev_id)
110 + int holdkey;
111 + struct event_t *event;
113 + //check button status
114 + gpio_line_get(FSG_UB_GPIO, &holdkey);
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";
121 + INIT_WORK(&event->wq, (void *)(void *)hotplug_button);
122 + schedule_work(&event->wq);
125 + return IRQ_HANDLED;
128 +static int __init fsg_buttons_init(void)
130 + if (!(machine_is_fsg()))
131 + return 0;
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;
139 + else
140 + printk("SYNC button registered on IRQ%d\n", FSG_SB_IRQ);
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;
148 + else
149 + printk("RESET button registered on IRQ%d\n", FSG_RB_IRQ);
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;
157 + else
158 + printk("UNPLUG button registered on IRQ%d\n", FSG_UB_IRQ);
160 + return 0;
163 +static void __exit fsg_buttons_exit(void)
165 + if (!(machine_is_fsg()))
166 + return;
168 + free_irq(FSG_SB_IRQ, NULL);
169 + free_irq(FSG_RB_IRQ, NULL);
170 + free_irq(FSG_UB_IRQ, NULL);
173 +module_init(fsg_buttons_init);
174 +module_exit(fsg_buttons_exit);
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 @@ -25,6 +25,6 @@
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
190 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o