aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ixp4xx/dsmg600-setup.c
diff options
context:
space:
mode:
authorRod Whitby <rod@whitby.id.au>2008-02-03 06:05:55 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-02-04 08:15:27 -0500
commit43816bcb72623c02a992e513feeaaf1178cea6dc (patch)
treeec6925c641f56dd3e20209c20e17f6950ec3c7c4 /arch/arm/mach-ixp4xx/dsmg600-setup.c
parentc7d1623e5820c46a39519e64fafb94f39419be82 (diff)
[ARM] 4809/2: ixp4xx: Merge dsmg600-power.c into dsmg600-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/arm/mach-ixp4xx/dsmg600-setup.c')
-rw-r--r--arch/arm/mach-ixp4xx/dsmg600-setup.c92
1 files changed, 87 insertions, 5 deletions
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
26static struct flash_platform_data dsmg600_flash_data = { 36static 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 */
156static 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
161static void dsmg600_power_handler(unsigned long data);
162static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
163
164static 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
196static 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
143static void __init dsmg600_timer_init(void) 204static 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
181MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") 263MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")