add Avila/Cambria latch LED support, thanks Chris
[openwrt.git] / target / linux / ixp4xx / patches-2.6.24 / 032-subsume_power_files.patch
1 From: Rod Whitby <rod@whitby.id.au>
2 Subject: ixp4xx: Merge nslu2-power.c into nslu2-setup.c (Patch #4807)
3
4 There is no reason to have power control in a separate file from the
5 board setup code. Merge it back into the board setup file, removing
6 superfluous header includes and removing superfluous constants from
7 the machine header file.
8
9 Signed-off-by: Rod Whitby <rod@whitby.id.au>
10 --
11 PATCH FOLLOWS
12 KernelVersion: v2.6.24-1917-gaf66bd3
13
14 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/Makefile
15 ===================================================================
16 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/Makefile
17 +++ linux-2.6.24.7/arch/arm/mach-ixp4xx/Makefile
18 @@ -24,9 +24,9 @@ obj-$(CONFIG_MACH_AVILA) += avila-setup.
19 obj-$(CONFIG_MACH_IXDPG425) += coyote-setup.o
20 obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
21 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
22 -obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o nslu2-power.o
23 -obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
24 -obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
25 +obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o
26 +obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o
27 +obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o
28 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
29 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
30 obj-$(CONFIG_MACH_FSG) += fsg-setup.o
31 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/nslu2-power.c
32 ===================================================================
33 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/nslu2-power.c
34 +++ /dev/null
35 @@ -1,92 +0,0 @@
36 -/*
37 - * arch/arm/mach-ixp4xx/nslu2-power.c
38 - *
39 - * NSLU2 Power/Reset driver
40 - *
41 - * Copyright (C) 2005 Tower Technologies
42 - *
43 - * based on nslu2-io.c
44 - * Copyright (C) 2004 Karen Spearel
45 - *
46 - * Author: Alessandro Zummo <a.zummo@towertech.it>
47 - * Maintainers: http://www.nslu2-linux.org/
48 - *
49 - * This program is free software; you can redistribute it and/or modify
50 - * it under the terms of the GNU General Public License version 2 as
51 - * published by the Free Software Foundation.
52 - *
53 - */
54 -
55 -#include <linux/module.h>
56 -#include <linux/reboot.h>
57 -#include <linux/irq.h>
58 -#include <linux/interrupt.h>
59 -#include <linux/reboot.h>
60 -
61 -#include <asm/mach-types.h>
62 -
63 -static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
64 -{
65 - /* Signal init to do the ctrlaltdel action, this will bypass init if
66 - * it hasn't started and do a kernel_restart.
67 - */
68 - ctrl_alt_del();
69 -
70 - return IRQ_HANDLED;
71 -}
72 -
73 -static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
74 -{
75 - /* This is the paper-clip reset, it shuts the machine down directly.
76 - */
77 - machine_power_off();
78 -
79 - return IRQ_HANDLED;
80 -}
81 -
82 -static int __init nslu2_power_init(void)
83 -{
84 - if (!(machine_is_nslu2()))
85 - return 0;
86 -
87 - *IXP4XX_GPIO_GPISR = 0x20400000; /* read the 2 irqs to clr */
88 -
89 - set_irq_type(NSLU2_RB_IRQ, IRQT_LOW);
90 - set_irq_type(NSLU2_PB_IRQ, IRQT_HIGH);
91 -
92 - if (request_irq(NSLU2_RB_IRQ, &nslu2_reset_handler,
93 - IRQF_DISABLED, "NSLU2 reset button", NULL) < 0) {
94 -
95 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
96 - NSLU2_RB_IRQ);
97 -
98 - return -EIO;
99 - }
100 -
101 - if (request_irq(NSLU2_PB_IRQ, &nslu2_power_handler,
102 - IRQF_DISABLED, "NSLU2 power button", NULL) < 0) {
103 -
104 - printk(KERN_DEBUG "Power Button IRQ %d not available\n",
105 - NSLU2_PB_IRQ);
106 -
107 - return -EIO;
108 - }
109 -
110 - return 0;
111 -}
112 -
113 -static void __exit nslu2_power_exit(void)
114 -{
115 - if (!(machine_is_nslu2()))
116 - return;
117 -
118 - free_irq(NSLU2_RB_IRQ, NULL);
119 - free_irq(NSLU2_PB_IRQ, NULL);
120 -}
121 -
122 -module_init(nslu2_power_init);
123 -module_exit(nslu2_power_exit);
124 -
125 -MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
126 -MODULE_DESCRIPTION("NSLU2 Power/Reset driver");
127 -MODULE_LICENSE("GPL");
128 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/nslu2-setup.c
129 ===================================================================
130 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/nslu2-setup.c
131 +++ linux-2.6.24.7/arch/arm/mach-ixp4xx/nslu2-setup.c
132 @@ -3,22 +3,26 @@
133 *
134 * NSLU2 board-setup
135 *
136 - * based ixdp425-setup.c:
137 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
138 + *
139 + * based on ixdp425-setup.c:
140 * Copyright (C) 2003-2004 MontaVista Software, Inc.
141 + * based on nslu2-power.c:
142 + * Copyright (C) 2005 Tower Technologies
143 *
144 * Author: Mark Rakes <mrakes at mac.com>
145 * Author: Rod Whitby <rod@whitby.id.au>
146 + * Author: Alessandro Zummo <a.zummo@towertech.it>
147 * Maintainers: http://www.nslu2-linux.org/
148 *
149 - * Fixed missing init_time in MACHINE_START kas11 10/22/04
150 - * Changed to conform to new style __init ixdp425 kas11 10/22/04
151 */
152
153 #include <linux/if_ether.h>
154 -#include <linux/kernel.h>
155 +#include <linux/irq.h>
156 #include <linux/serial.h>
157 #include <linux/serial_8250.h>
158 #include <linux/leds.h>
159 +#include <linux/reboot.h>
160 #include <linux/i2c.h>
161 #include <linux/i2c-gpio.h>
162
163 @@ -27,6 +31,7 @@
164 #include <asm/mach/flash.h>
165 #include <asm/mach/time.h>
166 #include <asm/io.h>
167 +#include <asm/gpio.h>
168
169 static struct flash_platform_data nslu2_flash_data = {
170 .map_name = "cfi_probe",
171 @@ -181,6 +186,25 @@ static void nslu2_power_off(void)
172 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
173 }
174
175 +static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
176 +{
177 + /* Signal init to do the ctrlaltdel action, this will bypass init if
178 + * it hasn't started and do a kernel_restart.
179 + */
180 + ctrl_alt_del();
181 +
182 + return IRQ_HANDLED;
183 +}
184 +
185 +static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
186 +{
187 + /* This is the paper-clip reset, it shuts the machine down directly.
188 + */
189 + machine_power_off();
190 +
191 + return IRQ_HANDLED;
192 +}
193 +
194 static void __init nslu2_timer_init(void)
195 {
196 /* The xtal on this machine is non-standard. */
197 @@ -206,8 +230,6 @@ static void __init nslu2_init(void)
198 nslu2_flash_resource.end =
199 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
200
201 - pm_power_off = nslu2_power_off;
202 -
203 i2c_register_board_info(0, nslu2_i2c_board_info,
204 ARRAY_SIZE(nslu2_i2c_board_info));
205
206 @@ -220,6 +242,23 @@ static void __init nslu2_init(void)
207
208 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
209
210 + pm_power_off = nslu2_power_off;
211 +
212 + if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler,
213 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
214 + "NSLU2 reset button", NULL) < 0) {
215 +
216 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
217 + gpio_to_irq(NSLU2_RB_GPIO));
218 + }
219 +
220 + if (request_irq(gpio_to_irq(NSLU2_PB_GPIO), &nslu2_power_handler,
221 + IRQF_DISABLED | IRQF_TRIGGER_HIGH,
222 + "NSLU2 power button", NULL) < 0) {
223 +
224 + printk(KERN_DEBUG "Power Button IRQ %d not available\n",
225 + gpio_to_irq(NSLU2_PB_GPIO));
226 + }
227
228 /*
229 * Map in a portion of the flash and read the MAC address.
230 Index: linux-2.6.24.7/include/asm-arm/arch-ixp4xx/nslu2.h
231 ===================================================================
232 --- linux-2.6.24.7.orig/include/asm-arm/arch-ixp4xx/nslu2.h
233 +++ linux-2.6.24.7/include/asm-arm/arch-ixp4xx/nslu2.h
234 @@ -39,34 +39,17 @@
235
236 /* Buttons */
237
238 -#define NSLU2_PB_GPIO 5
239 +#define NSLU2_PB_GPIO 5 /* power button */
240 #define NSLU2_PO_GPIO 8 /* power off */
241 -#define NSLU2_RB_GPIO 12
242 -
243 -#define NSLU2_PB_IRQ IRQ_IXP4XX_GPIO5
244 -#define NSLU2_RB_IRQ IRQ_IXP4XX_GPIO12
245 -
246 -#define NSLU2_PB_BM (1L << NSLU2_PB_GPIO)
247 -#define NSLU2_PO_BM (1L << NSLU2_PO_GPIO)
248 -#define NSLU2_RB_BM (1L << NSLU2_RB_GPIO)
249 +#define NSLU2_RB_GPIO 12 /* reset button */
250
251 /* Buzzer */
252
253 #define NSLU2_GPIO_BUZZ 4
254 -#define NSLU2_BZ_BM (1L << NSLU2_GPIO_BUZZ)
255
256 /* LEDs */
257
258 #define NSLU2_LED_RED_GPIO 0
259 #define NSLU2_LED_GRN_GPIO 1
260 -
261 -#define NSLU2_LED_RED_BM (1L << NSLU2_LED_RED_GPIO)
262 -#define NSLU2_LED_GRN_BM (1L << NSLU2_LED_GRN_GPIO)
263 -
264 #define NSLU2_LED_DISK1_GPIO 3
265 #define NSLU2_LED_DISK2_GPIO 2
266 -
267 -#define NSLU2_LED_DISK1_BM (1L << NSLU2_LED_DISK1_GPIO)
268 -#define NSLU2_LED_DISK2_BM (1L << NSLU2_LED_DISK2_GPIO)
269 -
270 -
271 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/nas100d-power.c
272 ===================================================================
273 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/nas100d-power.c
274 +++ /dev/null
275 @@ -1,128 +0,0 @@
276 -/*
277 - * arch/arm/mach-ixp4xx/nas100d-power.c
278 - *
279 - * NAS 100d Power/Reset driver
280 - *
281 - * Copyright (C) 2005 Tower Technologies
282 - *
283 - * based on nas100d-io.c
284 - * Copyright (C) 2004 Karen Spearel
285 - *
286 - * Author: Alessandro Zummo <a.zummo@towertech.it>
287 - * Maintainers: http://www.nslu2-linux.org/
288 - *
289 - * This program is free software; you can redistribute it and/or modify
290 - * it under the terms of the GNU General Public License version 2 as
291 - * published by the Free Software Foundation.
292 - *
293 - */
294 -
295 -#include <linux/interrupt.h>
296 -#include <linux/irq.h>
297 -#include <linux/module.h>
298 -#include <linux/reboot.h>
299 -#include <linux/jiffies.h>
300 -#include <linux/timer.h>
301 -
302 -#include <asm/gpio.h>
303 -#include <asm/mach-types.h>
304 -
305 -/* This is used to make sure the power-button pusher is serious. The button
306 - * must be held until the value of this counter reaches zero.
307 - */
308 -static int power_button_countdown;
309 -
310 -/* Must hold the button down for at least this many counts to be processed */
311 -#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
312 -
313 -static void nas100d_power_handler(unsigned long data);
314 -static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
315 -
316 -static void nas100d_power_handler(unsigned long data)
317 -{
318 - /* This routine is called twice per second to check the
319 - * state of the power button.
320 - */
321 -
322 - if (gpio_get_value(NAS100D_PB_GPIO)) {
323 -
324 - /* IO Pin is 1 (button pushed) */
325 - if (power_button_countdown > 0)
326 - power_button_countdown--;
327 -
328 - } else {
329 -
330 - /* Done on button release, to allow for auto-power-on mods. */
331 - if (power_button_countdown == 0) {
332 - /* Signal init to do the ctrlaltdel action,
333 - * this will bypass init if it hasn't started
334 - * and do a kernel_restart.
335 - */
336 - ctrl_alt_del();
337 -
338 - /* Change the state of the power LED to "blink" */
339 - gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
340 - } else {
341 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
342 - }
343 - }
344 -
345 - mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
346 -}
347 -
348 -static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
349 -{
350 - /* This is the paper-clip reset, it shuts the machine down directly. */
351 - machine_power_off();
352 -
353 - return IRQ_HANDLED;
354 -}
355 -
356 -static int __init nas100d_power_init(void)
357 -{
358 - if (!(machine_is_nas100d()))
359 - return 0;
360 -
361 - set_irq_type(gpio_to_irq(NAS100D_RB_GPIO), IRQT_LOW);
362 -
363 - if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
364 - IRQF_DISABLED, "NAS100D reset button", NULL) < 0) {
365 -
366 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
367 - gpio_to_irq(NAS100D_RB_GPIO));
368 -
369 - return -EIO;
370 - }
371 -
372 - /* The power button on the Iomega NAS100d is on GPIO 14, but
373 - * it cannot handle interrupts on that GPIO line. So we'll
374 - * have to poll it with a kernel timer.
375 - */
376 -
377 - /* Make sure that the power button GPIO is set up as an input */
378 - gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
379 -
380 - /* Set the initial value for the power button IRQ handler */
381 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
382 -
383 - mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
384 -
385 - return 0;
386 -}
387 -
388 -static void __exit nas100d_power_exit(void)
389 -{
390 - if (!(machine_is_nas100d()))
391 - return;
392 -
393 - del_timer_sync(&nas100d_power_timer);
394 -
395 - free_irq(gpio_to_irq(NAS100D_RB_GPIO), NULL);
396 -}
397 -
398 -module_init(nas100d_power_init);
399 -module_exit(nas100d_power_exit);
400 -
401 -MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
402 -MODULE_DESCRIPTION("NAS100D Power/Reset driver");
403 -MODULE_LICENSE("GPL");
404 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/nas100d-setup.c
405 ===================================================================
406 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/nas100d-setup.c
407 +++ linux-2.6.24.7/arch/arm/mach-ixp4xx/nas100d-setup.c
408 @@ -3,8 +3,14 @@
409 *
410 * NAS 100d board-setup
411 *
412 - * based ixdp425-setup.c:
413 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
414 + *
415 + * based on ixdp425-setup.c:
416 * Copyright (C) 2003-2004 MontaVista Software, Inc.
417 + * based on nas100d-power.c:
418 + * Copyright (C) 2005 Tower Technologies
419 + * based on nas100d-io.c
420 + * Copyright (C) 2004 Karen Spearel
421 *
422 * Author: Alessandro Zummo <a.zummo@towertech.it>
423 * Author: Rod Whitby <rod@whitby.id.au>
424 @@ -13,10 +19,13 @@
425 */
426
427 #include <linux/if_ether.h>
428 -#include <linux/kernel.h>
429 +#include <linux/irq.h>
430 +#include <linux/jiffies.h>
431 +#include <linux/timer.h>
432 #include <linux/serial.h>
433 #include <linux/serial_8250.h>
434 #include <linux/leds.h>
435 +#include <linux/reboot.h>
436 #include <linux/i2c.h>
437 #include <linux/i2c-gpio.h>
438
439 @@ -24,6 +33,7 @@
440 #include <asm/mach/arch.h>
441 #include <asm/mach/flash.h>
442 #include <asm/io.h>
443 +#include <asm/gpio.h>
444
445 static struct flash_platform_data nas100d_flash_data = {
446 .map_name = "cfi_probe",
447 @@ -168,6 +178,57 @@ static void nas100d_power_off(void)
448 gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH);
449 }
450
451 +/* This is used to make sure the power-button pusher is serious. The button
452 + * must be held until the value of this counter reaches zero.
453 + */
454 +static int power_button_countdown;
455 +
456 +/* Must hold the button down for at least this many counts to be processed */
457 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
458 +
459 +static void nas100d_power_handler(unsigned long data);
460 +static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
461 +
462 +static void nas100d_power_handler(unsigned long data)
463 +{
464 + /* This routine is called twice per second to check the
465 + * state of the power button.
466 + */
467 +
468 + if (gpio_get_value(NAS100D_PB_GPIO)) {
469 +
470 + /* IO Pin is 1 (button pushed) */
471 + if (power_button_countdown > 0)
472 + power_button_countdown--;
473 +
474 + } else {
475 +
476 + /* Done on button release, to allow for auto-power-on mods. */
477 + if (power_button_countdown == 0) {
478 + /* Signal init to do the ctrlaltdel action,
479 + * this will bypass init if it hasn't started
480 + * and do a kernel_restart.
481 + */
482 + ctrl_alt_del();
483 +
484 + /* Change the state of the power LED to "blink" */
485 + gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
486 + } else {
487 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
488 + }
489 + }
490 +
491 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
492 +}
493 +
494 +static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
495 +{
496 + /* This is the paper-clip reset, it shuts the machine down directly. */
497 + machine_power_off();
498 +
499 + return IRQ_HANDLED;
500 +}
501 +
502 static void __init nas100d_init(void)
503 {
504 DECLARE_MAC_BUF(mac_buf);
505 @@ -183,8 +244,6 @@ static void __init nas100d_init(void)
506 nas100d_flash_resource.end =
507 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
508
509 - pm_power_off = nas100d_power_off;
510 -
511 i2c_register_board_info(0, nas100d_i2c_board_info,
512 ARRAY_SIZE(nas100d_i2c_board_info));
513
514 @@ -197,6 +256,29 @@ static void __init nas100d_init(void)
515
516 platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
517
518 + pm_power_off = nas100d_power_off;
519 +
520 + if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
521 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
522 + "NAS100D reset button", NULL) < 0) {
523 +
524 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
525 + gpio_to_irq(NAS100D_RB_GPIO));
526 + }
527 +
528 + /* The power button on the Iomega NAS100d is on GPIO 14, but
529 + * it cannot handle interrupts on that GPIO line. So we'll
530 + * have to poll it with a kernel timer.
531 + */
532 +
533 + /* Make sure that the power button GPIO is set up as an input */
534 + gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
535 +
536 + /* Set the initial value for the power button IRQ handler */
537 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
538 +
539 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
540 +
541 /*
542 * Map in a portion of the flash and read the MAC address.
543 * Since it is stored in BE in the flash itself, we need to
544 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/dsmg600-power.c
545 ===================================================================
546 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/dsmg600-power.c
547 +++ /dev/null
548 @@ -1,129 +0,0 @@
549 -/*
550 - * arch/arm/mach-ixp4xx/dsmg600-power.c
551 - *
552 - * DSM-G600 Power/Reset driver
553 - * Author: Michael Westerhof <mwester@dls.net>
554 - *
555 - * Based on nslu2-power.c
556 - * Copyright (C) 2005 Tower Technologies
557 - * Author: Alessandro Zummo <a.zummo@towertech.it>
558 - *
559 - * which was based on nslu2-io.c
560 - * Copyright (C) 2004 Karen Spearel
561 - *
562 - * Maintainers: http://www.nslu2-linux.org/
563 - *
564 - * This program is free software; you can redistribute it and/or modify
565 - * it under the terms of the GNU General Public License version 2 as
566 - * published by the Free Software Foundation.
567 - *
568 - */
569 -
570 -#include <linux/module.h>
571 -#include <linux/reboot.h>
572 -#include <linux/interrupt.h>
573 -#include <linux/irq.h>
574 -#include <linux/jiffies.h>
575 -#include <linux/timer.h>
576 -
577 -#include <asm/gpio.h>
578 -#include <asm/mach-types.h>
579 -
580 -/* This is used to make sure the power-button pusher is serious. The button
581 - * must be held until the value of this counter reaches zero.
582 - */
583 -static int power_button_countdown;
584 -
585 -/* Must hold the button down for at least this many counts to be processed */
586 -#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
587 -
588 -static void dsmg600_power_handler(unsigned long data);
589 -static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
590 -
591 -static void dsmg600_power_handler(unsigned long data)
592 -{
593 - /* This routine is called twice per second to check the
594 - * state of the power button.
595 - */
596 -
597 - if (gpio_get_value(DSMG600_PB_GPIO)) {
598 -
599 - /* IO Pin is 1 (button pushed) */
600 - if (power_button_countdown > 0)
601 - power_button_countdown--;
602 -
603 - } else {
604 -
605 - /* Done on button release, to allow for auto-power-on mods. */
606 - if (power_button_countdown == 0) {
607 - /* Signal init to do the ctrlaltdel action,
608 - * this will bypass init if it hasn't started
609 - * and do a kernel_restart.
610 - */
611 - ctrl_alt_del();
612 -
613 - /* Change the state of the power LED to "blink" */
614 - gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
615 - } else {
616 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
617 - }
618 - }
619 -
620 - mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
621 -}
622 -
623 -static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
624 -{
625 - /* This is the paper-clip reset, it shuts the machine down directly. */
626 - machine_power_off();
627 -
628 - return IRQ_HANDLED;
629 -}
630 -
631 -static int __init dsmg600_power_init(void)
632 -{
633 - if (!(machine_is_dsmg600()))
634 - return 0;
635 -
636 - if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
637 - IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
638 - NULL) < 0) {
639 -
640 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
641 - gpio_to_irq(DSMG600_RB_GPIO));
642 -
643 - return -EIO;
644 - }
645 -
646 - /* The power button on the D-Link DSM-G600 is on GPIO 15, but
647 - * it cannot handle interrupts on that GPIO line. So we'll
648 - * have to poll it with a kernel timer.
649 - */
650 -
651 - /* Make sure that the power button GPIO is set up as an input */
652 - gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
653 -
654 - /* Set the initial value for the power button IRQ handler */
655 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
656 -
657 - mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
658 -
659 - return 0;
660 -}
661 -
662 -static void __exit dsmg600_power_exit(void)
663 -{
664 - if (!(machine_is_dsmg600()))
665 - return;
666 -
667 - del_timer_sync(&dsmg600_power_timer);
668 -
669 - free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL);
670 -}
671 -
672 -module_init(dsmg600_power_init);
673 -module_exit(dsmg600_power_exit);
674 -
675 -MODULE_AUTHOR("Michael Westerhof <mwester@dls.net>");
676 -MODULE_DESCRIPTION("DSM-G600 Power/Reset driver");
677 -MODULE_LICENSE("GPL");
678 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/dsmg600-setup.c
679 ===================================================================
680 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/dsmg600-setup.c
681 +++ linux-2.6.24.7/arch/arm/mach-ixp4xx/dsmg600-setup.c
682 @@ -1,20 +1,29 @@
683 /*
684 * DSM-G600 board-setup
685 *
686 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
687 * Copyright (C) 2006 Tower Technologies
688 - * Author: Alessandro Zummo <a.zummo@towertech.it>
689 *
690 - * based ixdp425-setup.c:
691 + * based on ixdp425-setup.c:
692 * Copyright (C) 2003-2004 MontaVista Software, Inc.
693 + * based on nslu2-power.c:
694 + * Copyright (C) 2005 Tower Technologies
695 + * based on nslu2-io.c:
696 + * Copyright (C) 2004 Karen Spearel
697 *
698 * Author: Alessandro Zummo <a.zummo@towertech.it>
699 + * Author: Michael Westerhof <mwester@dls.net>
700 + * Author: Rod Whitby <rod@whitby.id.au>
701 * Maintainers: http://www.nslu2-linux.org/
702 */
703
704 -#include <linux/kernel.h>
705 +#include <linux/irq.h>
706 +#include <linux/jiffies.h>
707 +#include <linux/timer.h>
708 #include <linux/serial.h>
709 #include <linux/serial_8250.h>
710 #include <linux/leds.h>
711 +#include <linux/reboot.h>
712 #include <linux/i2c.h>
713 #include <linux/i2c-gpio.h>
714
715 @@ -22,6 +31,7 @@
716 #include <asm/mach/arch.h>
717 #include <asm/mach/flash.h>
718 #include <asm/mach/time.h>
719 +#include <asm/gpio.h>
720
721 static struct flash_platform_data dsmg600_flash_data = {
722 .map_name = "cfi_probe",
723 @@ -140,6 +150,57 @@ static void dsmg600_power_off(void)
724 gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
725 }
726
727 +/* This is used to make sure the power-button pusher is serious. The button
728 + * must be held until the value of this counter reaches zero.
729 + */
730 +static int power_button_countdown;
731 +
732 +/* Must hold the button down for at least this many counts to be processed */
733 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
734 +
735 +static void dsmg600_power_handler(unsigned long data);
736 +static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
737 +
738 +static void dsmg600_power_handler(unsigned long data)
739 +{
740 + /* This routine is called twice per second to check the
741 + * state of the power button.
742 + */
743 +
744 + if (gpio_get_value(DSMG600_PB_GPIO)) {
745 +
746 + /* IO Pin is 1 (button pushed) */
747 + if (power_button_countdown > 0)
748 + power_button_countdown--;
749 +
750 + } else {
751 +
752 + /* Done on button release, to allow for auto-power-on mods. */
753 + if (power_button_countdown == 0) {
754 + /* Signal init to do the ctrlaltdel action,
755 + * this will bypass init if it hasn't started
756 + * and do a kernel_restart.
757 + */
758 + ctrl_alt_del();
759 +
760 + /* Change the state of the power LED to "blink" */
761 + gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
762 + } else {
763 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
764 + }
765 + }
766 +
767 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
768 +}
769 +
770 +static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
771 +{
772 + /* This is the paper-clip reset, it shuts the machine down directly. */
773 + machine_power_off();
774 +
775 + return IRQ_HANDLED;
776 +}
777 +
778 static void __init dsmg600_timer_init(void)
779 {
780 /* The xtal on this machine is non-standard. */
781 @@ -164,8 +225,6 @@ static void __init dsmg600_init(void)
782 dsmg600_flash_resource.end =
783 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
784
785 - pm_power_off = dsmg600_power_off;
786 -
787 i2c_register_board_info(0, dsmg600_i2c_board_info,
788 ARRAY_SIZE(dsmg600_i2c_board_info));
789
790 @@ -176,6 +235,29 @@ static void __init dsmg600_init(void)
791 (void)platform_device_register(&dsmg600_uart);
792
793 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
794 +
795 + pm_power_off = dsmg600_power_off;
796 +
797 + if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
798 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
799 + "DSM-G600 reset button", NULL) < 0) {
800 +
801 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
802 + gpio_to_irq(DSMG600_RB_GPIO));
803 + }
804 +
805 + /* The power button on the D-Link DSM-G600 is on GPIO 15, but
806 + * it cannot handle interrupts on that GPIO line. So we'll
807 + * have to poll it with a kernel timer.
808 + */
809 +
810 + /* Make sure that the power button GPIO is set up as an input */
811 + gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
812 +
813 + /* Set the initial value for the power button IRQ handler */
814 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
815 +
816 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
817 }
818
819 MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
This page took 0.076996 seconds and 5 git commands to generate.