1 From: Rod Whitby <rod@whitby.id.au>
2 Subject: ixp4xx: Merge nslu2-power.c into nslu2-setup.c (Patch #4807)
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.
9 Signed-off-by: Rod Whitby <rod@whitby.id.au>
12 KernelVersion: v2.6.24-1917-gaf66bd3
14 Index: linux-2.6.24-armeb/arch/arm/mach-ixp4xx/Makefile
15 ===================================================================
16 --- linux-2.6.24-armeb.orig/arch/arm/mach-ixp4xx/Makefile 2008-02-03 22:45:22.000000000 +1030
17 +++ linux-2.6.24-armeb/arch/arm/mach-ixp4xx/Makefile 2008-02-03 22:45:44.000000000 +1030
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_NSLU2) += nslu2-setup.o
24 obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
25 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
26 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
27 Index: linux-2.6.24-armeb/arch/arm/mach-ixp4xx/nslu2-power.c
28 ===================================================================
29 --- linux-2.6.24-armeb.orig/arch/arm/mach-ixp4xx/nslu2-power.c 2008-02-03 22:45:10.000000000 +1030
30 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000
33 - * arch/arm/mach-ixp4xx/nslu2-power.c
35 - * NSLU2 Power/Reset driver
37 - * Copyright (C) 2005 Tower Technologies
39 - * based on nslu2-io.c
40 - * Copyright (C) 2004 Karen Spearel
42 - * Author: Alessandro Zummo <a.zummo@towertech.it>
43 - * Maintainers: http://www.nslu2-linux.org/
45 - * This program is free software; you can redistribute it and/or modify
46 - * it under the terms of the GNU General Public License version 2 as
47 - * published by the Free Software Foundation.
51 -#include <linux/module.h>
52 -#include <linux/reboot.h>
53 -#include <linux/irq.h>
54 -#include <linux/interrupt.h>
55 -#include <linux/reboot.h>
57 -#include <asm/mach-types.h>
59 -static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
61 - /* Signal init to do the ctrlaltdel action, this will bypass init if
62 - * it hasn't started and do a kernel_restart.
69 -static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
71 - /* This is the paper-clip reset, it shuts the machine down directly.
73 - machine_power_off();
78 -static int __init nslu2_power_init(void)
80 - if (!(machine_is_nslu2()))
83 - *IXP4XX_GPIO_GPISR = 0x20400000; /* read the 2 irqs to clr */
85 - set_irq_type(NSLU2_RB_IRQ, IRQT_LOW);
86 - set_irq_type(NSLU2_PB_IRQ, IRQT_HIGH);
88 - if (request_irq(NSLU2_RB_IRQ, &nslu2_reset_handler,
89 - IRQF_DISABLED, "NSLU2 reset button", NULL) < 0) {
91 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
97 - if (request_irq(NSLU2_PB_IRQ, &nslu2_power_handler,
98 - IRQF_DISABLED, "NSLU2 power button", NULL) < 0) {
100 - printk(KERN_DEBUG "Power Button IRQ %d not available\n",
109 -static void __exit nslu2_power_exit(void)
111 - if (!(machine_is_nslu2()))
114 - free_irq(NSLU2_RB_IRQ, NULL);
115 - free_irq(NSLU2_PB_IRQ, NULL);
118 -module_init(nslu2_power_init);
119 -module_exit(nslu2_power_exit);
121 -MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
122 -MODULE_DESCRIPTION("NSLU2 Power/Reset driver");
123 -MODULE_LICENSE("GPL");
124 Index: linux-2.6.24-armeb/arch/arm/mach-ixp4xx/nslu2-setup.c
125 ===================================================================
126 --- linux-2.6.24-armeb.orig/arch/arm/mach-ixp4xx/nslu2-setup.c 2008-02-03 22:45:22.000000000 +1030
127 +++ linux-2.6.24-armeb/arch/arm/mach-ixp4xx/nslu2-setup.c 2008-02-03 22:45:44.000000000 +1030
132 - * based ixdp425-setup.c:
133 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
135 + * based on ixdp425-setup.c:
136 * Copyright (C) 2003-2004 MontaVista Software, Inc.
137 + * based on nslu2-power.c:
138 + * Copyright (C) 2005 Tower Technologies
140 * Author: Mark Rakes <mrakes at mac.com>
141 * Author: Rod Whitby <rod@whitby.id.au>
142 + * Author: Alessandro Zummo <a.zummo@towertech.it>
143 * Maintainers: http://www.nslu2-linux.org/
145 - * Fixed missing init_time in MACHINE_START kas11 10/22/04
146 - * Changed to conform to new style __init ixdp425 kas11 10/22/04
149 #include <linux/if_ether.h>
150 -#include <linux/kernel.h>
151 +#include <linux/irq.h>
152 #include <linux/serial.h>
153 #include <linux/serial_8250.h>
154 #include <linux/leds.h>
155 +#include <linux/reboot.h>
156 #include <linux/i2c.h>
157 #include <linux/i2c-gpio.h>
160 #include <asm/mach/flash.h>
161 #include <asm/mach/time.h>
163 +#include <asm/gpio.h>
165 static struct flash_platform_data nslu2_flash_data = {
166 .map_name = "cfi_probe",
168 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
171 +static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
173 + /* Signal init to do the ctrlaltdel action, this will bypass init if
174 + * it hasn't started and do a kernel_restart.
178 + return IRQ_HANDLED;
181 +static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
183 + /* This is the paper-clip reset, it shuts the machine down directly.
185 + machine_power_off();
187 + return IRQ_HANDLED;
190 static void __init nslu2_timer_init(void)
192 /* The xtal on this machine is non-standard. */
194 nslu2_flash_resource.end =
195 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
197 - pm_power_off = nslu2_power_off;
199 i2c_register_board_info(0, nslu2_i2c_board_info,
200 ARRAY_SIZE(nslu2_i2c_board_info));
204 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
206 + pm_power_off = nslu2_power_off;
208 + if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler,
209 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
210 + "NSLU2 reset button", NULL) < 0) {
212 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
213 + gpio_to_irq(NSLU2_RB_GPIO));
216 + if (request_irq(gpio_to_irq(NSLU2_PB_GPIO), &nslu2_power_handler,
217 + IRQF_DISABLED | IRQF_TRIGGER_HIGH,
218 + "NSLU2 power button", NULL) < 0) {
220 + printk(KERN_DEBUG "Power Button IRQ %d not available\n",
221 + gpio_to_irq(NSLU2_PB_GPIO));
225 * Map in a portion of the flash and read the MAC address.
226 Index: linux-2.6.24-armeb/include/asm-arm/arch-ixp4xx/nslu2.h
227 ===================================================================
228 --- linux-2.6.24-armeb.orig/include/asm-arm/arch-ixp4xx/nslu2.h 2008-02-03 22:45:11.000000000 +1030
229 +++ linux-2.6.24-armeb/include/asm-arm/arch-ixp4xx/nslu2.h 2008-02-03 22:45:44.000000000 +1030
234 -#define NSLU2_PB_GPIO 5
235 +#define NSLU2_PB_GPIO 5 /* power button */
236 #define NSLU2_PO_GPIO 8 /* power off */
237 -#define NSLU2_RB_GPIO 12
239 -#define NSLU2_PB_IRQ IRQ_IXP4XX_GPIO5
240 -#define NSLU2_RB_IRQ IRQ_IXP4XX_GPIO12
242 -#define NSLU2_PB_BM (1L << NSLU2_PB_GPIO)
243 -#define NSLU2_PO_BM (1L << NSLU2_PO_GPIO)
244 -#define NSLU2_RB_BM (1L << NSLU2_RB_GPIO)
245 +#define NSLU2_RB_GPIO 12 /* reset button */
249 #define NSLU2_GPIO_BUZZ 4
250 -#define NSLU2_BZ_BM (1L << NSLU2_GPIO_BUZZ)
254 #define NSLU2_LED_RED_GPIO 0
255 #define NSLU2_LED_GRN_GPIO 1
257 -#define NSLU2_LED_RED_BM (1L << NSLU2_LED_RED_GPIO)
258 -#define NSLU2_LED_GRN_BM (1L << NSLU2_LED_GRN_GPIO)
260 #define NSLU2_LED_DISK1_GPIO 3
261 #define NSLU2_LED_DISK2_GPIO 2
263 -#define NSLU2_LED_DISK1_BM (1L << NSLU2_LED_DISK1_GPIO)
264 -#define NSLU2_LED_DISK2_BM (1L << NSLU2_LED_DISK2_GPIO)
267 From: Rod Whitby <rod@whitby.id.au>
268 Subject: ixp4xx: Merge nas100d-power.c into nas100d-setup.c (Patch #4808)
270 There is no reason to have power control in a separate file from the
271 board setup code. Merge it back into the board setup file and remove
272 superfluous header includes.
274 Signed-off-by: Rod Whitby <rod@whitby.id.au>
277 KernelVersion: 2.6.24-git9
279 diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile
280 index 4fc7316..a7880ab 100644
281 --- a/arch/arm/mach-ixp4xx/Makefile
282 +++ b/arch/arm/mach-ixp4xx/Makefile
283 @@ -24,7 +24,7 @@ obj-$(CONFIG_MACH_IXDPG425) += coyote-setup.o
284 obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
285 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
286 obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o
287 -obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
288 +obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o
289 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
290 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
291 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
292 diff --git a/arch/arm/mach-ixp4xx/nas100d-power.c b/arch/arm/mach-ixp4xx/nas100d-power.c
293 deleted file mode 100644
294 index 4c1c01b..0000000
295 --- a/arch/arm/mach-ixp4xx/nas100d-power.c
299 - * arch/arm/mach-ixp4xx/nas100d-power.c
301 - * NAS 100d Power/Reset driver
303 - * Copyright (C) 2005 Tower Technologies
305 - * based on nas100d-io.c
306 - * Copyright (C) 2004 Karen Spearel
308 - * Author: Alessandro Zummo <a.zummo@towertech.it>
309 - * Maintainers: http://www.nslu2-linux.org/
311 - * This program is free software; you can redistribute it and/or modify
312 - * it under the terms of the GNU General Public License version 2 as
313 - * published by the Free Software Foundation.
317 -#include <linux/interrupt.h>
318 -#include <linux/irq.h>
319 -#include <linux/module.h>
320 -#include <linux/reboot.h>
321 -#include <linux/jiffies.h>
322 -#include <linux/timer.h>
324 -#include <asm/gpio.h>
325 -#include <asm/mach-types.h>
327 -/* This is used to make sure the power-button pusher is serious. The button
328 - * must be held until the value of this counter reaches zero.
330 -static int power_button_countdown;
332 -/* Must hold the button down for at least this many counts to be processed */
333 -#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
335 -static void nas100d_power_handler(unsigned long data);
336 -static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
338 -static void nas100d_power_handler(unsigned long data)
340 - /* This routine is called twice per second to check the
341 - * state of the power button.
344 - if (gpio_get_value(NAS100D_PB_GPIO)) {
346 - /* IO Pin is 1 (button pushed) */
347 - if (power_button_countdown > 0)
348 - power_button_countdown--;
352 - /* Done on button release, to allow for auto-power-on mods. */
353 - if (power_button_countdown == 0) {
354 - /* Signal init to do the ctrlaltdel action,
355 - * this will bypass init if it hasn't started
356 - * and do a kernel_restart.
360 - /* Change the state of the power LED to "blink" */
361 - gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
363 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
367 - mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
370 -static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
372 - /* This is the paper-clip reset, it shuts the machine down directly. */
373 - machine_power_off();
375 - return IRQ_HANDLED;
378 -static int __init nas100d_power_init(void)
380 - if (!(machine_is_nas100d()))
383 - set_irq_type(gpio_to_irq(NAS100D_RB_GPIO), IRQT_LOW);
385 - if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
386 - IRQF_DISABLED, "NAS100D reset button", NULL) < 0) {
388 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
389 - gpio_to_irq(NAS100D_RB_GPIO));
394 - /* The power button on the Iomega NAS100d is on GPIO 14, but
395 - * it cannot handle interrupts on that GPIO line. So we'll
396 - * have to poll it with a kernel timer.
399 - /* Make sure that the power button GPIO is set up as an input */
400 - gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
402 - /* Set the initial value for the power button IRQ handler */
403 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
405 - mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
410 -static void __exit nas100d_power_exit(void)
412 - if (!(machine_is_nas100d()))
415 - del_timer_sync(&nas100d_power_timer);
417 - free_irq(gpio_to_irq(NAS100D_RB_GPIO), NULL);
420 -module_init(nas100d_power_init);
421 -module_exit(nas100d_power_exit);
423 -MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
424 -MODULE_DESCRIPTION("NAS100D Power/Reset driver");
425 -MODULE_LICENSE("GPL");
426 diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
427 index a432226..4cecae8 100644
428 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c
429 +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
432 * NAS 100d board-setup
434 - * based ixdp425-setup.c:
435 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
437 + * based on ixdp425-setup.c:
438 * Copyright (C) 2003-2004 MontaVista Software, Inc.
439 + * based on nas100d-power.c:
440 + * Copyright (C) 2005 Tower Technologies
441 + * based on nas100d-io.c
442 + * Copyright (C) 2004 Karen Spearel
444 * Author: Alessandro Zummo <a.zummo@towertech.it>
445 * Author: Rod Whitby <rod@whitby.id.au>
449 #include <linux/if_ether.h>
450 -#include <linux/kernel.h>
451 +#include <linux/irq.h>
452 +#include <linux/jiffies.h>
453 +#include <linux/timer.h>
454 #include <linux/serial.h>
455 #include <linux/serial_8250.h>
456 #include <linux/leds.h>
457 +#include <linux/reboot.h>
458 #include <linux/i2c.h>
459 #include <linux/i2c-gpio.h>
462 #include <asm/mach/arch.h>
463 #include <asm/mach/flash.h>
465 +#include <asm/gpio.h>
467 static struct flash_platform_data nas100d_flash_data = {
468 .map_name = "cfi_probe",
469 @@ -168,6 +178,57 @@ static void nas100d_power_off(void)
470 gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH);
473 +/* This is used to make sure the power-button pusher is serious. The button
474 + * must be held until the value of this counter reaches zero.
476 +static int power_button_countdown;
478 +/* Must hold the button down for at least this many counts to be processed */
479 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
481 +static void nas100d_power_handler(unsigned long data);
482 +static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
484 +static void nas100d_power_handler(unsigned long data)
486 + /* This routine is called twice per second to check the
487 + * state of the power button.
490 + if (gpio_get_value(NAS100D_PB_GPIO)) {
492 + /* IO Pin is 1 (button pushed) */
493 + if (power_button_countdown > 0)
494 + power_button_countdown--;
498 + /* Done on button release, to allow for auto-power-on mods. */
499 + if (power_button_countdown == 0) {
500 + /* Signal init to do the ctrlaltdel action,
501 + * this will bypass init if it hasn't started
502 + * and do a kernel_restart.
506 + /* Change the state of the power LED to "blink" */
507 + gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
509 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
513 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
516 +static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
518 + /* This is the paper-clip reset, it shuts the machine down directly. */
519 + machine_power_off();
521 + return IRQ_HANDLED;
524 static void __init nas100d_init(void)
526 DECLARE_MAC_BUF(mac_buf);
527 @@ -183,8 +244,6 @@ static void __init nas100d_init(void)
528 nas100d_flash_resource.end =
529 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
531 - pm_power_off = nas100d_power_off;
533 i2c_register_board_info(0, nas100d_i2c_board_info,
534 ARRAY_SIZE(nas100d_i2c_board_info));
536 @@ -197,6 +256,29 @@ static void __init nas100d_init(void)
538 platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
540 + pm_power_off = nas100d_power_off;
542 + if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
543 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
544 + "NAS100D reset button", NULL) < 0) {
546 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
547 + gpio_to_irq(NAS100D_RB_GPIO));
550 + /* The power button on the Iomega NAS100d is on GPIO 14, but
551 + * it cannot handle interrupts on that GPIO line. So we'll
552 + * have to poll it with a kernel timer.
555 + /* Make sure that the power button GPIO is set up as an input */
556 + gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
558 + /* Set the initial value for the power button IRQ handler */
559 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
561 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
564 * Map in a portion of the flash and read the MAC address.
565 * Since it is stored in BE in the flash itself, we need to
569 From: Rod Whitby <rod@whitby.id.au>
570 Subject: ixp4xx: Merge dsmg600-power.c into dsmg600-setup.c (Patch #4809)
572 There is no reason to have power control in a separate file from the
573 board setup code. Merge it back into the board setup file and remove
574 superfluous header includes.
576 Signed-off-by: Rod Whitby <rod@whitby.id.au>
579 KernelVersion: 2.6.24-git9
581 diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile
582 index a7880ab..c195688 100644
583 --- a/arch/arm/mach-ixp4xx/Makefile
584 +++ b/arch/arm/mach-ixp4xx/Makefile
585 @@ -25,7 +25,7 @@ obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
586 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
587 obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o
588 obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o
589 -obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
590 +obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o
591 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
592 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
594 diff --git a/arch/arm/mach-ixp4xx/dsmg600-power.c b/arch/arm/mach-ixp4xx/dsmg600-power.c
595 deleted file mode 100644
596 index db63987..0000000
597 --- a/arch/arm/mach-ixp4xx/dsmg600-power.c
601 - * arch/arm/mach-ixp4xx/dsmg600-power.c
603 - * DSM-G600 Power/Reset driver
604 - * Author: Michael Westerhof <mwester@dls.net>
606 - * Based on nslu2-power.c
607 - * Copyright (C) 2005 Tower Technologies
608 - * Author: Alessandro Zummo <a.zummo@towertech.it>
610 - * which was based on nslu2-io.c
611 - * Copyright (C) 2004 Karen Spearel
613 - * Maintainers: http://www.nslu2-linux.org/
615 - * This program is free software; you can redistribute it and/or modify
616 - * it under the terms of the GNU General Public License version 2 as
617 - * published by the Free Software Foundation.
621 -#include <linux/module.h>
622 -#include <linux/reboot.h>
623 -#include <linux/interrupt.h>
624 -#include <linux/irq.h>
625 -#include <linux/jiffies.h>
626 -#include <linux/timer.h>
628 -#include <asm/gpio.h>
629 -#include <asm/mach-types.h>
631 -/* This is used to make sure the power-button pusher is serious. The button
632 - * must be held until the value of this counter reaches zero.
634 -static int power_button_countdown;
636 -/* Must hold the button down for at least this many counts to be processed */
637 -#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
639 -static void dsmg600_power_handler(unsigned long data);
640 -static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
642 -static void dsmg600_power_handler(unsigned long data)
644 - /* This routine is called twice per second to check the
645 - * state of the power button.
648 - if (gpio_get_value(DSMG600_PB_GPIO)) {
650 - /* IO Pin is 1 (button pushed) */
651 - if (power_button_countdown > 0)
652 - power_button_countdown--;
656 - /* Done on button release, to allow for auto-power-on mods. */
657 - if (power_button_countdown == 0) {
658 - /* Signal init to do the ctrlaltdel action,
659 - * this will bypass init if it hasn't started
660 - * and do a kernel_restart.
664 - /* Change the state of the power LED to "blink" */
665 - gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
667 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
671 - mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
674 -static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
676 - /* This is the paper-clip reset, it shuts the machine down directly. */
677 - machine_power_off();
679 - return IRQ_HANDLED;
682 -static int __init dsmg600_power_init(void)
684 - if (!(machine_is_dsmg600()))
687 - if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
688 - IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
691 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
692 - gpio_to_irq(DSMG600_RB_GPIO));
697 - /* The power button on the D-Link DSM-G600 is on GPIO 15, but
698 - * it cannot handle interrupts on that GPIO line. So we'll
699 - * have to poll it with a kernel timer.
702 - /* Make sure that the power button GPIO is set up as an input */
703 - gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
705 - /* Set the initial value for the power button IRQ handler */
706 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
708 - mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
713 -static void __exit dsmg600_power_exit(void)
715 - if (!(machine_is_dsmg600()))
718 - del_timer_sync(&dsmg600_power_timer);
720 - free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL);
723 -module_init(dsmg600_power_init);
724 -module_exit(dsmg600_power_exit);
726 -MODULE_AUTHOR("Michael Westerhof <mwester@dls.net>");
727 -MODULE_DESCRIPTION("DSM-G600 Power/Reset driver");
728 -MODULE_LICENSE("GPL");
729 diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c
730 index d0e1295..6886596 100644
731 --- a/arch/arm/mach-ixp4xx/dsmg600-setup.c
732 +++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c
735 * DSM-G600 board-setup
737 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
738 * Copyright (C) 2006 Tower Technologies
739 - * Author: Alessandro Zummo <a.zummo@towertech.it>
741 - * based ixdp425-setup.c:
742 + * based on ixdp425-setup.c:
743 * Copyright (C) 2003-2004 MontaVista Software, Inc.
744 + * based on nslu2-power.c:
745 + * Copyright (C) 2005 Tower Technologies
746 + * based on nslu2-io.c:
747 + * Copyright (C) 2004 Karen Spearel
749 * Author: Alessandro Zummo <a.zummo@towertech.it>
750 + * Author: Michael Westerhof <mwester@dls.net>
751 + * Author: Rod Whitby <rod@whitby.id.au>
752 * Maintainers: http://www.nslu2-linux.org/
755 -#include <linux/kernel.h>
756 +#include <linux/irq.h>
757 +#include <linux/jiffies.h>
758 +#include <linux/timer.h>
759 #include <linux/serial.h>
760 #include <linux/serial_8250.h>
761 #include <linux/leds.h>
762 +#include <linux/reboot.h>
763 #include <linux/i2c.h>
764 #include <linux/i2c-gpio.h>
767 #include <asm/mach/arch.h>
768 #include <asm/mach/flash.h>
769 #include <asm/mach/time.h>
770 +#include <asm/gpio.h>
772 static struct flash_platform_data dsmg600_flash_data = {
773 .map_name = "cfi_probe",
774 @@ -140,6 +150,57 @@ static void dsmg600_power_off(void)
775 gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
778 +/* This is used to make sure the power-button pusher is serious. The button
779 + * must be held until the value of this counter reaches zero.
781 +static int power_button_countdown;
783 +/* Must hold the button down for at least this many counts to be processed */
784 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
786 +static void dsmg600_power_handler(unsigned long data);
787 +static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
789 +static void dsmg600_power_handler(unsigned long data)
791 + /* This routine is called twice per second to check the
792 + * state of the power button.
795 + if (gpio_get_value(DSMG600_PB_GPIO)) {
797 + /* IO Pin is 1 (button pushed) */
798 + if (power_button_countdown > 0)
799 + power_button_countdown--;
803 + /* Done on button release, to allow for auto-power-on mods. */
804 + if (power_button_countdown == 0) {
805 + /* Signal init to do the ctrlaltdel action,
806 + * this will bypass init if it hasn't started
807 + * and do a kernel_restart.
811 + /* Change the state of the power LED to "blink" */
812 + gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
814 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
818 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
821 +static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
823 + /* This is the paper-clip reset, it shuts the machine down directly. */
824 + machine_power_off();
826 + return IRQ_HANDLED;
829 static void __init dsmg600_timer_init(void)
831 /* The xtal on this machine is non-standard. */
832 @@ -164,8 +225,6 @@ static void __init dsmg600_init(void)
833 dsmg600_flash_resource.end =
834 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
836 - pm_power_off = dsmg600_power_off;
838 i2c_register_board_info(0, dsmg600_i2c_board_info,
839 ARRAY_SIZE(dsmg600_i2c_board_info));
841 @@ -176,6 +235,29 @@ static void __init dsmg600_init(void)
842 (void)platform_device_register(&dsmg600_uart);
844 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
846 + pm_power_off = dsmg600_power_off;
848 + if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
849 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
850 + "DSM-G600 reset button", NULL) < 0) {
852 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
853 + gpio_to_irq(DSMG600_RB_GPIO));
856 + /* The power button on the D-Link DSM-G600 is on GPIO 15, but
857 + * it cannot handle interrupts on that GPIO line. So we'll
858 + * have to poll it with a kernel timer.
861 + /* Make sure that the power button GPIO is set up as an input */
862 + gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
864 + /* Set the initial value for the power button IRQ handler */
865 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
867 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
870 MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")