diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-02-04 18:29:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-02-04 18:29:53 -0500 |
commit | 9ef9dc69d4167276c04590d67ee55de8380bc1ad (patch) | |
tree | f0afd03cd9184eda2fe14c41f09daec79a62682e /arch/arm/mach-ixp4xx/dsmg600-setup.c | |
parent | 2c8296f8cf0ec40867965dddef3dfe92f73b38f4 (diff) | |
parent | 0d899e1b0000ddf78a75d7dcf9a9029d6f7f8091 (diff) |
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (44 commits)
[ARM] 4822/1: RealView: Change the REALVIEW_MPCORE configuration option
[ARM] 4821/1: RealView: Remove the platform dependencies from localtimer.c
[ARM] 4820/1: RealView: Select the timer IRQ at run-time
[ARM] 4819/1: RealView: Fix entry-macro.S to work with multiple platforms
[ARM] 4818/1: RealView: Add core-tile detection
[ARM] 4817/1: RealView: Move the AMBA resource definitions to realview_eb.c
[ARM] 4816/1: RealView: Move the platform-specific definitions into board-eb.h
[ARM] 4815/1: RealView: Add clockevents suport for the local timers
[ARM] 4814/1: RealView: Add broadcasting clockevents support for ARM11MPCore
[ARM] 4813/1: Add SMP helper functions for clockevents support
[ARM] 4812/1: RealView: clockevents support for the RealView platforms
[ARM] 4811/1: RealView: clocksource support for the RealView platforms
[ARM] 4736/1: Export atags to userspace and allow kexec to use customised atags
[ARM] 4798/1: pcm027: fix missing header file
[ARM] 4803/1: pxa: fix building issue of poodle.c caused by patch 4737/1
[ARM] 4801/1: pxa: fix building issues of missing pxa2xx-regs.h
[ARM] pxa: introduce sysdev for pxa3xx static memory controller
[ARM] pxa: add preliminary suspend/resume code for pxa3xx
[ARM] pxa: introduce sysdev for GPIO register saving/restoring
[ARM] pxa: introduce sysdev for IRQ register saving/restoring
...
Diffstat (limited to 'arch/arm/mach-ixp4xx/dsmg600-setup.c')
-rw-r--r-- | arch/arm/mach-ixp4xx/dsmg600-setup.c | 134 |
1 files changed, 111 insertions, 23 deletions
diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c index c473d408aa7c..688659668bdf 100644 --- a/arch/arm/mach-ixp4xx/dsmg600-setup.c +++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c | |||
@@ -1,25 +1,37 @@ | |||
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> |
25 | #include <linux/leds.h> | ||
26 | #include <linux/reboot.h> | ||
27 | #include <linux/i2c.h> | ||
17 | #include <linux/i2c-gpio.h> | 28 | #include <linux/i2c-gpio.h> |
18 | 29 | ||
19 | #include <asm/mach-types.h> | 30 | #include <asm/mach-types.h> |
20 | #include <asm/mach/arch.h> | 31 | #include <asm/mach/arch.h> |
21 | #include <asm/mach/flash.h> | 32 | #include <asm/mach/flash.h> |
22 | #include <asm/mach/time.h> | 33 | #include <asm/mach/time.h> |
34 | #include <asm/gpio.h> | ||
23 | 35 | ||
24 | static struct flash_platform_data dsmg600_flash_data = { | 36 | static struct flash_platform_data dsmg600_flash_data = { |
25 | .map_name = "cfi_probe", | 37 | .map_name = "cfi_probe", |
@@ -51,29 +63,34 @@ static struct platform_device dsmg600_i2c_gpio = { | |||
51 | }, | 63 | }, |
52 | }; | 64 | }; |
53 | 65 | ||
54 | #ifdef CONFIG_LEDS_CLASS | 66 | static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = { |
55 | static struct resource dsmg600_led_resources[] = { | 67 | { |
68 | I2C_BOARD_INFO("rtc-pcf8563", 0x51), | ||
69 | }, | ||
70 | }; | ||
71 | |||
72 | static struct gpio_led dsmg600_led_pins[] = { | ||
56 | { | 73 | { |
57 | .name = "power", | 74 | .name = "power", |
58 | .start = DSMG600_LED_PWR_GPIO, | 75 | .gpio = DSMG600_LED_PWR_GPIO, |
59 | .end = DSMG600_LED_PWR_GPIO, | ||
60 | .flags = IXP4XX_GPIO_HIGH, | ||
61 | }, | 76 | }, |
62 | { | 77 | { |
63 | .name = "wlan", | 78 | .name = "wlan", |
64 | .start = DSMG600_LED_WLAN_GPIO, | 79 | .gpio = DSMG600_LED_WLAN_GPIO, |
65 | .end = DSMG600_LED_WLAN_GPIO, | 80 | .active_low = true, |
66 | .flags = IXP4XX_GPIO_LOW, | ||
67 | }, | 81 | }, |
68 | }; | 82 | }; |
69 | 83 | ||
84 | static struct gpio_led_platform_data dsmg600_led_data = { | ||
85 | .num_leds = ARRAY_SIZE(dsmg600_led_pins), | ||
86 | .leds = dsmg600_led_pins, | ||
87 | }; | ||
88 | |||
70 | static struct platform_device dsmg600_leds = { | 89 | static struct platform_device dsmg600_leds = { |
71 | .name = "IXP4XX-GPIO-LED", | 90 | .name = "leds-gpio", |
72 | .id = -1, | 91 | .id = -1, |
73 | .num_resources = ARRAY_SIZE(dsmg600_led_resources), | 92 | .dev.platform_data = &dsmg600_led_data, |
74 | .resource = dsmg600_led_resources, | ||
75 | }; | 93 | }; |
76 | #endif | ||
77 | 94 | ||
78 | static struct resource dsmg600_uart_resources[] = { | 95 | static struct resource dsmg600_uart_resources[] = { |
79 | { | 96 | { |
@@ -121,6 +138,7 @@ static struct platform_device dsmg600_uart = { | |||
121 | static struct platform_device *dsmg600_devices[] __initdata = { | 138 | static struct platform_device *dsmg600_devices[] __initdata = { |
122 | &dsmg600_i2c_gpio, | 139 | &dsmg600_i2c_gpio, |
123 | &dsmg600_flash, | 140 | &dsmg600_flash, |
141 | &dsmg600_leds, | ||
124 | }; | 142 | }; |
125 | 143 | ||
126 | static void dsmg600_power_off(void) | 144 | static void dsmg600_power_off(void) |
@@ -132,6 +150,57 @@ static void dsmg600_power_off(void) | |||
132 | gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH); | 150 | gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH); |
133 | } | 151 | } |
134 | 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 | |||
135 | static void __init dsmg600_timer_init(void) | 204 | static void __init dsmg600_timer_init(void) |
136 | { | 205 | { |
137 | /* The xtal on this machine is non-standard. */ | 206 | /* The xtal on this machine is non-standard. */ |
@@ -156,7 +225,8 @@ static void __init dsmg600_init(void) | |||
156 | dsmg600_flash_resource.end = | 225 | dsmg600_flash_resource.end = |
157 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; | 226 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
158 | 227 | ||
159 | pm_power_off = dsmg600_power_off; | 228 | i2c_register_board_info(0, dsmg600_i2c_board_info, |
229 | ARRAY_SIZE(dsmg600_i2c_board_info)); | ||
160 | 230 | ||
161 | /* The UART is required on the DSM-G600 (Redboot cannot use the | 231 | /* The UART is required on the DSM-G600 (Redboot cannot use the |
162 | * NIC) -- do it here so that it does *not* get removed if | 232 | * NIC) -- do it here so that it does *not* get removed if |
@@ -166,10 +236,28 @@ static void __init dsmg600_init(void) | |||
166 | 236 | ||
167 | platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices)); | 237 | platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices)); |
168 | 238 | ||
169 | #ifdef CONFIG_LEDS_CLASS | 239 | pm_power_off = dsmg600_power_off; |
170 | /* We don't care whether or not this works. */ | 240 | |
171 | (void)platform_device_register(&dsmg600_leds); | 241 | if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler, |
172 | #endif | 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)); | ||
173 | } | 261 | } |
174 | 262 | ||
175 | MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") | 263 | MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") |