diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-ixp4xx/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/dsmg600-power.c | 129 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/dsmg600-setup.c | 92 |
3 files changed, 88 insertions, 135 deletions
diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile index a7880aba3fa7..c1956882c48b 100644 --- a/arch/arm/mach-ixp4xx/Makefile +++ b/arch/arm/mach-ixp4xx/Makefile | |||
@@ -25,7 +25,7 @@ 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 | 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 |
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 |
31 | 31 | ||
diff --git a/arch/arm/mach-ixp4xx/dsmg600-power.c b/arch/arm/mach-ixp4xx/dsmg600-power.c deleted file mode 100644 index db6398777124..000000000000 --- a/arch/arm/mach-ixp4xx/dsmg600-power.c +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-ixp4xx/dsmg600-power.c | ||
3 | * | ||
4 | * DSM-G600 Power/Reset driver | ||
5 | * Author: Michael Westerhof <mwester@dls.net> | ||
6 | * | ||
7 | * Based on nslu2-power.c | ||
8 | * Copyright (C) 2005 Tower Technologies | ||
9 | * Author: Alessandro Zummo <a.zummo@towertech.it> | ||
10 | * | ||
11 | * which was based on nslu2-io.c | ||
12 | * Copyright (C) 2004 Karen Spearel | ||
13 | * | ||
14 | * Maintainers: http://www.nslu2-linux.org/ | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or modify | ||
17 | * it under the terms of the GNU General Public License version 2 as | ||
18 | * published by the Free Software Foundation. | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/reboot.h> | ||
24 | #include <linux/interrupt.h> | ||
25 | #include <linux/irq.h> | ||
26 | #include <linux/jiffies.h> | ||
27 | #include <linux/timer.h> | ||
28 | |||
29 | #include <asm/gpio.h> | ||
30 | #include <asm/mach-types.h> | ||
31 | |||
32 | /* This is used to make sure the power-button pusher is serious. The button | ||
33 | * must be held until the value of this counter reaches zero. | ||
34 | */ | ||
35 | static int power_button_countdown; | ||
36 | |||
37 | /* Must hold the button down for at least this many counts to be processed */ | ||
38 | #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */ | ||
39 | |||
40 | static void dsmg600_power_handler(unsigned long data); | ||
41 | static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0); | ||
42 | |||
43 | static void dsmg600_power_handler(unsigned long data) | ||
44 | { | ||
45 | /* This routine is called twice per second to check the | ||
46 | * state of the power button. | ||
47 | */ | ||
48 | |||
49 | if (gpio_get_value(DSMG600_PB_GPIO)) { | ||
50 | |||
51 | /* IO Pin is 1 (button pushed) */ | ||
52 | if (power_button_countdown > 0) | ||
53 | power_button_countdown--; | ||
54 | |||
55 | } else { | ||
56 | |||
57 | /* Done on button release, to allow for auto-power-on mods. */ | ||
58 | if (power_button_countdown == 0) { | ||
59 | /* Signal init to do the ctrlaltdel action, | ||
60 | * this will bypass init if it hasn't started | ||
61 | * and do a kernel_restart. | ||
62 | */ | ||
63 | ctrl_alt_del(); | ||
64 | |||
65 | /* Change the state of the power LED to "blink" */ | ||
66 | gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW); | ||
67 | } else { | ||
68 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); | ||
73 | } | ||
74 | |||
75 | static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id) | ||
76 | { | ||
77 | /* This is the paper-clip reset, it shuts the machine down directly. */ | ||
78 | machine_power_off(); | ||
79 | |||
80 | return IRQ_HANDLED; | ||
81 | } | ||
82 | |||
83 | static int __init dsmg600_power_init(void) | ||
84 | { | ||
85 | if (!(machine_is_dsmg600())) | ||
86 | return 0; | ||
87 | |||
88 | if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler, | ||
89 | IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button", | ||
90 | NULL) < 0) { | ||
91 | |||
92 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
93 | gpio_to_irq(DSMG600_RB_GPIO)); | ||
94 | |||
95 | return -EIO; | ||
96 | } | ||
97 | |||
98 | /* The power button on the D-Link DSM-G600 is on GPIO 15, but | ||
99 | * it cannot handle interrupts on that GPIO line. So we'll | ||
100 | * have to poll it with a kernel timer. | ||
101 | */ | ||
102 | |||
103 | /* Make sure that the power button GPIO is set up as an input */ | ||
104 | gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN); | ||
105 | |||
106 | /* Set the initial value for the power button IRQ handler */ | ||
107 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
108 | |||
109 | mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static void __exit dsmg600_power_exit(void) | ||
115 | { | ||
116 | if (!(machine_is_dsmg600())) | ||
117 | return; | ||
118 | |||
119 | del_timer_sync(&dsmg600_power_timer); | ||
120 | |||
121 | free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL); | ||
122 | } | ||
123 | |||
124 | module_init(dsmg600_power_init); | ||
125 | module_exit(dsmg600_power_exit); | ||
126 | |||
127 | MODULE_AUTHOR("Michael Westerhof <mwester@dls.net>"); | ||
128 | MODULE_DESCRIPTION("DSM-G600 Power/Reset driver"); | ||
129 | MODULE_LICENSE("GPL"); | ||
diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c index d0e129566fbc..688659668bdf 100644 --- a/arch/arm/mach-ixp4xx/dsmg600-setup.c +++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c | |||
@@ -1,20 +1,29 @@ | |||
1 | /* | 1 | /* |
2 | * DSM-G600 board-setup | 2 | * DSM-G600 board-setup |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au> | ||
4 | * Copyright (C) 2006 Tower Technologies | 5 | * Copyright (C) 2006 Tower Technologies |
5 | * Author: Alessandro Zummo <a.zummo@towertech.it> | ||
6 | * | 6 | * |
7 | * based ixdp425-setup.c: | 7 | * based on ixdp425-setup.c: |
8 | * Copyright (C) 2003-2004 MontaVista Software, Inc. | 8 | * Copyright (C) 2003-2004 MontaVista Software, Inc. |
9 | * based on nslu2-power.c: | ||
10 | * Copyright (C) 2005 Tower Technologies | ||
11 | * based on nslu2-io.c: | ||
12 | * Copyright (C) 2004 Karen Spearel | ||
9 | * | 13 | * |
10 | * Author: Alessandro Zummo <a.zummo@towertech.it> | 14 | * Author: Alessandro Zummo <a.zummo@towertech.it> |
15 | * Author: Michael Westerhof <mwester@dls.net> | ||
16 | * Author: Rod Whitby <rod@whitby.id.au> | ||
11 | * Maintainers: http://www.nslu2-linux.org/ | 17 | * Maintainers: http://www.nslu2-linux.org/ |
12 | */ | 18 | */ |
13 | 19 | ||
14 | #include <linux/kernel.h> | 20 | #include <linux/irq.h> |
21 | #include <linux/jiffies.h> | ||
22 | #include <linux/timer.h> | ||
15 | #include <linux/serial.h> | 23 | #include <linux/serial.h> |
16 | #include <linux/serial_8250.h> | 24 | #include <linux/serial_8250.h> |
17 | #include <linux/leds.h> | 25 | #include <linux/leds.h> |
26 | #include <linux/reboot.h> | ||
18 | #include <linux/i2c.h> | 27 | #include <linux/i2c.h> |
19 | #include <linux/i2c-gpio.h> | 28 | #include <linux/i2c-gpio.h> |
20 | 29 | ||
@@ -22,6 +31,7 @@ | |||
22 | #include <asm/mach/arch.h> | 31 | #include <asm/mach/arch.h> |
23 | #include <asm/mach/flash.h> | 32 | #include <asm/mach/flash.h> |
24 | #include <asm/mach/time.h> | 33 | #include <asm/mach/time.h> |
34 | #include <asm/gpio.h> | ||
25 | 35 | ||
26 | static struct flash_platform_data dsmg600_flash_data = { | 36 | static struct flash_platform_data dsmg600_flash_data = { |
27 | .map_name = "cfi_probe", | 37 | .map_name = "cfi_probe", |
@@ -140,6 +150,57 @@ static void dsmg600_power_off(void) | |||
140 | gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH); | 150 | gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH); |
141 | } | 151 | } |
142 | 152 | ||
153 | /* This is used to make sure the power-button pusher is serious. The button | ||
154 | * must be held until the value of this counter reaches zero. | ||
155 | */ | ||
156 | static int power_button_countdown; | ||
157 | |||
158 | /* Must hold the button down for at least this many counts to be processed */ | ||
159 | #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */ | ||
160 | |||
161 | static void dsmg600_power_handler(unsigned long data); | ||
162 | static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0); | ||
163 | |||
164 | static void dsmg600_power_handler(unsigned long data) | ||
165 | { | ||
166 | /* This routine is called twice per second to check the | ||
167 | * state of the power button. | ||
168 | */ | ||
169 | |||
170 | if (gpio_get_value(DSMG600_PB_GPIO)) { | ||
171 | |||
172 | /* IO Pin is 1 (button pushed) */ | ||
173 | if (power_button_countdown > 0) | ||
174 | power_button_countdown--; | ||
175 | |||
176 | } else { | ||
177 | |||
178 | /* Done on button release, to allow for auto-power-on mods. */ | ||
179 | if (power_button_countdown == 0) { | ||
180 | /* Signal init to do the ctrlaltdel action, | ||
181 | * this will bypass init if it hasn't started | ||
182 | * and do a kernel_restart. | ||
183 | */ | ||
184 | ctrl_alt_del(); | ||
185 | |||
186 | /* Change the state of the power LED to "blink" */ | ||
187 | gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW); | ||
188 | } else { | ||
189 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); | ||
194 | } | ||
195 | |||
196 | static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id) | ||
197 | { | ||
198 | /* This is the paper-clip reset, it shuts the machine down directly. */ | ||
199 | machine_power_off(); | ||
200 | |||
201 | return IRQ_HANDLED; | ||
202 | } | ||
203 | |||
143 | static void __init dsmg600_timer_init(void) | 204 | static void __init dsmg600_timer_init(void) |
144 | { | 205 | { |
145 | /* The xtal on this machine is non-standard. */ | 206 | /* The xtal on this machine is non-standard. */ |
@@ -164,8 +225,6 @@ static void __init dsmg600_init(void) | |||
164 | dsmg600_flash_resource.end = | 225 | dsmg600_flash_resource.end = |
165 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; | 226 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
166 | 227 | ||
167 | pm_power_off = dsmg600_power_off; | ||
168 | |||
169 | i2c_register_board_info(0, dsmg600_i2c_board_info, | 228 | i2c_register_board_info(0, dsmg600_i2c_board_info, |
170 | ARRAY_SIZE(dsmg600_i2c_board_info)); | 229 | ARRAY_SIZE(dsmg600_i2c_board_info)); |
171 | 230 | ||
@@ -176,6 +235,29 @@ static void __init dsmg600_init(void) | |||
176 | (void)platform_device_register(&dsmg600_uart); | 235 | (void)platform_device_register(&dsmg600_uart); |
177 | 236 | ||
178 | platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices)); | 237 | platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices)); |
238 | |||
239 | pm_power_off = dsmg600_power_off; | ||
240 | |||
241 | if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler, | ||
242 | IRQF_DISABLED | IRQF_TRIGGER_LOW, | ||
243 | "DSM-G600 reset button", NULL) < 0) { | ||
244 | |||
245 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
246 | gpio_to_irq(DSMG600_RB_GPIO)); | ||
247 | } | ||
248 | |||
249 | /* The power button on the D-Link DSM-G600 is on GPIO 15, but | ||
250 | * it cannot handle interrupts on that GPIO line. So we'll | ||
251 | * have to poll it with a kernel timer. | ||
252 | */ | ||
253 | |||
254 | /* Make sure that the power button GPIO is set up as an input */ | ||
255 | gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN); | ||
256 | |||
257 | /* Set the initial value for the power button IRQ handler */ | ||
258 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
259 | |||
260 | mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); | ||
179 | } | 261 | } |
180 | 262 | ||
181 | MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") | 263 | MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") |