fa4070ba2882c2bf223a531dc4da75942bbb4259
[openwrt.git] / target / linux / ixp4xx / patches-2.6.24 / 032-subsume_power_files.patch
1 From: Rod Whitby <rod@whitby.id.au>
2 Subject: ixp4xx: Merge nslu2-power.c into nslu2-setup.c (Patch #4807)
3
4 There is no reason to have power control in a separate file from the
5 board setup code. Merge it back into the board setup file, removing
6 superfluous header includes and removing superfluous constants from
7 the machine header file.
8
9 Signed-off-by: Rod Whitby <rod@whitby.id.au>
10 --
11 PATCH FOLLOWS
12 KernelVersion: v2.6.24-1917-gaf66bd3
13
14 Index: linux-2.6.24-armeb/arch/arm/mach-ixp4xx/Makefile
15 ===================================================================
16 --- linux-2.6.24-armeb.orig/arch/arm/mach-ixp4xx/Makefile 2008-02-03 22:45:22.000000000 +1030
17 +++ linux-2.6.24-armeb/arch/arm/mach-ixp4xx/Makefile 2008-02-03 22:45:44.000000000 +1030
18 @@ -23,7 +23,7 @@
19 obj-$(CONFIG_MACH_IXDPG425) += coyote-setup.o
20 obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
21 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
22 -obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o nslu2-power.o
23 +obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o
24 obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
25 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
26 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
27 Index: linux-2.6.24-armeb/arch/arm/mach-ixp4xx/nslu2-power.c
28 ===================================================================
29 --- linux-2.6.24-armeb.orig/arch/arm/mach-ixp4xx/nslu2-power.c 2008-02-03 22:45:10.000000000 +1030
30 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000
31 @@ -1,92 +0,0 @@
32 -/*
33 - * arch/arm/mach-ixp4xx/nslu2-power.c
34 - *
35 - * NSLU2 Power/Reset driver
36 - *
37 - * Copyright (C) 2005 Tower Technologies
38 - *
39 - * based on nslu2-io.c
40 - * Copyright (C) 2004 Karen Spearel
41 - *
42 - * Author: Alessandro Zummo <a.zummo@towertech.it>
43 - * Maintainers: http://www.nslu2-linux.org/
44 - *
45 - * This program is free software; you can redistribute it and/or modify
46 - * it under the terms of the GNU General Public License version 2 as
47 - * published by the Free Software Foundation.
48 - *
49 - */
50 -
51 -#include <linux/module.h>
52 -#include <linux/reboot.h>
53 -#include <linux/irq.h>
54 -#include <linux/interrupt.h>
55 -#include <linux/reboot.h>
56 -
57 -#include <asm/mach-types.h>
58 -
59 -static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
60 -{
61 - /* Signal init to do the ctrlaltdel action, this will bypass init if
62 - * it hasn't started and do a kernel_restart.
63 - */
64 - ctrl_alt_del();
65 -
66 - return IRQ_HANDLED;
67 -}
68 -
69 -static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
70 -{
71 - /* This is the paper-clip reset, it shuts the machine down directly.
72 - */
73 - machine_power_off();
74 -
75 - return IRQ_HANDLED;
76 -}
77 -
78 -static int __init nslu2_power_init(void)
79 -{
80 - if (!(machine_is_nslu2()))
81 - return 0;
82 -
83 - *IXP4XX_GPIO_GPISR = 0x20400000; /* read the 2 irqs to clr */
84 -
85 - set_irq_type(NSLU2_RB_IRQ, IRQT_LOW);
86 - set_irq_type(NSLU2_PB_IRQ, IRQT_HIGH);
87 -
88 - if (request_irq(NSLU2_RB_IRQ, &nslu2_reset_handler,
89 - IRQF_DISABLED, "NSLU2 reset button", NULL) < 0) {
90 -
91 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
92 - NSLU2_RB_IRQ);
93 -
94 - return -EIO;
95 - }
96 -
97 - if (request_irq(NSLU2_PB_IRQ, &nslu2_power_handler,
98 - IRQF_DISABLED, "NSLU2 power button", NULL) < 0) {
99 -
100 - printk(KERN_DEBUG "Power Button IRQ %d not available\n",
101 - NSLU2_PB_IRQ);
102 -
103 - return -EIO;
104 - }
105 -
106 - return 0;
107 -}
108 -
109 -static void __exit nslu2_power_exit(void)
110 -{
111 - if (!(machine_is_nslu2()))
112 - return;
113 -
114 - free_irq(NSLU2_RB_IRQ, NULL);
115 - free_irq(NSLU2_PB_IRQ, NULL);
116 -}
117 -
118 -module_init(nslu2_power_init);
119 -module_exit(nslu2_power_exit);
120 -
121 -MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
122 -MODULE_DESCRIPTION("NSLU2 Power/Reset driver");
123 -MODULE_LICENSE("GPL");
124 Index: linux-2.6.24-armeb/arch/arm/mach-ixp4xx/nslu2-setup.c
125 ===================================================================
126 --- linux-2.6.24-armeb.orig/arch/arm/mach-ixp4xx/nslu2-setup.c 2008-02-03 22:45:22.000000000 +1030
127 +++ linux-2.6.24-armeb/arch/arm/mach-ixp4xx/nslu2-setup.c 2008-02-03 22:45:44.000000000 +1030
128 @@ -3,22 +3,26 @@
129 *
130 * NSLU2 board-setup
131 *
132 - * based ixdp425-setup.c:
133 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
134 + *
135 + * based on ixdp425-setup.c:
136 * Copyright (C) 2003-2004 MontaVista Software, Inc.
137 + * based on nslu2-power.c:
138 + * Copyright (C) 2005 Tower Technologies
139 *
140 * Author: Mark Rakes <mrakes at mac.com>
141 * Author: Rod Whitby <rod@whitby.id.au>
142 + * Author: Alessandro Zummo <a.zummo@towertech.it>
143 * Maintainers: http://www.nslu2-linux.org/
144 *
145 - * Fixed missing init_time in MACHINE_START kas11 10/22/04
146 - * Changed to conform to new style __init ixdp425 kas11 10/22/04
147 */
148
149 #include <linux/if_ether.h>
150 -#include <linux/kernel.h>
151 +#include <linux/irq.h>
152 #include <linux/serial.h>
153 #include <linux/serial_8250.h>
154 #include <linux/leds.h>
155 +#include <linux/reboot.h>
156 #include <linux/i2c.h>
157 #include <linux/i2c-gpio.h>
158
159 @@ -27,6 +31,7 @@
160 #include <asm/mach/flash.h>
161 #include <asm/mach/time.h>
162 #include <asm/io.h>
163 +#include <asm/gpio.h>
164
165 static struct flash_platform_data nslu2_flash_data = {
166 .map_name = "cfi_probe",
167 @@ -181,6 +186,25 @@
168 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
169 }
170
171 +static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
172 +{
173 + /* Signal init to do the ctrlaltdel action, this will bypass init if
174 + * it hasn't started and do a kernel_restart.
175 + */
176 + ctrl_alt_del();
177 +
178 + return IRQ_HANDLED;
179 +}
180 +
181 +static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
182 +{
183 + /* This is the paper-clip reset, it shuts the machine down directly.
184 + */
185 + machine_power_off();
186 +
187 + return IRQ_HANDLED;
188 +}
189 +
190 static void __init nslu2_timer_init(void)
191 {
192 /* The xtal on this machine is non-standard. */
193 @@ -206,8 +230,6 @@
194 nslu2_flash_resource.end =
195 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
196
197 - pm_power_off = nslu2_power_off;
198 -
199 i2c_register_board_info(0, nslu2_i2c_board_info,
200 ARRAY_SIZE(nslu2_i2c_board_info));
201
202 @@ -220,6 +242,23 @@
203
204 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
205
206 + pm_power_off = nslu2_power_off;
207 +
208 + if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler,
209 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
210 + "NSLU2 reset button", NULL) < 0) {
211 +
212 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
213 + gpio_to_irq(NSLU2_RB_GPIO));
214 + }
215 +
216 + if (request_irq(gpio_to_irq(NSLU2_PB_GPIO), &nslu2_power_handler,
217 + IRQF_DISABLED | IRQF_TRIGGER_HIGH,
218 + "NSLU2 power button", NULL) < 0) {
219 +
220 + printk(KERN_DEBUG "Power Button IRQ %d not available\n",
221 + gpio_to_irq(NSLU2_PB_GPIO));
222 + }
223
224 /*
225 * Map in a portion of the flash and read the MAC address.
226 Index: linux-2.6.24-armeb/include/asm-arm/arch-ixp4xx/nslu2.h
227 ===================================================================
228 --- linux-2.6.24-armeb.orig/include/asm-arm/arch-ixp4xx/nslu2.h 2008-02-03 22:45:11.000000000 +1030
229 +++ linux-2.6.24-armeb/include/asm-arm/arch-ixp4xx/nslu2.h 2008-02-03 22:45:44.000000000 +1030
230 @@ -39,34 +39,17 @@
231
232 /* Buttons */
233
234 -#define NSLU2_PB_GPIO 5
235 +#define NSLU2_PB_GPIO 5 /* power button */
236 #define NSLU2_PO_GPIO 8 /* power off */
237 -#define NSLU2_RB_GPIO 12
238 -
239 -#define NSLU2_PB_IRQ IRQ_IXP4XX_GPIO5
240 -#define NSLU2_RB_IRQ IRQ_IXP4XX_GPIO12
241 -
242 -#define NSLU2_PB_BM (1L << NSLU2_PB_GPIO)
243 -#define NSLU2_PO_BM (1L << NSLU2_PO_GPIO)
244 -#define NSLU2_RB_BM (1L << NSLU2_RB_GPIO)
245 +#define NSLU2_RB_GPIO 12 /* reset button */
246
247 /* Buzzer */
248
249 #define NSLU2_GPIO_BUZZ 4
250 -#define NSLU2_BZ_BM (1L << NSLU2_GPIO_BUZZ)
251
252 /* LEDs */
253
254 #define NSLU2_LED_RED_GPIO 0
255 #define NSLU2_LED_GRN_GPIO 1
256 -
257 -#define NSLU2_LED_RED_BM (1L << NSLU2_LED_RED_GPIO)
258 -#define NSLU2_LED_GRN_BM (1L << NSLU2_LED_GRN_GPIO)
259 -
260 #define NSLU2_LED_DISK1_GPIO 3
261 #define NSLU2_LED_DISK2_GPIO 2
262 -
263 -#define NSLU2_LED_DISK1_BM (1L << NSLU2_LED_DISK1_GPIO)
264 -#define NSLU2_LED_DISK2_BM (1L << NSLU2_LED_DISK2_GPIO)
265 -
266 -
267 From: Rod Whitby <rod@whitby.id.au>
268 Subject: ixp4xx: Merge nas100d-power.c into nas100d-setup.c (Patch #4808)
269
270 There is no reason to have power control in a separate file from the
271 board setup code. Merge it back into the board setup file and remove
272 superfluous header includes.
273
274 Signed-off-by: Rod Whitby <rod@whitby.id.au>
275 --
276 PATCH FOLLOWS
277 KernelVersion: 2.6.24-git9
278
279 diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile
280 index 4fc7316..a7880ab 100644
281 --- a/arch/arm/mach-ixp4xx/Makefile
282 +++ b/arch/arm/mach-ixp4xx/Makefile
283 @@ -24,7 +24,7 @@ obj-$(CONFIG_MACH_IXDPG425) += coyote-setup.o
284 obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
285 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
286 obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o
287 -obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
288 +obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o
289 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
290 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
291 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
292 diff --git a/arch/arm/mach-ixp4xx/nas100d-power.c b/arch/arm/mach-ixp4xx/nas100d-power.c
293 deleted file mode 100644
294 index 4c1c01b..0000000
295 --- a/arch/arm/mach-ixp4xx/nas100d-power.c
296 +++ /dev/null
297 @@ -1,128 +0,0 @@
298 -/*
299 - * arch/arm/mach-ixp4xx/nas100d-power.c
300 - *
301 - * NAS 100d Power/Reset driver
302 - *
303 - * Copyright (C) 2005 Tower Technologies
304 - *
305 - * based on nas100d-io.c
306 - * Copyright (C) 2004 Karen Spearel
307 - *
308 - * Author: Alessandro Zummo <a.zummo@towertech.it>
309 - * Maintainers: http://www.nslu2-linux.org/
310 - *
311 - * This program is free software; you can redistribute it and/or modify
312 - * it under the terms of the GNU General Public License version 2 as
313 - * published by the Free Software Foundation.
314 - *
315 - */
316 -
317 -#include <linux/interrupt.h>
318 -#include <linux/irq.h>
319 -#include <linux/module.h>
320 -#include <linux/reboot.h>
321 -#include <linux/jiffies.h>
322 -#include <linux/timer.h>
323 -
324 -#include <asm/gpio.h>
325 -#include <asm/mach-types.h>
326 -
327 -/* This is used to make sure the power-button pusher is serious. The button
328 - * must be held until the value of this counter reaches zero.
329 - */
330 -static int power_button_countdown;
331 -
332 -/* Must hold the button down for at least this many counts to be processed */
333 -#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
334 -
335 -static void nas100d_power_handler(unsigned long data);
336 -static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
337 -
338 -static void nas100d_power_handler(unsigned long data)
339 -{
340 - /* This routine is called twice per second to check the
341 - * state of the power button.
342 - */
343 -
344 - if (gpio_get_value(NAS100D_PB_GPIO)) {
345 -
346 - /* IO Pin is 1 (button pushed) */
347 - if (power_button_countdown > 0)
348 - power_button_countdown--;
349 -
350 - } else {
351 -
352 - /* Done on button release, to allow for auto-power-on mods. */
353 - if (power_button_countdown == 0) {
354 - /* Signal init to do the ctrlaltdel action,
355 - * this will bypass init if it hasn't started
356 - * and do a kernel_restart.
357 - */
358 - ctrl_alt_del();
359 -
360 - /* Change the state of the power LED to "blink" */
361 - gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
362 - } else {
363 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
364 - }
365 - }
366 -
367 - mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
368 -}
369 -
370 -static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
371 -{
372 - /* This is the paper-clip reset, it shuts the machine down directly. */
373 - machine_power_off();
374 -
375 - return IRQ_HANDLED;
376 -}
377 -
378 -static int __init nas100d_power_init(void)
379 -{
380 - if (!(machine_is_nas100d()))
381 - return 0;
382 -
383 - set_irq_type(gpio_to_irq(NAS100D_RB_GPIO), IRQT_LOW);
384 -
385 - if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
386 - IRQF_DISABLED, "NAS100D reset button", NULL) < 0) {
387 -
388 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
389 - gpio_to_irq(NAS100D_RB_GPIO));
390 -
391 - return -EIO;
392 - }
393 -
394 - /* The power button on the Iomega NAS100d is on GPIO 14, but
395 - * it cannot handle interrupts on that GPIO line. So we'll
396 - * have to poll it with a kernel timer.
397 - */
398 -
399 - /* Make sure that the power button GPIO is set up as an input */
400 - gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
401 -
402 - /* Set the initial value for the power button IRQ handler */
403 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
404 -
405 - mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
406 -
407 - return 0;
408 -}
409 -
410 -static void __exit nas100d_power_exit(void)
411 -{
412 - if (!(machine_is_nas100d()))
413 - return;
414 -
415 - del_timer_sync(&nas100d_power_timer);
416 -
417 - free_irq(gpio_to_irq(NAS100D_RB_GPIO), NULL);
418 -}
419 -
420 -module_init(nas100d_power_init);
421 -module_exit(nas100d_power_exit);
422 -
423 -MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
424 -MODULE_DESCRIPTION("NAS100D Power/Reset driver");
425 -MODULE_LICENSE("GPL");
426 diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
427 index a432226..4cecae8 100644
428 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c
429 +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
430 @@ -3,8 +3,14 @@
431 *
432 * NAS 100d board-setup
433 *
434 - * based ixdp425-setup.c:
435 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
436 + *
437 + * based on ixdp425-setup.c:
438 * Copyright (C) 2003-2004 MontaVista Software, Inc.
439 + * based on nas100d-power.c:
440 + * Copyright (C) 2005 Tower Technologies
441 + * based on nas100d-io.c
442 + * Copyright (C) 2004 Karen Spearel
443 *
444 * Author: Alessandro Zummo <a.zummo@towertech.it>
445 * Author: Rod Whitby <rod@whitby.id.au>
446 @@ -13,10 +19,13 @@
447 */
448
449 #include <linux/if_ether.h>
450 -#include <linux/kernel.h>
451 +#include <linux/irq.h>
452 +#include <linux/jiffies.h>
453 +#include <linux/timer.h>
454 #include <linux/serial.h>
455 #include <linux/serial_8250.h>
456 #include <linux/leds.h>
457 +#include <linux/reboot.h>
458 #include <linux/i2c.h>
459 #include <linux/i2c-gpio.h>
460
461 @@ -24,6 +33,7 @@
462 #include <asm/mach/arch.h>
463 #include <asm/mach/flash.h>
464 #include <asm/io.h>
465 +#include <asm/gpio.h>
466
467 static struct flash_platform_data nas100d_flash_data = {
468 .map_name = "cfi_probe",
469 @@ -168,6 +178,57 @@ static void nas100d_power_off(void)
470 gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH);
471 }
472
473 +/* This is used to make sure the power-button pusher is serious. The button
474 + * must be held until the value of this counter reaches zero.
475 + */
476 +static int power_button_countdown;
477 +
478 +/* Must hold the button down for at least this many counts to be processed */
479 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
480 +
481 +static void nas100d_power_handler(unsigned long data);
482 +static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
483 +
484 +static void nas100d_power_handler(unsigned long data)
485 +{
486 + /* This routine is called twice per second to check the
487 + * state of the power button.
488 + */
489 +
490 + if (gpio_get_value(NAS100D_PB_GPIO)) {
491 +
492 + /* IO Pin is 1 (button pushed) */
493 + if (power_button_countdown > 0)
494 + power_button_countdown--;
495 +
496 + } else {
497 +
498 + /* Done on button release, to allow for auto-power-on mods. */
499 + if (power_button_countdown == 0) {
500 + /* Signal init to do the ctrlaltdel action,
501 + * this will bypass init if it hasn't started
502 + * and do a kernel_restart.
503 + */
504 + ctrl_alt_del();
505 +
506 + /* Change the state of the power LED to "blink" */
507 + gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
508 + } else {
509 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
510 + }
511 + }
512 +
513 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
514 +}
515 +
516 +static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
517 +{
518 + /* This is the paper-clip reset, it shuts the machine down directly. */
519 + machine_power_off();
520 +
521 + return IRQ_HANDLED;
522 +}
523 +
524 static void __init nas100d_init(void)
525 {
526 DECLARE_MAC_BUF(mac_buf);
527 @@ -183,8 +244,6 @@ static void __init nas100d_init(void)
528 nas100d_flash_resource.end =
529 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
530
531 - pm_power_off = nas100d_power_off;
532 -
533 i2c_register_board_info(0, nas100d_i2c_board_info,
534 ARRAY_SIZE(nas100d_i2c_board_info));
535
536 @@ -197,6 +256,29 @@ static void __init nas100d_init(void)
537
538 platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
539
540 + pm_power_off = nas100d_power_off;
541 +
542 + if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
543 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
544 + "NAS100D reset button", NULL) < 0) {
545 +
546 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
547 + gpio_to_irq(NAS100D_RB_GPIO));
548 + }
549 +
550 + /* The power button on the Iomega NAS100d is on GPIO 14, but
551 + * it cannot handle interrupts on that GPIO line. So we'll
552 + * have to poll it with a kernel timer.
553 + */
554 +
555 + /* Make sure that the power button GPIO is set up as an input */
556 + gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
557 +
558 + /* Set the initial value for the power button IRQ handler */
559 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
560 +
561 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
562 +
563 /*
564 * Map in a portion of the flash and read the MAC address.
565 * Since it is stored in BE in the flash itself, we need to
566 --
567 1.5.2.5
568
569 From: Rod Whitby <rod@whitby.id.au>
570 Subject: ixp4xx: Merge dsmg600-power.c into dsmg600-setup.c (Patch #4809)
571
572 There is no reason to have power control in a separate file from the
573 board setup code. Merge it back into the board setup file and remove
574 superfluous header includes.
575
576 Signed-off-by: Rod Whitby <rod@whitby.id.au>
577 --
578 PATCH FOLLOWS
579 KernelVersion: 2.6.24-git9
580
581 diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile
582 index a7880ab..c195688 100644
583 --- a/arch/arm/mach-ixp4xx/Makefile
584 +++ b/arch/arm/mach-ixp4xx/Makefile
585 @@ -25,7 +25,7 @@ obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-setup.o
586 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
587 obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o
588 obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o
589 -obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
590 +obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o
591 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
592 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
593
594 diff --git a/arch/arm/mach-ixp4xx/dsmg600-power.c b/arch/arm/mach-ixp4xx/dsmg600-power.c
595 deleted file mode 100644
596 index db63987..0000000
597 --- a/arch/arm/mach-ixp4xx/dsmg600-power.c
598 +++ /dev/null
599 @@ -1,129 +0,0 @@
600 -/*
601 - * arch/arm/mach-ixp4xx/dsmg600-power.c
602 - *
603 - * DSM-G600 Power/Reset driver
604 - * Author: Michael Westerhof <mwester@dls.net>
605 - *
606 - * Based on nslu2-power.c
607 - * Copyright (C) 2005 Tower Technologies
608 - * Author: Alessandro Zummo <a.zummo@towertech.it>
609 - *
610 - * which was based on nslu2-io.c
611 - * Copyright (C) 2004 Karen Spearel
612 - *
613 - * Maintainers: http://www.nslu2-linux.org/
614 - *
615 - * This program is free software; you can redistribute it and/or modify
616 - * it under the terms of the GNU General Public License version 2 as
617 - * published by the Free Software Foundation.
618 - *
619 - */
620 -
621 -#include <linux/module.h>
622 -#include <linux/reboot.h>
623 -#include <linux/interrupt.h>
624 -#include <linux/irq.h>
625 -#include <linux/jiffies.h>
626 -#include <linux/timer.h>
627 -
628 -#include <asm/gpio.h>
629 -#include <asm/mach-types.h>
630 -
631 -/* This is used to make sure the power-button pusher is serious. The button
632 - * must be held until the value of this counter reaches zero.
633 - */
634 -static int power_button_countdown;
635 -
636 -/* Must hold the button down for at least this many counts to be processed */
637 -#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
638 -
639 -static void dsmg600_power_handler(unsigned long data);
640 -static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
641 -
642 -static void dsmg600_power_handler(unsigned long data)
643 -{
644 - /* This routine is called twice per second to check the
645 - * state of the power button.
646 - */
647 -
648 - if (gpio_get_value(DSMG600_PB_GPIO)) {
649 -
650 - /* IO Pin is 1 (button pushed) */
651 - if (power_button_countdown > 0)
652 - power_button_countdown--;
653 -
654 - } else {
655 -
656 - /* Done on button release, to allow for auto-power-on mods. */
657 - if (power_button_countdown == 0) {
658 - /* Signal init to do the ctrlaltdel action,
659 - * this will bypass init if it hasn't started
660 - * and do a kernel_restart.
661 - */
662 - ctrl_alt_del();
663 -
664 - /* Change the state of the power LED to "blink" */
665 - gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
666 - } else {
667 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
668 - }
669 - }
670 -
671 - mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
672 -}
673 -
674 -static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
675 -{
676 - /* This is the paper-clip reset, it shuts the machine down directly. */
677 - machine_power_off();
678 -
679 - return IRQ_HANDLED;
680 -}
681 -
682 -static int __init dsmg600_power_init(void)
683 -{
684 - if (!(machine_is_dsmg600()))
685 - return 0;
686 -
687 - if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
688 - IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
689 - NULL) < 0) {
690 -
691 - printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
692 - gpio_to_irq(DSMG600_RB_GPIO));
693 -
694 - return -EIO;
695 - }
696 -
697 - /* The power button on the D-Link DSM-G600 is on GPIO 15, but
698 - * it cannot handle interrupts on that GPIO line. So we'll
699 - * have to poll it with a kernel timer.
700 - */
701 -
702 - /* Make sure that the power button GPIO is set up as an input */
703 - gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
704 -
705 - /* Set the initial value for the power button IRQ handler */
706 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
707 -
708 - mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
709 -
710 - return 0;
711 -}
712 -
713 -static void __exit dsmg600_power_exit(void)
714 -{
715 - if (!(machine_is_dsmg600()))
716 - return;
717 -
718 - del_timer_sync(&dsmg600_power_timer);
719 -
720 - free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL);
721 -}
722 -
723 -module_init(dsmg600_power_init);
724 -module_exit(dsmg600_power_exit);
725 -
726 -MODULE_AUTHOR("Michael Westerhof <mwester@dls.net>");
727 -MODULE_DESCRIPTION("DSM-G600 Power/Reset driver");
728 -MODULE_LICENSE("GPL");
729 diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c
730 index d0e1295..6886596 100644
731 --- a/arch/arm/mach-ixp4xx/dsmg600-setup.c
732 +++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c
733 @@ -1,20 +1,29 @@
734 /*
735 * DSM-G600 board-setup
736 *
737 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
738 * Copyright (C) 2006 Tower Technologies
739 - * Author: Alessandro Zummo <a.zummo@towertech.it>
740 *
741 - * based ixdp425-setup.c:
742 + * based on ixdp425-setup.c:
743 * Copyright (C) 2003-2004 MontaVista Software, Inc.
744 + * based on nslu2-power.c:
745 + * Copyright (C) 2005 Tower Technologies
746 + * based on nslu2-io.c:
747 + * Copyright (C) 2004 Karen Spearel
748 *
749 * Author: Alessandro Zummo <a.zummo@towertech.it>
750 + * Author: Michael Westerhof <mwester@dls.net>
751 + * Author: Rod Whitby <rod@whitby.id.au>
752 * Maintainers: http://www.nslu2-linux.org/
753 */
754
755 -#include <linux/kernel.h>
756 +#include <linux/irq.h>
757 +#include <linux/jiffies.h>
758 +#include <linux/timer.h>
759 #include <linux/serial.h>
760 #include <linux/serial_8250.h>
761 #include <linux/leds.h>
762 +#include <linux/reboot.h>
763 #include <linux/i2c.h>
764 #include <linux/i2c-gpio.h>
765
766 @@ -22,6 +31,7 @@
767 #include <asm/mach/arch.h>
768 #include <asm/mach/flash.h>
769 #include <asm/mach/time.h>
770 +#include <asm/gpio.h>
771
772 static struct flash_platform_data dsmg600_flash_data = {
773 .map_name = "cfi_probe",
774 @@ -140,6 +150,57 @@ static void dsmg600_power_off(void)
775 gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
776 }
777
778 +/* This is used to make sure the power-button pusher is serious. The button
779 + * must be held until the value of this counter reaches zero.
780 + */
781 +static int power_button_countdown;
782 +
783 +/* Must hold the button down for at least this many counts to be processed */
784 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
785 +
786 +static void dsmg600_power_handler(unsigned long data);
787 +static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
788 +
789 +static void dsmg600_power_handler(unsigned long data)
790 +{
791 + /* This routine is called twice per second to check the
792 + * state of the power button.
793 + */
794 +
795 + if (gpio_get_value(DSMG600_PB_GPIO)) {
796 +
797 + /* IO Pin is 1 (button pushed) */
798 + if (power_button_countdown > 0)
799 + power_button_countdown--;
800 +
801 + } else {
802 +
803 + /* Done on button release, to allow for auto-power-on mods. */
804 + if (power_button_countdown == 0) {
805 + /* Signal init to do the ctrlaltdel action,
806 + * this will bypass init if it hasn't started
807 + * and do a kernel_restart.
808 + */
809 + ctrl_alt_del();
810 +
811 + /* Change the state of the power LED to "blink" */
812 + gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
813 + } else {
814 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
815 + }
816 + }
817 +
818 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
819 +}
820 +
821 +static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
822 +{
823 + /* This is the paper-clip reset, it shuts the machine down directly. */
824 + machine_power_off();
825 +
826 + return IRQ_HANDLED;
827 +}
828 +
829 static void __init dsmg600_timer_init(void)
830 {
831 /* The xtal on this machine is non-standard. */
832 @@ -164,8 +225,6 @@ static void __init dsmg600_init(void)
833 dsmg600_flash_resource.end =
834 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
835
836 - pm_power_off = dsmg600_power_off;
837 -
838 i2c_register_board_info(0, dsmg600_i2c_board_info,
839 ARRAY_SIZE(dsmg600_i2c_board_info));
840
841 @@ -176,6 +235,29 @@ static void __init dsmg600_init(void)
842 (void)platform_device_register(&dsmg600_uart);
843
844 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
845 +
846 + pm_power_off = dsmg600_power_off;
847 +
848 + if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
849 + IRQF_DISABLED | IRQF_TRIGGER_LOW,
850 + "DSM-G600 reset button", NULL) < 0) {
851 +
852 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
853 + gpio_to_irq(DSMG600_RB_GPIO));
854 + }
855 +
856 + /* The power button on the D-Link DSM-G600 is on GPIO 15, but
857 + * it cannot handle interrupts on that GPIO line. So we'll
858 + * have to poll it with a kernel timer.
859 + */
860 +
861 + /* Make sure that the power button GPIO is set up as an input */
862 + gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
863 +
864 + /* Set the initial value for the power button IRQ handler */
865 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
866 +
867 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
868 }
869
870 MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
871 --
872 1.5.2.5
873
This page took 0.079037 seconds and 3 git commands to generate.