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