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.7/arch/arm/mach-ixp4xx/fsg-power.c
7 ===================================================================
9 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/fsg-power.c
12 + * arch/arm/mach-ixp4xx/fsg-power.c
14 + * FSG buttons driver
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.
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>
30 + struct work_struct wq;
35 +static void hotplug_button(struct event_t *event)
37 + static char buf[128];
38 + char *argv[3], *envp[6], *action;
42 + argv[i++] = "/sbin/hotplug";
43 + argv[i++] = "button";
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);
55 + action = event->action ? "released" : "pressed";
56 + snprintf(buf, 128, "ACTION=%s", action);
61 + // create hotplug event
62 + call_usermodehelper (argv[0], argv, envp, 0);
64 + //destroy event structure
68 +static irqreturn_t fsg_sync_button_handler(int irq, void *dev_id)
71 + struct event_t *event;
73 + //check button status
74 + gpio_line_get(FSG_SB_GPIO, &holdkey);
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);
88 +static irqreturn_t fsg_reset_button_handler(int irq, void *dev_id)
91 + struct event_t *event;
93 + //check button status
94 + gpio_line_get(FSG_RB_GPIO, &holdkey);
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)
111 + struct event_t *event;
113 + //check button status
114 + gpio_line_get(FSG_UB_GPIO, &holdkey);
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()))
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);
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);
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);
158 + printk("UNPLUG button registered on IRQ%d\n", FSG_UB_IRQ);
163 +static void __exit fsg_buttons_exit(void)
165 + if (!(machine_is_fsg()))
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.7/arch/arm/mach-ixp4xx/Makefile
180 ===================================================================
181 --- linux-2.6.21.7.orig/arch/arm/mach-ixp4xx/Makefile
182 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/Makefile
183 @@ -30,7 +30,7 @@ obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-
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