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