summaryrefslogtreecommitdiff
path: root/target/device/Atmel/arch-arm/u-boot/2009.01/u-boot-2009.01-010-coloured_led.patch
blob: 5c1d29dce52288d95364a98dcb80652aef13a594 (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
190
191
192
193
194
195
196
diff -urN u-boot-2009.01-0rig//common/cmd_led.c u-boot-2009.01/common/cmd_led.c
--- u-boot-2009.01-0rig//common/cmd_led.c	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-2009.01/common/cmd_led.c	2009-01-03 23:39:57.000000000 +0100
@@ -0,0 +1,84 @@
+/*
+ * (C) Copyright 2008
+ * Ulf Samuelsson <ulf.samuelsson@atmel.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * This file provides a shell like 'test' function to return
+ * true/false from an integer or string compare of two memory
+ * locations or a location and a scalar/literal.
+ * A few parts were lifted from bash 'test' command
+ */
+
+#include <common.h>
+#include <config.h>
+#include <command.h>
+#include <coloured_led.h>
+
+int do_led ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] )
+{
+	int	led;
+	/* Validate arguments */
+	if ((argc != 3)){
+		printf("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+	if (strcmp(argv[1], "1") == 0) {
+		led = (1 << 0);
+	} else if (strcmp(argv[1], "2") == 0) {
+		led = (1 << 1);
+	} else if (strcmp(argv[1], "3") == 0) {
+		led = (1 << 2);
+	} else if (strcmp(argv[1], "green") == 0) {
+		led = (1 << 0);
+	} else if (strcmp(argv[1], "yellow") == 0) {
+		led = (1 << 1);
+	} else if (strcmp(argv[1], "red") == 0) {
+		led = (1 << 2);
+	} else if (strcmp(argv[1], "all") == 0) {
+		led = 7;
+	} else {
+		printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	if (strcmp(argv[2], "off") == 0) {
+		if(led & 1) green_LED_off();
+		if(led & 2) yellow_LED_off();
+		if(led & 4) red_LED_off();		
+	} else if (strcmp(argv[2], "on") == 0) {
+		if(led & 1) green_LED_on();
+		if(led & 2) yellow_LED_on();
+		if(led & 4) red_LED_on();		
+	} else {
+		printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	led, 3, 1, do_led,
+	"led\t- [1|2|3|green|yellow|red|all] [on|off]\n",
+	"led [1|2|3|green|yellow|red|all] [on|off] sets /clears led 1,2,3\n"
+);
+
diff -urN u-boot-2009.01-0rig//common/Makefile u-boot-2009.01/common/Makefile
--- u-boot-2009.01-0rig//common/Makefile	2009-01-02 21:18:24.000000000 +0100
+++ u-boot-2009.01/common/Makefile	2009-01-03 23:41:53.000000000 +0100
@@ -99,6 +99,7 @@
 COBJS-$(CONFIG_CMD_IRQ) += cmd_irq.o
 COBJS-$(CONFIG_CMD_ITEST) += cmd_itest.o
 COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o
+COBJS-$(CONFIG_CMD_LED) += cmd_led.o
 COBJS-$(CONFIG_CMD_LICENSE) += cmd_license.o
 COBJS-y += cmd_load.o
 COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o
diff -urN u-boot-2009.01-0rig//include/coloured_led.h u-boot-2009.01/include/coloured_led.h
--- u-boot-2009.01-0rig//include/coloured_led.h	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-2009.01/include/coloured_led.h	2009-01-03 23:39:19.000000000 +0100
@@ -0,0 +1,62 @@
+/*
+ * (C) Copyright 2008
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ * 
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * The purpose of this code is to signal the operational status of a
+ * target which usually boots over the network; while running in
+ * PCBoot, a status LED is blinking. As soon as a valid BOOTP reply
+ * message has been received, the LED is turned off. The Linux
+ * kernel, once it is running, will start blinking the LED again,
+ * with another frequency.
+ */
+
+#ifndef _COLOURED_LED_H_
+#define	_COLOURED_LED_H_
+
+#ifdef CONFIG_COLOURED_LED
+
+/*
+ * Coloured LEDs API
+ */
+#ifndef	__ASSEMBLY__
+extern void	coloured_LED_init (void);
+extern void	red_LED_on(void);
+extern void	red_LED_off(void);
+extern void	green_LED_on(void);
+extern void	green_LED_off(void);
+extern void	yellow_LED_on(void);
+extern void	yellow_LED_off(void);
+#else
+	.extern LED_init
+	.extern red_LED_on
+	.extern red_LED_off
+	.extern yellow_LED_on
+	.extern yellow_LED_off
+	.extern green_LED_on
+	.extern green_LED_off
+#endif
+
+#endif	/* CONFIG_COLOURED_LED	*/
+
+#endif	/* _STATUS_COLOURED_H_	*/
+
diff -urN u-boot-2009.01-0rig//include/status_led.h u-boot-2009.01/include/status_led.h
--- u-boot-2009.01-0rig//include/status_led.h	2008-12-16 23:48:27.000000000 +0100
+++ u-boot-2009.01/include/status_led.h	2009-01-03 23:44:40.000000000 +0100
@@ -383,27 +383,6 @@
 # include <asm/status_led.h>
 #endif
 
-/*
- * Coloured LEDs API
- */
-#ifndef	__ASSEMBLY__
-extern void	coloured_LED_init (void);
-extern void	red_LED_on(void);
-extern void	red_LED_off(void);
-extern void	green_LED_on(void);
-extern void	green_LED_off(void);
-extern void	yellow_LED_on(void);
-extern void	yellow_LED_off(void);
-#else
-	.extern LED_init
-	.extern red_LED_on
-	.extern red_LED_off
-	.extern yellow_LED_on
-	.extern yellow_LED_off
-	.extern green_LED_on
-	.extern green_LED_off
-#endif
-
 #endif	/* CONFIG_STATUS_LED	*/
 
 #endif	/* _STATUS_LED_H_	*/