]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-bsp/u-boot/u-boot/0039-Add-led-command.patch
BSP: rename beagleboard to TI
[glsdk/meta-ti-glsdk.git] / recipes-bsp / u-boot / u-boot / 0039-Add-led-command.patch
1 From 609524ecd54526b3f3c7d52cc43a3c9795970f6b Mon Sep 17 00:00:00 2001
2 From: Jason Kridner <jkridner@beagleboard.org>
3 Date: Thu, 20 May 2010 05:41:26 -0500
4 Subject: [PATCH] Add 'led' command
6 This patch allows any board implementing the coloured LED API
7 to control the LEDs from the console.
9 led [green | yellow | red | all ]  [ on | off ]
11 or
13 led [ 1 | 2 | 3 | all ]  [ on | off ]
15 Adds configuration item CONFIG_CMD_LED enabling the command.
17 Partially based on patch from Ulf Samuelsson:
18 http://www.mail-archive.com/u-boot@lists.denx.de/msg09593.html.
19 (cherry picked from commit aaf47f8d6af81393b7d3275d69b5dbdf07a3d6fb)
20 (cherry picked from commit 3d314bf59a48c2ee93d06d50b81f109af6a6c1ec)
22 Signed-off-by: Jason Kridner <jkridner@beagleboard.org>
23 ---
24  common/Makefile  |    1 +
25  common/cmd_led.c |  207 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
26  2 files changed, 208 insertions(+), 0 deletions(-)
27  create mode 100644 common/cmd_led.c
29 diff --git a/common/Makefile b/common/Makefile
30 index dbf7a05..1d717ca 100644
31 --- a/common/Makefile
32 +++ b/common/Makefile
33 @@ -106,6 +106,7 @@ COBJS-$(CONFIG_CMD_IRQ) += cmd_irq.o
34  COBJS-$(CONFIG_CMD_ITEST) += cmd_itest.o
35  COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o
36  COBJS-$(CONFIG_CMD_CRAMFS) += cmd_cramfs.o
37 +COBJS-$(CONFIG_CMD_LED) += cmd_led.o
38  COBJS-$(CONFIG_CMD_LICENSE) += cmd_license.o
39  COBJS-y += cmd_load.o
40  COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o
41 diff --git a/common/cmd_led.c b/common/cmd_led.c
42 new file mode 100644
43 index 0000000..3b7b534
44 --- /dev/null
45 +++ b/common/cmd_led.c
46 @@ -0,0 +1,207 @@
47 +/*
48 + * (C) Copyright 2010
49 + * Jason Kridner <jkridner@beagleboard.org>
50 + *
51 + * Based on cmd_led.c patch from:
52 + * http://www.mail-archive.com/u-boot@lists.denx.de/msg06873.html
53 + * (C) Copyright 2008
54 + * Ulf Samuelsson <ulf.samuelsson@atmel.com>
55 + *
56 + * See file CREDITS for list of people who contributed to this
57 + * project.
58 + *
59 + * This program is free software; you can redistribute it and/or
60 + * modify it under the terms of the GNU General Public License as
61 + * published by the Free Software Foundation; either version 2 of
62 + * the License, or (at your option) any later version.
63 + *
64 + * This program is distributed in the hope that it will be useful,
65 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
66 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
67 + * GNU General Public License for more details.
68 + *
69 + * You should have received a copy of the GNU General Public License
70 + * along with this program; if not, write to the Free Software
71 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
72 + * MA 02111-1307 USA
73 + */
74 +
75 +/*
76 + * This file provides a shell like 'test' function to return
77 + * true/false from an integer or string compare of two memory
78 + * locations or a location and a scalar/literal.
79 + * A few parts were lifted from bash 'test' command
80 + */
81 +
82 +#include <common.h>
83 +#include <config.h>
84 +#include <command.h>
85 +#include <status_led.h>
86 +
87 +int do_led ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] )
88 +{
89 +#ifdef CONFIG_BOARD_SPECIFIC_LED
90 +       led_id_t mask;
91 +#endif
92 +       int state;
93 +
94 +       /* Validate arguments */
95 +       if ((argc != 3)){
96 +               printf("Usage:\n%s\n", cmdtp->usage);
97 +               return 1;
98 +       }
99 +
100 +       if (strcmp(argv[2], "off") == 0) {
101 +               state = 0;
102 +       } else if (strcmp(argv[2], "on") == 0) {
103 +               state = 1;
104 +       } else {
105 +               printf ("Usage:\n%s\n", cmdtp->usage);
106 +               return 1;
107 +       }
109 +#if defined(STATUS_LED_BIT) && defined(CONFIG_BOARD_SPECIFIC_LED)
110 +       if (strcmp(argv[1], "0") == 0) {
111 +               mask = STATUS_LED_BIT;
112 +               __led_set(mask, state);
113 +       }
114 +       else
115 +#endif
116 +#if defined(STATUS_LED_BIT1) && defined(CONFIG_BOARD_SPECIFIC_LED)
117 +       if (strcmp(argv[1], "1") == 0) {
118 +               mask = STATUS_LED_BIT1;
119 +               __led_set(mask, state);
120 +       }
121 +       else
122 +#endif
123 +#if defined(STATUS_LED_BIT2) && defined(CONFIG_BOARD_SPECIFIC_LED)
124 +       if (strcmp(argv[1], "2") == 0) {
125 +               mask = STATUS_LED_BIT2;
126 +               __led_set(mask, state);
127 +       }
128 +       else
129 +#endif
130 +#if defined(STATUS_LED_BIT3) && defined(CONFIG_BOARD_SPECIFIC_LED)
131 +       if (strcmp(argv[1], "3") == 0) {
132 +               mask = STATUS_LED_BIT3;
133 +               __led_set(mask, state);
134 +       }
135 +       else
136 +#endif
137 +#ifdef STATUS_LED_RED
138 +       if (strcmp(argv[1], "red") == 0) {
139 +               if (state == 0)
140 +                       red_LED_off();
141 +               else
142 +                       red_LED_on();
143 +       }
144 +       else
145 +#endif
146 +#ifdef STATUS_LED_GREEN
147 +       if (strcmp(argv[1], "green") == 0) {
148 +               if (state == 0)
149 +                       green_LED_off();
150 +               else
151 +                       green_LED_on();
152 +       }
153 +       else
154 +#endif
155 +#ifdef STATUS_LED_YELLOW
156 +       if (strcmp(argv[1], "yellow") == 0) {
157 +               if (state == 0)
158 +                       yellow_LED_off();
159 +               else
160 +                       yellow_LED_on();
161 +       }
162 +       else
163 +#endif
164 +#ifdef STATUS_LED_BLUE
165 +       if (strcmp(argv[1], "blue") == 0) {
166 +               if (state == 0)
167 +                       blue_LED_off();
168 +               else
169 +                       blue_LED_on();
170 +       }
171 +       else
172 +#endif
173 +       if (strcmp(argv[1], "all") == 0) {
174 +               mask = 0
175 +#if defined(STATUS_LED_BIT) && defined(CONFIG_BOARD_SPECIFIC_LED)
176 +                       | STATUS_LED_BIT
177 +#endif
178 +#if defined(STATUS_LED_BIT1) && defined(CONFIG_BOARD_SPECIFIC_LED)
179 +                       | STATUS_LED_BIT1
180 +#endif
181 +#if defined(STATUS_LED_BIT2) && defined(CONFIG_BOARD_SPECIFIC_LED)
182 +                       | STATUS_LED_BIT2
183 +#endif
184 +#if defined(STATUS_LED_BIT3) && defined(CONFIG_BOARD_SPECIFIC_LED)
185 +                       | STATUS_LED_BIT3
186 +#endif
187 +                       ;
188 +#ifdef CONFIG_BOARD_SPECIFIC_LED
189 +               __led_set(mask, state);
190 +#endif
191 +#ifdef STATUS_LED_RED
192 +               if (state == 0)
193 +                       red_LED_off();
194 +               else
195 +                       red_LED_on();
196 +#endif
197 +#ifdef STATUS_LED_GREEN
198 +               if (state == 0)
199 +                       green_LED_off();
200 +               else
201 +                       green_LED_on();
202 +#endif
203 +#ifdef STATUS_LED_YELLOW
204 +               if (state == 0)
205 +                       yellow_LED_off();
206 +               else
207 +                       yellow_LED_on();
208 +#endif
209 +#ifdef STATUS_LED_BLUE
210 +               if (state == 0)
211 +                       blue_LED_off();
212 +               else
213 +                       blue_LED_on();
214 +#endif
215 +       } else {
216 +               printf ("Usage:\n%s\n", cmdtp->usage);
217 +               return 1;
218 +       }
220 +       return 0;
221 +}
223 +U_BOOT_CMD(
224 +       led, 3, 1, do_led,
225 +       "led\t- ["
226 +#if defined(STATUS_LED_BIT) && defined(CONFIG_BOARD_SPECIFIC_LED)
227 +       "0|"
228 +#endif
229 +#if defined(STATUS_LED_BIT1) && defined(CONFIG_BOARD_SPECIFIC_LED)
230 +       "1|"
231 +#endif
232 +#if defined(STATUS_LED_BIT2) && defined(CONFIG_BOARD_SPECIFIC_LED)
233 +       "2|"
234 +#endif
235 +#if defined(STATUS_LED_BIT3) && defined(CONFIG_BOARD_SPECIFIC_LED)
236 +       "3|"
237 +#endif
238 +#ifdef STATUS_LED_GREEN
239 +       "green|"
240 +#endif
241 +#ifdef STATUS_LED_YELLOW
242 +       "yellow|"
243 +#endif
244 +#ifdef STATUS_LED_RED
245 +       "red|"
246 +#endif
247 +#ifdef STATUS_LED_BLUE
248 +       "blue|"
249 +#endif
250 +       "all] [on|off]\n",
251 +       "led [led_name] [on|off] sets or clears led(s)\n"
252 +);
254 -- 
255 1.5.6.4