]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/ssv/common/cmd_sled.c
2 * (C) Copyright 2004, Li-Pro.Net <www.li-pro.net>
3 * Stephan Linz <linz@li-pro.net>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <status_led.h>
28 #if defined(CONFIG_STATUS_LED)
30 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 * !!!!! Q u i c k & D i r t y H a c k !!!!!
32 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
34 * !!!!! Next type definition was coming from original !!!!!
35 * !!!!! status LED driver drivers/status_led.c and !!!!!
36 * !!!!! should exported for using here. !!!!!
38 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
47 extern led_dev_t led_dev
[];
49 #if (CONFIG_COMMANDS & CFG_CMD_BSP)
50 int do_sled (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
55 #ifdef STATUS_LED_BOOT
56 if (!strcmp (argv
[1], "boot")) {
57 led_id
= STATUS_LED_BOOT
+ 1;
61 if (!strcmp (argv
[1], "red")) {
62 led_id
= STATUS_LED_RED
+ 1;
65 #ifdef STATUS_LED_YELLOW
66 if (!strcmp (argv
[1], "yellow")) {
67 led_id
= STATUS_LED_YELLOW
+ 1;
70 #ifdef STATUS_LED_GREEN
71 if (!strcmp (argv
[1], "green")) {
72 led_id
= STATUS_LED_GREEN
+ 1;
79 #if (STATUS_LED_BITS > 3)
80 for (; led_id
< 4; led_id
++)
81 #elif (STATUS_LED_BITS > 2)
82 for (; led_id
< 3; led_id
++)
83 #elif (STATUS_LED_BITS > 1)
84 for (; led_id
< 2; led_id
++)
85 #elif (STATUS_LED_BITS > 0)
86 for (; led_id
< 1; led_id
++)
88 #error "*** STATUS_LED_BITS not correct defined ***"
91 printf ("Status LED '%s' is %s\n",
92 led_id
== STATUS_LED_BOOT
? "boot"
93 : led_id
== STATUS_LED_RED
? "red"
94 : led_id
== STATUS_LED_YELLOW
? "yellow"
96 STATUS_LED_GREEN
? "green" : "unknown",
97 led_dev
[led_id
].state
==
98 STATUS_LED_ON
? "on" : led_dev
[led_id
].
100 STATUS_LED_OFF
? "off" : led_dev
[led_id
].
102 STATUS_LED_BLINKING
? "blinking" : "unknown");
107 printf ("Status LED '%s' is %s\n", argv
[1],
108 led_dev
[led_id
- 1].state
==
109 STATUS_LED_ON
? "on" : led_dev
[led_id
-
111 STATUS_LED_OFF
? "off" : led_dev
[led_id
-
113 STATUS_LED_BLINKING
? "blinking" : "unknown");
119 if (!strcmp (argv
[2], "on")) {
120 status_led_set (led_id
- 1, STATUS_LED_ON
);
122 } else if (!strcmp (argv
[2], "off")) {
123 status_led_set (led_id
- 1, STATUS_LED_OFF
);
125 } else if (!strcmp (argv
[2], "blink")) {
126 status_led_set (led_id
- 1,
127 STATUS_LED_BLINKING
);
136 printf ("Usage:\n%s\n", cmdtp
->usage
);
140 #ifdef STATUS_LED_BOOT
141 #ifdef STATUS_LED_RED
142 #ifdef STATUS_LED_YELLOW
143 #ifdef STATUS_LED_GREEN
144 #define __NAME_STR " - name: boot|red|yellow|green\n"
146 #define __NAME_STR " - name: boot|red|yellow\n"
149 #define __NAME_STR " - name: boot|red\n"
152 #define __NAME_STR " - name: boot\n"
155 #define __NAME_STR " - name: (no such defined)\n"
158 U_BOOT_CMD (sled
, 3, 0, do_sled
,
159 "sled - check and set status led\n",
160 "sled [name [state]]\n" __NAME_STR
" - state: on|off|blink\n");
161 #endif /* CFG_CMD_BSP */
162 #endif /* CONFIG_STATUS_LED */