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