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.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
37 - * arch/arm/mach-ixp4xx/nslu2-power.c
39 - * NSLU2 Power/Reset driver
41 - * Copyright (C) 2005 Tower Technologies
43 - * based on nslu2-io.c
44 - * Copyright (C) 2004 Karen Spearel
46 - * Author: Alessandro Zummo <a.zummo@towertech.it>
47 - * Maintainers: http://www.nslu2-linux.org/
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.
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>
61 -#include <asm/mach-types.h>
63 -static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
65 - /* Signal init to do the ctrlaltdel action, this will bypass init if
66 - * it hasn't started and do a kernel_restart.
73 -static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
75 - /* This is the paper-clip reset, it shuts the machine down directly.
77 - machine_power_off();
82 -static int __init nslu2_power_init(void)
84 - if (!(machine_is_nslu2()))
87 - *IXP4XX_GPIO_GPISR = 0x20400000; /* read the 2 irqs to clr */
89 - set_irq_type(NSLU2_RB_IRQ, IRQT_LOW);
90 - set_irq_type(NSLU2_PB_IRQ, IRQT_HIGH);
92 - if (request_irq(NSLU2_RB_IRQ, &nslu2_reset_handler,
93 - IRQF_DISABLED, "NSLU2 reset button", NULL) < 0) {
95 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
101 - if (request_irq(NSLU2_PB_IRQ, &nslu2_power_handler,
102 - IRQF_DISABLED, "NSLU2 power button", NULL) < 0) {
104 - printk(KERN_DEBUG "Power Button IRQ %d not available\n",
113 -static void __exit nslu2_power_exit(void)
115 - if (!(machine_is_nslu2()))
118 - free_irq(NSLU2_RB_IRQ, NULL);
119 - free_irq(NSLU2_PB_IRQ, NULL);
122 -module_init(nslu2_power_init);
123 -module_exit(nslu2_power_exit);
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
136 - * based ixdp425-setup.c:
137 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
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
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/
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
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>
164 #include <asm/mach/flash.h>
165 #include <asm/mach/time.h>
167 +#include <asm/gpio.h>
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);
175 +static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
177 + /* Signal init to do the ctrlaltdel action, this will bypass init if
178 + * it hasn't started and do a kernel_restart.
182 + return IRQ_HANDLED;
185 +static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
187 + /* This is the paper-clip reset, it shuts the machine down directly.
189 + machine_power_off();
191 + return IRQ_HANDLED;
194 static void __init nslu2_timer_init(void)
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;
201 - pm_power_off = nslu2_power_off;
203 i2c_register_board_info(0, nslu2_i2c_board_info,
204 ARRAY_SIZE(nslu2_i2c_board_info));
206 @@ -220,6 +242,23 @@ static void __init nslu2_init(void)
208 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
210 + pm_power_off = nslu2_power_off;
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) {
216 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
217 + gpio_to_irq(NSLU2_RB_GPIO));
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) {
224 + printk(KERN_DEBUG "Power Button IRQ %d not available\n",
225 + gpio_to_irq(NSLU2_PB_GPIO));
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
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
243 -#define NSLU2_PB_IRQ IRQ_IXP4XX_GPIO5
244 -#define NSLU2_RB_IRQ IRQ_IXP4XX_GPIO12
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 */
253 #define NSLU2_GPIO_BUZZ 4
254 -#define NSLU2_BZ_BM (1L << NSLU2_GPIO_BUZZ)
258 #define NSLU2_LED_RED_GPIO 0
259 #define NSLU2_LED_GRN_GPIO 1
261 -#define NSLU2_LED_RED_BM (1L << NSLU2_LED_RED_GPIO)
262 -#define NSLU2_LED_GRN_BM (1L << NSLU2_LED_GRN_GPIO)
264 #define NSLU2_LED_DISK1_GPIO 3
265 #define NSLU2_LED_DISK2_GPIO 2
267 -#define NSLU2_LED_DISK1_BM (1L << NSLU2_LED_DISK1_GPIO)
268 -#define NSLU2_LED_DISK2_BM (1L << NSLU2_LED_DISK2_GPIO)
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
277 - * arch/arm/mach-ixp4xx/nas100d-power.c
279 - * NAS 100d Power/Reset driver
281 - * Copyright (C) 2005 Tower Technologies
283 - * based on nas100d-io.c
284 - * Copyright (C) 2004 Karen Spearel
286 - * Author: Alessandro Zummo <a.zummo@towertech.it>
287 - * Maintainers: http://www.nslu2-linux.org/
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.
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>
302 -#include <asm/gpio.h>
303 -#include <asm/mach-types.h>
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.
308 -static int power_button_countdown;
310 -/* Must hold the button down for at least this many counts to be processed */
311 -#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
313 -static void nas100d_power_handler(unsigned long data);
314 -static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
316 -static void nas100d_power_handler(unsigned long data)
318 - /* This routine is called twice per second to check the
319 - * state of the power button.
322 - if (gpio_get_value(NAS100D_PB_GPIO)) {
324 - /* IO Pin is 1 (button pushed) */
325 - if (power_button_countdown > 0)
326 - power_button_countdown--;
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.
338 - /* Change the state of the power LED to "blink" */
339 - gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
341 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
345 - mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
348 -static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
350 - /* This is the paper-clip reset, it shuts the machine down directly. */
351 - machine_power_off();
353 - return IRQ_HANDLED;
356 -static int __init nas100d_power_init(void)
358 - if (!(machine_is_nas100d()))
361 - set_irq_type(gpio_to_irq(NAS100D_RB_GPIO), IRQT_LOW);
363 - if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
364 - IRQF_DISABLED, "NAS100D reset button", NULL) < 0) {
366 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
367 - gpio_to_irq(NAS100D_RB_GPIO));
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.
377 - /* Make sure that the power button GPIO is set up as an input */
378 - gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
380 - /* Set the initial value for the power button IRQ handler */
381 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
383 - mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
388 -static void __exit nas100d_power_exit(void)
390 - if (!(machine_is_nas100d()))
393 - del_timer_sync(&nas100d_power_timer);
395 - free_irq(gpio_to_irq(NAS100D_RB_GPIO), NULL);
398 -module_init(nas100d_power_init);
399 -module_exit(nas100d_power_exit);
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
410 * NAS 100d board-setup
412 - * based ixdp425-setup.c:
413 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
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
422 * Author: Alessandro Zummo <a.zummo@towertech.it>
423 * Author: Rod Whitby <rod@whitby.id.au>
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>
440 #include <asm/mach/arch.h>
441 #include <asm/mach/flash.h>
443 +#include <asm/gpio.h>
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);
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.
454 +static int power_button_countdown;
456 +/* Must hold the button down for at least this many counts to be processed */
457 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
459 +static void nas100d_power_handler(unsigned long data);
460 +static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
462 +static void nas100d_power_handler(unsigned long data)
464 + /* This routine is called twice per second to check the
465 + * state of the power button.
468 + if (gpio_get_value(NAS100D_PB_GPIO)) {
470 + /* IO Pin is 1 (button pushed) */
471 + if (power_button_countdown > 0)
472 + power_button_countdown--;
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.
484 + /* Change the state of the power LED to "blink" */
485 + gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
487 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
491 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
494 +static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
496 + /* This is the paper-clip reset, it shuts the machine down directly. */
497 + machine_power_off();
499 + return IRQ_HANDLED;
502 static void __init nas100d_init(void)
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;
509 - pm_power_off = nas100d_power_off;
511 i2c_register_board_info(0, nas100d_i2c_board_info,
512 ARRAY_SIZE(nas100d_i2c_board_info));
514 @@ -197,6 +256,29 @@ static void __init nas100d_init(void)
516 platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
518 + pm_power_off = nas100d_power_off;
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) {
524 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
525 + gpio_to_irq(NAS100D_RB_GPIO));
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.
533 + /* Make sure that the power button GPIO is set up as an input */
534 + gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
536 + /* Set the initial value for the power button IRQ handler */
537 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
539 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
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
550 - * arch/arm/mach-ixp4xx/dsmg600-power.c
552 - * DSM-G600 Power/Reset driver
553 - * Author: Michael Westerhof <mwester@dls.net>
555 - * Based on nslu2-power.c
556 - * Copyright (C) 2005 Tower Technologies
557 - * Author: Alessandro Zummo <a.zummo@towertech.it>
559 - * which was based on nslu2-io.c
560 - * Copyright (C) 2004 Karen Spearel
562 - * Maintainers: http://www.nslu2-linux.org/
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.
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>
577 -#include <asm/gpio.h>
578 -#include <asm/mach-types.h>
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.
583 -static int power_button_countdown;
585 -/* Must hold the button down for at least this many counts to be processed */
586 -#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
588 -static void dsmg600_power_handler(unsigned long data);
589 -static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
591 -static void dsmg600_power_handler(unsigned long data)
593 - /* This routine is called twice per second to check the
594 - * state of the power button.
597 - if (gpio_get_value(DSMG600_PB_GPIO)) {
599 - /* IO Pin is 1 (button pushed) */
600 - if (power_button_countdown > 0)
601 - power_button_countdown--;
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.
613 - /* Change the state of the power LED to "blink" */
614 - gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
616 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
620 - mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
623 -static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
625 - /* This is the paper-clip reset, it shuts the machine down directly. */
626 - machine_power_off();
628 - return IRQ_HANDLED;
631 -static int __init dsmg600_power_init(void)
633 - if (!(machine_is_dsmg600()))
636 - if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
637 - IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
640 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
641 - gpio_to_irq(DSMG600_RB_GPIO));
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.
651 - /* Make sure that the power button GPIO is set up as an input */
652 - gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
654 - /* Set the initial value for the power button IRQ handler */
655 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
657 - mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
662 -static void __exit dsmg600_power_exit(void)
664 - if (!(machine_is_dsmg600()))
667 - del_timer_sync(&dsmg600_power_timer);
669 - free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL);
672 -module_init(dsmg600_power_init);
673 -module_exit(dsmg600_power_exit);
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
684 * DSM-G600 board-setup
686 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
687 * Copyright (C) 2006 Tower Technologies
688 - * Author: Alessandro Zummo <a.zummo@towertech.it>
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
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/
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>
716 #include <asm/mach/arch.h>
717 #include <asm/mach/flash.h>
718 #include <asm/mach/time.h>
719 +#include <asm/gpio.h>
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);
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.
730 +static int power_button_countdown;
732 +/* Must hold the button down for at least this many counts to be processed */
733 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
735 +static void dsmg600_power_handler(unsigned long data);
736 +static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
738 +static void dsmg600_power_handler(unsigned long data)
740 + /* This routine is called twice per second to check the
741 + * state of the power button.
744 + if (gpio_get_value(DSMG600_PB_GPIO)) {
746 + /* IO Pin is 1 (button pushed) */
747 + if (power_button_countdown > 0)
748 + power_button_countdown--;
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.
760 + /* Change the state of the power LED to "blink" */
761 + gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
763 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
767 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
770 +static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
772 + /* This is the paper-clip reset, it shuts the machine down directly. */
773 + machine_power_off();
775 + return IRQ_HANDLED;
778 static void __init dsmg600_timer_init(void)
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;
785 - pm_power_off = dsmg600_power_off;
787 i2c_register_board_info(0, dsmg600_i2c_board_info,
788 ARRAY_SIZE(dsmg600_i2c_board_info));
790 @@ -176,6 +235,29 @@ static void __init dsmg600_init(void)
791 (void)platform_device_register(&dsmg600_uart);
793 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
795 + pm_power_off = dsmg600_power_off;
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) {
801 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
802 + gpio_to_irq(DSMG600_RB_GPIO));
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.
810 + /* Make sure that the power button GPIO is set up as an input */
811 + gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
813 + /* Set the initial value for the power button IRQ handler */
814 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
816 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
819 MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")