allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / arm / mach-ixp4xx / nslu2-power.c
blobacd71e9c38a703792cc08d739ba1f0db81a2909b
1 /*
2 * arch/arm/mach-ixp4xx/nslu2-power.c
4 * NSLU2 Power/Reset driver
6 * Copyright (C) 2005 Tower Technologies
8 * based on nslu2-io.c
9 * Copyright (C) 2004 Karen Spearel
11 * Author: Alessandro Zummo <a.zummo@towertech.it>
12 * Maintainers: http://www.nslu2-linux.org/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
20 #include <linux/module.h>
21 #include <linux/reboot.h>
22 #include <linux/irq.h>
23 #include <linux/interrupt.h>
24 #include <linux/reboot.h>
26 #include <asm/mach-types.h>
28 static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
30 /* Signal init to do the ctrlaltdel action, this will bypass init if
31 * it hasn't started and do a kernel_restart.
33 ctrl_alt_del();
35 return IRQ_HANDLED;
38 static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
40 /* This is the paper-clip reset, it shuts the machine down directly.
42 machine_power_off();
44 return IRQ_HANDLED;
47 static int __init nslu2_power_init(void)
49 if (!(machine_is_nslu2()))
50 return 0;
52 *IXP4XX_GPIO_GPISR = 0x20400000; /* read the 2 irqs to clr */
54 set_irq_type(NSLU2_RB_IRQ, IRQT_LOW);
55 set_irq_type(NSLU2_PB_IRQ, IRQT_HIGH);
57 if (request_irq(NSLU2_RB_IRQ, &nslu2_reset_handler,
58 IRQF_DISABLED, "NSLU2 reset button", NULL) < 0) {
60 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
61 NSLU2_RB_IRQ);
63 return -EIO;
66 if (request_irq(NSLU2_PB_IRQ, &nslu2_power_handler,
67 IRQF_DISABLED, "NSLU2 power button", NULL) < 0) {
69 printk(KERN_DEBUG "Power Button IRQ %d not available\n",
70 NSLU2_PB_IRQ);
72 return -EIO;
75 return 0;
78 static void __exit nslu2_power_exit(void)
80 if (!(machine_is_nslu2()))
81 return;
83 free_irq(NSLU2_RB_IRQ, NULL);
84 free_irq(NSLU2_PB_IRQ, NULL);
87 module_init(nslu2_power_init);
88 module_exit(nslu2_power_exit);
90 MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
91 MODULE_DESCRIPTION("NSLU2 Power/Reset driver");
92 MODULE_LICENSE("GPL");