blob: 29aa98d3a7faeb4993213e29aee093fe0f389f88 [file] [log] [blame]
Rod Whitby3145d8a2006-01-04 17:17:11 +00001/*
2 * arch/arm/mach-ixp4xx/nas100d-power.c
3 *
4 * NAS 100d Power/Reset driver
5 *
6 * Copyright (C) 2005 Tower Technologies
7 *
8 * based on nas100d-io.c
9 * Copyright (C) 2004 Karen Spearel
10 *
11 * Author: Alessandro Zummo <a.zummo@towertech.it>
12 * Maintainers: http://www.nslu2-linux.org/
13 *
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.
17 *
18 */
19
Rod Whitby3145d8a2006-01-04 17:17:11 +000020#include <linux/interrupt.h>
Thomas Gleixner698dfe22006-07-01 23:01:49 +010021#include <linux/irq.h>
22#include <linux/module.h>
Adrian Bunk83cc5ed2006-06-25 05:47:41 -070023#include <linux/reboot.h>
Rod Whitby3145d8a2006-01-04 17:17:11 +000024
25#include <asm/mach-types.h>
26
Linus Torvalds0cd61b62006-10-06 10:53:39 -070027static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
Rod Whitby3145d8a2006-01-04 17:17:11 +000028{
29 /* Signal init to do the ctrlaltdel action, this will bypass init if
30 * it hasn't started and do a kernel_restart.
31 */
32 ctrl_alt_del();
33
34 return IRQ_HANDLED;
35}
36
37static int __init nas100d_power_init(void)
38{
39 if (!(machine_is_nas100d()))
40 return 0;
41
42 set_irq_type(NAS100D_RB_IRQ, IRQT_LOW);
43
Rod Whitby3145d8a2006-01-04 17:17:11 +000044 if (request_irq(NAS100D_RB_IRQ, &nas100d_reset_handler,
Thomas Gleixner52e405e2006-07-03 02:20:05 +020045 IRQF_DISABLED, "NAS100D reset button", NULL) < 0) {
Rod Whitby3145d8a2006-01-04 17:17:11 +000046
47 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
48 NAS100D_RB_IRQ);
49
50 return -EIO;
51 }
52
53 return 0;
54}
55
56static void __exit nas100d_power_exit(void)
57{
Alessandro Zummo744bfe42006-03-07 22:48:29 +000058 if (!(machine_is_nas100d()))
59 return;
60
Rod Whitby3145d8a2006-01-04 17:17:11 +000061 free_irq(NAS100D_RB_IRQ, NULL);
62}
63
64module_init(nas100d_power_init);
65module_exit(nas100d_power_exit);
66
67MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
68MODULE_DESCRIPTION("NAS100D Power/Reset driver");
69MODULE_LICENSE("GPL");