[adm5120] fix a bug in the switch driver, thanks to Thomas Langer for reporting
[openwrt.git] / target / linux / at91 / patches-2.6.22 / 002-led-driver.patch
1 diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/Makefile linux-2.6.22.1/arch/arm/mach-at91/Makefile
2 --- linux-2.6.22.1.old/arch/arm/mach-at91/Makefile 2007-07-29 06:46:13.000000000 +0200
3 +++ linux-2.6.22.1/arch/arm/mach-at91/Makefile 2007-07-29 06:54:19.000000000 +0200
4 @@ -53,7 +53,7 @@
5 led-$(CONFIG_MACH_CSB637) += leds.o
6 led-$(CONFIG_MACH_KB9200) += leds.o
7 led-$(CONFIG_MACH_KAFA) += leds.o
8 -led-$(CONFIG_MACH_VLINK) += leds.o
9 +led-$(CONFIG_MACH_VLINK) += vlink_leds.o
10 obj-$(CONFIG_LEDS) += $(led-y)
11
12 # VGA support
13 diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/vlink_leds.c linux-2.6.22.1/arch/arm/mach-at91/vlink_leds.c
14 --- linux-2.6.22.1.old/arch/arm/mach-at91/vlink_leds.c 1970-01-01 01:00:00.000000000 +0100
15 +++ linux-2.6.22.1/arch/arm/mach-at91/vlink_leds.c 2007-07-29 06:54:58.000000000 +0200
16 @@ -0,0 +1,105 @@
17 +/*
18 + * LED driver for Atmel AT91-based boards.
19 + *
20 + * Copyright (C) SAN People (Pty) Ltd
21 + * Modified for FDL VersaLink Copyright (C) Guthrie Consulting
22 + *
23 + * This program is free software; you can redistribute it and/or
24 + * modify it under the terms of the GNU General Public License
25 + * as published by the Free Software Foundation; either version
26 + * 2 of the License, or (at your option) any later version.
27 +*/
28 +
29 +#include <linux/kernel.h>
30 +#include <linux/module.h>
31 +#include <linux/init.h>
32 +
33 +#include <asm/mach-types.h>
34 +#include <asm/leds.h>
35 +#include <asm/arch/board.h>
36 +#include <asm/arch/gpio.h>
37 +
38 +
39 +static inline void at91_led_on(unsigned int led)
40 +{
41 + at91_set_gpio_value(led, 0);
42 +}
43 +
44 +static inline void at91_led_off(unsigned int led)
45 +{
46 + at91_set_gpio_value(led, 1);
47 +}
48 +
49 +static inline void at91_led_toggle(unsigned int led)
50 +{
51 + unsigned long is_off = at91_get_gpio_value(led);
52 + if (is_off) {
53 + at91_led_on(led);
54 + at91_led_off(at91_leds_cpu);
55 + }
56 + else {
57 + at91_led_on(at91_leds_cpu);
58 + at91_led_off(led);
59 + }
60 +}
61 +
62 +
63 +/*
64 + * Handle LED events.
65 + */
66 +
67 +/*
68 + * VersaLink has a single bi-coloured LED which changes colour when the
69 + * polarity is reversed
70 + */
71 +static void at91_leds_event(led_event_t evt)
72 +{
73 + unsigned long flags;
74 +
75 + local_irq_save(flags);
76 +
77 + switch(evt) {
78 + case led_start: /* System startup */
79 + at91_led_toggle(at91_leds_timer);
80 + break;
81 +
82 + case led_stop: /* System stop / suspend */
83 + at91_led_toggle(at91_leds_timer);
84 + break;
85 +
86 +#ifdef CONFIG_LEDS_TIMER
87 + case led_timer: /* Every 50 timer ticks */
88 + at91_led_toggle(at91_leds_timer);
89 + break;
90 +#endif
91 +
92 +#ifdef CONFIG_LEDS_CPU
93 + case led_idle_start: /* Entering idle state */
94 + at91_led_toggle(at91_leds_timer);
95 + break;
96 +
97 + case led_idle_end: /* Exit idle state */
98 + at91_led_toggle(at91_leds_timer);
99 + break;
100 +#endif
101 +
102 + default:
103 + break;
104 + }
105 +
106 + local_irq_restore(flags);
107 +}
108 +
109 +
110 +static int __init leds_init(void)
111 +{
112 + if (!at91_leds_timer || !at91_leds_cpu)
113 + return -ENODEV;
114 +
115 + leds_event = at91_leds_event;
116 +
117 + leds_event(led_start);
118 + return 0;
119 +}
120 +
121 +__initcall(leds_init);
This page took 0.046774 seconds and 5 git commands to generate.