2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <status_led.h>
12 * The purpose of this code is to signal the operational status of a
13 * target which usually boots over the network; while running in
14 * U-Boot, a status LED is blinking. As soon as a valid BOOTP reply
15 * message has been received, the LED is turned off. The Linux
16 * kernel, once it is running, will start blinking the LED again,
17 * with another frequency.
20 /* ------------------------------------------------------------------------- */
29 led_dev_t led_dev[] = {
35 #if defined(STATUS_LED_BIT1)
42 #if defined(STATUS_LED_BIT2)
49 #if defined(STATUS_LED_BIT3)
56 #if defined(STATUS_LED_BIT4)
63 #if defined(STATUS_LED_BIT5)
72 #define MAX_LED_DEV (sizeof(led_dev)/sizeof(led_dev_t))
74 static int status_led_init_done = 0;
76 static void status_led_init (void)
81 for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++)
82 __led_init (ld->mask, ld->state);
83 status_led_init_done = 1;
86 void status_led_tick (ulong timestamp)
91 if (!status_led_init_done)
94 for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) {
96 if (ld->state != STATUS_LED_BLINKING)
99 if (++ld->cnt >= ld->period) {
100 __led_toggle (ld->mask);
101 ld->cnt -= ld->period;
107 void status_led_set (int led, int state)
111 if (led < 0 || led >= MAX_LED_DEV)
114 if (!status_led_init_done)
120 if (state == STATUS_LED_BLINKING) {
121 ld->cnt = 0; /* always start with full period */
122 state = STATUS_LED_ON; /* always start with LED _ON_ */
124 __led_set (ld->mask, state);