2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
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,
25 #include <status_led.h>
28 * The purpose of this code is to signal the operational status of a
29 * target which usually boots over the network; while running in
30 * U-Boot, a status LED is blinking. As soon as a valid BOOTP reply
31 * message has been received, the LED is turned off. The Linux
32 * kernel, once it is running, will start blinking the LED again,
33 * with another frequency.
36 /* ------------------------------------------------------------------------- */
38 #ifdef CONFIG_STATUS_LED
47 led_dev_t led_dev
[] = {
53 #if defined(STATUS_LED_BIT1)
60 #if defined(STATUS_LED_BIT2)
67 #if defined(STATUS_LED_BIT3)
76 #define MAX_LED_DEV (sizeof(led_dev)/sizeof(led_dev_t))
78 static int status_led_init_done
= 0;
80 static void status_led_init (void)
85 for (i
= 0, ld
= led_dev
; i
< MAX_LED_DEV
; i
++, ld
++)
86 __led_init (ld
->mask
, ld
->state
);
87 status_led_init_done
= 1;
90 void status_led_tick (ulong timestamp
)
95 if (!status_led_init_done
)
98 for (i
= 0, ld
= led_dev
; i
< MAX_LED_DEV
; i
++, ld
++) {
100 if (ld
->state
!= STATUS_LED_BLINKING
)
103 if (++ld
->cnt
>= ld
->period
) {
104 __led_toggle (ld
->mask
);
105 ld
->cnt
-= ld
->period
;
111 void status_led_set (int led
, int state
)
115 if (led
< 0 || led
>= MAX_LED_DEV
)
118 if (!status_led_init_done
)
124 if (state
== STATUS_LED_BLINKING
) {
125 ld
->cnt
= 0; /* always start with full period */
126 state
= STATUS_LED_ON
; /* always start with LED _ON_ */
128 __led_set (ld
->mask
, state
);
131 #endif /* CONFIG_STATUS_LED */