diff options
author | Rod Whitby <rod@whitby.id.au> | 2008-02-03 06:05:49 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-02-04 08:15:27 -0500 |
commit | c7d1623e5820c46a39519e64fafb94f39419be82 (patch) | |
tree | b7374d7e14b6277f06df911ceaa0554545c0c8b7 /arch | |
parent | 0929ac3ea4c0bece16b0c5c5365181fa45fbf582 (diff) |
[ARM] 4808/2: ixp4xx: Merge nas100d-power.c into nas100d-setup.c
There is no reason to have power control in a separate file from the
board setup code. Merge it back into the board setup file and remove
superfluous header includes.
--
Signed-off-by: Rod Whitby <rod@whitby.id.au>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-ixp4xx/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/nas100d-power.c | 128 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/nas100d-setup.c | 90 |
3 files changed, 87 insertions, 133 deletions
diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile index 4fc7316191e9..a7880aba3fa7 100644 --- a/arch/arm/mach-ixp4xx/Makefile +++ b/arch/arm/mach-ixp4xx/Makefile | |||
@@ -24,7 +24,7 @@ obj-$(CONFIG_MACH_IXDPG425) += coyote-setup.o | |||
24 | obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o | 24 | obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o |
25 | obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o | 25 | obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o |
26 | obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o | 26 | obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o |
27 | obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o | 27 | obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o |
28 | obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o | 28 | obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o |
29 | obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o | 29 | obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o |
30 | obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o | 30 | obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o |
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"); | ||
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c index a432226b2050..4cecae84837b 100644 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c | |||
@@ -3,8 +3,14 @@ | |||
3 | * | 3 | * |
4 | * NAS 100d board-setup | 4 | * NAS 100d board-setup |
5 | * | 5 | * |
6 | * based ixdp425-setup.c: | 6 | * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au> |
7 | * | ||
8 | * based on ixdp425-setup.c: | ||
7 | * Copyright (C) 2003-2004 MontaVista Software, Inc. | 9 | * Copyright (C) 2003-2004 MontaVista Software, Inc. |
10 | * based on nas100d-power.c: | ||
11 | * Copyright (C) 2005 Tower Technologies | ||
12 | * based on nas100d-io.c | ||
13 | * Copyright (C) 2004 Karen Spearel | ||
8 | * | 14 | * |
9 | * Author: Alessandro Zummo <a.zummo@towertech.it> | 15 | * Author: Alessandro Zummo <a.zummo@towertech.it> |
10 | * Author: Rod Whitby <rod@whitby.id.au> | 16 | * Author: Rod Whitby <rod@whitby.id.au> |
@@ -13,10 +19,13 @@ | |||
13 | */ | 19 | */ |
14 | 20 | ||
15 | #include <linux/if_ether.h> | 21 | #include <linux/if_ether.h> |
16 | #include <linux/kernel.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/jiffies.h> | ||
24 | #include <linux/timer.h> | ||
17 | #include <linux/serial.h> | 25 | #include <linux/serial.h> |
18 | #include <linux/serial_8250.h> | 26 | #include <linux/serial_8250.h> |
19 | #include <linux/leds.h> | 27 | #include <linux/leds.h> |
28 | #include <linux/reboot.h> | ||
20 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
21 | #include <linux/i2c-gpio.h> | 30 | #include <linux/i2c-gpio.h> |
22 | 31 | ||
@@ -24,6 +33,7 @@ | |||
24 | #include <asm/mach/arch.h> | 33 | #include <asm/mach/arch.h> |
25 | #include <asm/mach/flash.h> | 34 | #include <asm/mach/flash.h> |
26 | #include <asm/io.h> | 35 | #include <asm/io.h> |
36 | #include <asm/gpio.h> | ||
27 | 37 | ||
28 | static struct flash_platform_data nas100d_flash_data = { | 38 | static struct flash_platform_data nas100d_flash_data = { |
29 | .map_name = "cfi_probe", | 39 | .map_name = "cfi_probe", |
@@ -168,6 +178,57 @@ static void nas100d_power_off(void) | |||
168 | gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH); | 178 | gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH); |
169 | } | 179 | } |
170 | 180 | ||
181 | /* This is used to make sure the power-button pusher is serious. The button | ||
182 | * must be held until the value of this counter reaches zero. | ||
183 | */ | ||
184 | static int power_button_countdown; | ||
185 | |||
186 | /* Must hold the button down for at least this many counts to be processed */ | ||
187 | #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */ | ||
188 | |||
189 | static void nas100d_power_handler(unsigned long data); | ||
190 | static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0); | ||
191 | |||
192 | static void nas100d_power_handler(unsigned long data) | ||
193 | { | ||
194 | /* This routine is called twice per second to check the | ||
195 | * state of the power button. | ||
196 | */ | ||
197 | |||
198 | if (gpio_get_value(NAS100D_PB_GPIO)) { | ||
199 | |||
200 | /* IO Pin is 1 (button pushed) */ | ||
201 | if (power_button_countdown > 0) | ||
202 | power_button_countdown--; | ||
203 | |||
204 | } else { | ||
205 | |||
206 | /* Done on button release, to allow for auto-power-on mods. */ | ||
207 | if (power_button_countdown == 0) { | ||
208 | /* Signal init to do the ctrlaltdel action, | ||
209 | * this will bypass init if it hasn't started | ||
210 | * and do a kernel_restart. | ||
211 | */ | ||
212 | ctrl_alt_del(); | ||
213 | |||
214 | /* Change the state of the power LED to "blink" */ | ||
215 | gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW); | ||
216 | } else { | ||
217 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); | ||
222 | } | ||
223 | |||
224 | static irqreturn_t nas100d_reset_handler(int irq, void *dev_id) | ||
225 | { | ||
226 | /* This is the paper-clip reset, it shuts the machine down directly. */ | ||
227 | machine_power_off(); | ||
228 | |||
229 | return IRQ_HANDLED; | ||
230 | } | ||
231 | |||
171 | static void __init nas100d_init(void) | 232 | static void __init nas100d_init(void) |
172 | { | 233 | { |
173 | DECLARE_MAC_BUF(mac_buf); | 234 | DECLARE_MAC_BUF(mac_buf); |
@@ -183,8 +244,6 @@ static void __init nas100d_init(void) | |||
183 | nas100d_flash_resource.end = | 244 | nas100d_flash_resource.end = |
184 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; | 245 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
185 | 246 | ||
186 | pm_power_off = nas100d_power_off; | ||
187 | |||
188 | i2c_register_board_info(0, nas100d_i2c_board_info, | 247 | i2c_register_board_info(0, nas100d_i2c_board_info, |
189 | ARRAY_SIZE(nas100d_i2c_board_info)); | 248 | ARRAY_SIZE(nas100d_i2c_board_info)); |
190 | 249 | ||
@@ -197,6 +256,29 @@ static void __init nas100d_init(void) | |||
197 | 256 | ||
198 | platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices)); | 257 | platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices)); |
199 | 258 | ||
259 | pm_power_off = nas100d_power_off; | ||
260 | |||
261 | if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler, | ||
262 | IRQF_DISABLED | IRQF_TRIGGER_LOW, | ||
263 | "NAS100D reset button", NULL) < 0) { | ||
264 | |||
265 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
266 | gpio_to_irq(NAS100D_RB_GPIO)); | ||
267 | } | ||
268 | |||
269 | /* The power button on the Iomega NAS100d is on GPIO 14, but | ||
270 | * it cannot handle interrupts on that GPIO line. So we'll | ||
271 | * have to poll it with a kernel timer. | ||
272 | */ | ||
273 | |||
274 | /* Make sure that the power button GPIO is set up as an input */ | ||
275 | gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN); | ||
276 | |||
277 | /* Set the initial value for the power button IRQ handler */ | ||
278 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
279 | |||
280 | mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); | ||
281 | |||
200 | /* | 282 | /* |
201 | * Map in a portion of the flash and read the MAC address. | 283 | * Map in a portion of the flash and read the MAC address. |
202 | * Since it is stored in BE in the flash itself, we need to | 284 | * Since it is stored in BE in the flash itself, we need to |