diff options
Diffstat (limited to 'arch/arm/mach-ixp4xx/nas100d-power.c')
-rw-r--r-- | arch/arm/mach-ixp4xx/nas100d-power.c | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/arch/arm/mach-ixp4xx/nas100d-power.c b/arch/arm/mach-ixp4xx/nas100d-power.c deleted file mode 100644 index 4c1c01bb3fe2..000000000000 --- a/arch/arm/mach-ixp4xx/nas100d-power.c +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | /* | ||
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 | |||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/irq.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/reboot.h> | ||
24 | #include <linux/jiffies.h> | ||
25 | #include <linux/timer.h> | ||
26 | |||
27 | #include <asm/gpio.h> | ||
28 | #include <asm/mach-types.h> | ||
29 | |||
30 | /* This is used to make sure the power-button pusher is serious. The button | ||
31 | * must be held until the value of this counter reaches zero. | ||
32 | */ | ||
33 | static int power_button_countdown; | ||
34 | |||
35 | /* Must hold the button down for at least this many counts to be processed */ | ||
36 | #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */ | ||
37 | |||
38 | static void nas100d_power_handler(unsigned long data); | ||
39 | static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0); | ||
40 | |||
41 | static void nas100d_power_handler(unsigned long data) | ||
42 | { | ||
43 | /* This routine is called twice per second to check the | ||
44 | * state of the power button. | ||
45 | */ | ||
46 | |||
47 | if (gpio_get_value(NAS100D_PB_GPIO)) { | ||
48 | |||
49 | /* IO Pin is 1 (button pushed) */ | ||
50 | if (power_button_countdown > 0) | ||
51 | power_button_countdown--; | ||
52 | |||
53 | } else { | ||
54 | |||
55 | /* Done on button release, to allow for auto-power-on mods. */ | ||
56 | if (power_button_countdown == 0) { | ||
57 | /* Signal init to do the ctrlaltdel action, | ||
58 | * this will bypass init if it hasn't started | ||
59 | * and do a kernel_restart. | ||
60 | */ | ||
61 | ctrl_alt_del(); | ||
62 | |||
63 | /* Change the state of the power LED to "blink" */ | ||
64 | gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW); | ||
65 | } else { | ||
66 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); | ||
71 | } | ||
72 | |||
73 | static irqreturn_t nas100d_reset_handler(int irq, void *dev_id) | ||
74 | { | ||
75 | /* This is the paper-clip reset, it shuts the machine down directly. */ | ||
76 | machine_power_off(); | ||
77 | |||
78 | return IRQ_HANDLED; | ||
79 | } | ||
80 | |||
81 | static int __init nas100d_power_init(void) | ||
82 | { | ||
83 | if (!(machine_is_nas100d())) | ||
84 | return 0; | ||
85 | |||
86 | set_irq_type(gpio_to_irq(NAS100D_RB_GPIO), IRQT_LOW); | ||
87 | |||
88 | if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler, | ||
89 | IRQF_DISABLED, "NAS100D reset button", NULL) < 0) { | ||
90 | |||
91 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
92 | gpio_to_irq(NAS100D_RB_GPIO)); | ||
93 | |||
94 | return -EIO; | ||
95 | } | ||
96 | |||
97 | /* The power button on the Iomega NAS100d is on GPIO 14, but | ||
98 | * it cannot handle interrupts on that GPIO line. So we'll | ||
99 | * have to poll it with a kernel timer. | ||
100 | */ | ||
101 | |||
102 | /* Make sure that the power button GPIO is set up as an input */ | ||
103 | gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN); | ||
104 | |||
105 | /* Set the initial value for the power button IRQ handler */ | ||
106 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
107 | |||
108 | mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static void __exit nas100d_power_exit(void) | ||
114 | { | ||
115 | if (!(machine_is_nas100d())) | ||
116 | return; | ||
117 | |||
118 | del_timer_sync(&nas100d_power_timer); | ||
119 | |||
120 | free_irq(gpio_to_irq(NAS100D_RB_GPIO), NULL); | ||
121 | } | ||
122 | |||
123 | module_init(nas100d_power_init); | ||
124 | module_exit(nas100d_power_exit); | ||
125 | |||
126 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | ||
127 | MODULE_DESCRIPTION("NAS100D Power/Reset driver"); | ||
128 | MODULE_LICENSE("GPL"); | ||