Fixes from Compex to make OpenWrt run on WP54AG, thanks !
[openwrt.git] / target / linux / at91-2.6 / patches / 002-led-driver.patch
1 diff -urN linux-2.6.19.2.old/arch/arm/mach-at91rm9200/Makefile linux-2.6.19.2/arch/arm/mach-at91rm9200/Makefile
2 --- linux-2.6.19.2.old/arch/arm/mach-at91rm9200/Makefile 2007-03-06 11:29:37.000000000 +0100
3 +++ linux-2.6.19.2/arch/arm/mach-at91rm9200/Makefile 2007-03-06 20:52:28.000000000 +0100
4 @@ -40,6 +40,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) += vlink_leds.o
9 obj-$(CONFIG_LEDS) += $(led-y)
10
11 # VGA support
12 diff -urN linux-2.6.19.2.old/arch/arm/mach-at91rm9200/vlink_leds.c linux-2.6.19.2/arch/arm/mach-at91rm9200/vlink_leds.c
13 --- linux-2.6.19.2.old/arch/arm/mach-at91rm9200/vlink_leds.c 1970-01-01 01:00:00.000000000 +0100
14 +++ linux-2.6.19.2/arch/arm/mach-at91rm9200/vlink_leds.c 2007-03-06 21:11:16.000000000 +0100
15 @@ -0,0 +1,151 @@
16 +/*
17 + * LED driver for Atmel AT91-based boards.
18 + *
19 + * Copyright (C) SAN People (Pty) Ltd
20 + *
21 + * Modified for FDL Versalink board (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 +#define LED_CPU 0
39 +#define LED_TIMER 1
40 +#define LED_COM1 2
41 +#define LED_COM2 3
42 +
43 +static inline void at91_led_on(unsigned int led)
44 +{
45 + at91_set_gpio_value(led, 0);
46 +}
47 +
48 +static inline void at91_led_off(unsigned int led)
49 +{
50 + at91_set_gpio_value(led, 1);
51 +}
52 +
53 +static inline void at91_led_toggle(unsigned int led)
54 +{
55 + unsigned long is_off = at91_get_gpio_value(AT91_PIN_PC7);
56 + if (is_off) {
57 + at91_set_gpio_value(AT91_PIN_PC7, 0);
58 + at91_set_gpio_value(AT91_PIN_PC8, 1);
59 + } else {
60 + at91_set_gpio_value(AT91_PIN_PC7, 1);
61 + at91_set_gpio_value(AT91_PIN_PC8, 0);
62 + }
63 +}
64 +
65 +
66 +/*
67 + * Handle LED events.
68 + */
69 +static void at91_leds_event(led_event_t evt)
70 +{
71 + unsigned long flags;
72 +
73 + local_irq_save(flags);
74 +
75 + switch(evt) {
76 + case led_start: /* System startup */
77 +// at91_led_on(at91_leds_cpu);
78 + at91_led_toggle(at91_leds_timer);
79 +/*
80 + at91_set_gpio_value(AT91_PIN_PC7, 0);
81 + at91_set_gpio_value(AT91_PIN_PC8, 1);
82 +*/
83 + break;
84 +
85 + case led_stop: /* System stop / suspend */
86 + at91_led_toggle(at91_leds_timer);
87 +/*
88 + at91_set_gpio_value(AT91_PIN_PC7, 1);
89 + at91_set_gpio_value(AT91_PIN_PC8, 0);
90 +*/
91 + break;
92 +
93 +#ifdef CONFIG_LEDS_TIMER
94 + case led_timer: /* Every 50 timer ticks */
95 + at91_led_toggle(at91_leds_timer);
96 + break;
97 +#endif
98 +
99 +#ifdef CONFIG_LEDS_CPU
100 + case led_idle_start: /* Entering idle state */
101 + at91_led_toggle(at91_leds_timer);
102 +/*
103 + at91_set_gpio_value(AT91_PIN_PC7, 1);
104 + at91_set_gpio_value(AT91_PIN_PC8, 0);
105 +*/
106 + break;
107 +
108 + case led_idle_end: /* Exit idle state */
109 + at91_led_toggle(at91_leds_timer);
110 +/*
111 + at91_set_gpio_value(AT91_PIN_PC7, 0);
112 + at91_set_gpio_value(AT91_PIN_PC8, 1);
113 +*/
114 + break;
115 +#endif
116 +
117 + default:
118 + break;
119 + }
120 +
121 + local_irq_restore(flags);
122 +}
123 +
124 +
125 +static int __init leds_init(void)
126 +{
127 +/* if (!at91_leds_timer || !at91_leds_cpu)
128 + return -ENODEV;
129 +*/
130 +// printk("leds_init()\n");
131 +
132 + /* Enable PIO to access the LEDs */
133 + at91_set_gpio_output(AT91_PIN_PC7, 1);
134 + at91_set_gpio_output(AT91_PIN_PC8, 1);
135 + at91_set_gpio_output(AT91_PIN_PC14, 1);
136 + at91_set_gpio_output(AT91_PIN_PC15, 1);
137 + at91_set_gpio_output(AT91_PIN_PB14, 1);
138 + at91_set_gpio_output(AT91_PIN_PB15, 1);
139 + at91_set_gpio_output(AT91_PIN_PB16, 1);
140 + at91_set_gpio_output(AT91_PIN_PB17, 1);
141 +
142 + at91_set_gpio_output(AT91_PIN_PB9, 1);
143 + at91_set_gpio_output(AT91_PIN_PB10, 1);
144 + at91_set_gpio_output(AT91_PIN_PB11, 1);
145 + at91_set_gpio_output(AT91_PIN_PB12, 1);
146 +
147 + at91_set_gpio_input(AT91_PIN_PB8, 1);
148 + at91_set_gpio_input(AT91_PIN_PB22, 1);
149 + at91_set_gpio_input(AT91_PIN_PA19, 1);
150 + at91_set_gpio_input(AT91_PIN_PA24, 1);
151 + at91_set_gpio_output(AT91_PIN_PA29, 1);
152 + at91_set_gpio_output(AT91_PIN_PB2, 1);
153 + at91_set_gpio_output(AT91_PIN_PB3, 1);
154 + at91_set_gpio_output(AT91_PIN_PB4, 1);
155 +
156 + at91_set_gpio_input(AT91_PIN_PB27, 1);
157 + at91_set_gpio_input(AT91_PIN_PB28, 1);
158 + at91_set_gpio_input(AT91_PIN_PB29, 1);
159 +
160 + leds_event = at91_leds_event;
161 +
162 + leds_event(led_start);
163 + return 0;
164 +}
165 +
166 +__initcall(leds_init);
This page took 0.058567 seconds and 5 git commands to generate.