[at91] refresh kernel patches
[openwrt.git] / target / linux / at91 / patches-2.6.21 / 002-led-driver.patch
1 Index: linux-2.6.21.7/arch/arm/mach-at91/board-vlink.c
2 ===================================================================
3 --- linux-2.6.21.7.orig/arch/arm/mach-at91/board-vlink.c
4 +++ linux-2.6.21.7/arch/arm/mach-at91/board-vlink.c
5 @@ -61,7 +61,7 @@ static void __init vlink_map_io(void)
6 at91rm9200_initialize(18432000, AT91RM9200_PQFP);
7
8 /* Setup the LEDs */
9 -// at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2);
10 + at91_init_leds(AT91_PIN_PC14, AT91_PIN_PC15);
11
12 /* Setup the serial ports and console */
13 at91_init_serial(&vlink_uart_config);
14 @@ -81,10 +81,12 @@ static struct at91_usbh_data __initdata
15 .ports = 1,
16 };
17
18 +/*
19 static struct at91_udc_data __initdata vlink_udc_data = {
20 .vbus_pin = AT91_PIN_PD4,
21 .pullup_pin = AT91_PIN_PD5,
22 };
23 +*/
24
25 static struct at91_mmc_data __initdata vlink_mmc_data = {
26 // .det_pin = AT91_PIN_PB27,
27 @@ -108,18 +110,19 @@ static struct spi_board_info vlink_spi_d
28 #endif
29 };
30
31 -static struct at91_gpio_led vlink_leds[] = {
32 +/*static struct at91_gpio_led vlink_leds[] = {
33 {
34 .name = "led0",
35 - .gpio = AT91_PIN_PB1,
36 + .gpio = AT91_PIN_PC14,
37 .trigger = "heartbeat",
38 },
39 {
40 .name = "led1",
41 - .gpio = AT91_PIN_PB2,
42 + .gpio = AT91_PIN_PC15,
43 .trigger = "timer",
44 }
45 };
46 +*/
47
48 static void __init vlink_board_init(void)
49 {
50 @@ -130,8 +133,8 @@ static void __init vlink_board_init(void
51 /* USB Host */
52 at91_add_device_usbh(&vlink_usbh_data);
53 /* USB Device */
54 - at91_add_device_udc(&vlink_udc_data);
55 - at91_set_multi_drive(vlink_udc_data.pullup_pin, 1); /* pullup_pin is connected to reset */
56 +// at91_add_device_udc(&vlink_udc_data);
57 +// at91_set_multi_drive(vlink_udc_data.pullup_pin, 1); /* pullup_pin is connected to reset */
58 /* I2C */
59 at91_add_device_i2c();
60 /* SPI */
61 @@ -145,7 +148,7 @@ static void __init vlink_board_init(void
62 at91_add_device_mmc(0, &vlink_mmc_data);
63 #endif
64 /* LEDs */
65 - at91_gpio_leds(vlink_leds, ARRAY_SIZE(vlink_leds));
66 +// at91_gpio_leds(vlink_leds, ARRAY_SIZE(vlink_leds));
67 }
68
69 MACHINE_START(VLINK, "FDL VersaLink")
70 Index: linux-2.6.21.7/arch/arm/mach-at91/Makefile
71 ===================================================================
72 --- linux-2.6.21.7.orig/arch/arm/mach-at91/Makefile
73 +++ linux-2.6.21.7/arch/arm/mach-at91/Makefile
74 @@ -52,7 +52,7 @@ led-$(CONFIG_MACH_CSB337) += leds.o
75 led-$(CONFIG_MACH_CSB637) += leds.o
76 led-$(CONFIG_MACH_KB9200) += leds.o
77 led-$(CONFIG_MACH_KAFA) += leds.o
78 -led-$(CONFIG_MACH_VLINK) += leds.o
79 +led-$(CONFIG_MACH_VLINK) += vlink_leds.o
80 obj-$(CONFIG_LEDS) += $(led-y)
81
82 # VGA support
83 Index: linux-2.6.21.7/arch/arm/mach-at91/vlink_leds.c
84 ===================================================================
85 --- /dev/null
86 +++ linux-2.6.21.7/arch/arm/mach-at91/vlink_leds.c
87 @@ -0,0 +1,105 @@
88 +/*
89 + * LED driver for Atmel AT91-based boards.
90 + *
91 + * Copyright (C) SAN People (Pty) Ltd
92 + * Modified for FDL VersaLink Copyright (C) Guthrie Consulting
93 + *
94 + * This program is free software; you can redistribute it and/or
95 + * modify it under the terms of the GNU General Public License
96 + * as published by the Free Software Foundation; either version
97 + * 2 of the License, or (at your option) any later version.
98 +*/
99 +
100 +#include <linux/kernel.h>
101 +#include <linux/module.h>
102 +#include <linux/init.h>
103 +
104 +#include <asm/mach-types.h>
105 +#include <asm/leds.h>
106 +#include <asm/arch/board.h>
107 +#include <asm/arch/gpio.h>
108 +
109 +
110 +static inline void at91_led_on(unsigned int led)
111 +{
112 + at91_set_gpio_value(led, 0);
113 +}
114 +
115 +static inline void at91_led_off(unsigned int led)
116 +{
117 + at91_set_gpio_value(led, 1);
118 +}
119 +
120 +static inline void at91_led_toggle(unsigned int led)
121 +{
122 + unsigned long is_off = at91_get_gpio_value(led);
123 + if (is_off) {
124 + at91_led_on(led);
125 + at91_led_off(at91_leds_cpu);
126 + }
127 + else {
128 + at91_led_on(at91_leds_cpu);
129 + at91_led_off(led);
130 + }
131 +}
132 +
133 +
134 +/*
135 + * Handle LED events.
136 + */
137 +
138 +/*
139 + * VersaLink has a single bi-coloured LED which changes colour when the
140 + * polarity is reversed
141 + */
142 +static void at91_leds_event(led_event_t evt)
143 +{
144 + unsigned long flags;
145 +
146 + local_irq_save(flags);
147 +
148 + switch(evt) {
149 + case led_start: /* System startup */
150 + at91_led_toggle(at91_leds_timer);
151 + break;
152 +
153 + case led_stop: /* System stop / suspend */
154 + at91_led_toggle(at91_leds_timer);
155 + break;
156 +
157 +#ifdef CONFIG_LEDS_TIMER
158 + case led_timer: /* Every 50 timer ticks */
159 + at91_led_toggle(at91_leds_timer);
160 + break;
161 +#endif
162 +
163 +#ifdef CONFIG_LEDS_CPU
164 + case led_idle_start: /* Entering idle state */
165 + at91_led_toggle(at91_leds_timer);
166 + break;
167 +
168 + case led_idle_end: /* Exit idle state */
169 + at91_led_toggle(at91_leds_timer);
170 + break;
171 +#endif
172 +
173 + default:
174 + break;
175 + }
176 +
177 + local_irq_restore(flags);
178 +}
179 +
180 +
181 +static int __init leds_init(void)
182 +{
183 + if (!at91_leds_timer || !at91_leds_cpu)
184 + return -ENODEV;
185 +
186 + leds_event = at91_leds_event;
187 +
188 + leds_event(led_start);
189 + return 0;
190 +}
191 +
192 +__initcall(leds_init);
This page took 0.054031 seconds and 5 git commands to generate.