1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * (C) Copyright 2000-2004
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 */
6
7 /*
8 * The purpose of this code is to signal the operational status of a
9 * target which usually boots over the network; while running in
10 * PCBoot, a status LED is blinking. As soon as a valid BOOTP reply
11 * message has been received, the LED is turned off. The Linux
12 * kernel, once it is running, will start blinking the LED again,
13 * with another frequency.
14 */
15
16 #ifndef _STATUS_LED_H_
17 #define _STATUS_LED_H_
18
19 #ifdef CONFIG_LED_STATUS
20
21 #define LED_STATUS_PERIOD (CONFIG_SYS_HZ / CONFIG_LED_STATUS_FREQ)
22 #ifdef CONFIG_LED_STATUS1
23 #define LED_STATUS_PERIOD1 (CONFIG_SYS_HZ / CONFIG_LED_STATUS_FREQ1)
24 #endif /* CONFIG_LED_STATUS1 */
25 #ifdef CONFIG_LED_STATUS2
26 #define LED_STATUS_PERIOD2 (CONFIG_SYS_HZ / CONFIG_LED_STATUS_FREQ2)
27 #endif /* CONFIG_LED_STATUS2 */
28 #ifdef CONFIG_LED_STATUS3
29 #define LED_STATUS_PERIOD3 (CONFIG_SYS_HZ / CONFIG_LED_STATUS_FREQ3)
30 #endif /* CONFIG_LED_STATUS3 */
31 #ifdef CONFIG_LED_STATUS4
32 #define LED_STATUS_PERIOD4 (CONFIG_SYS_HZ / CONFIG_LED_STATUS_FREQ4)
33 #endif /* CONFIG_LED_STATUS4 */
34 #ifdef CONFIG_LED_STATUS5
35 #define LED_STATUS_PERIOD5 (CONFIG_SYS_HZ / CONFIG_LED_STATUS_FREQ5)
36 #endif /* CONFIG_LED_STATUS5 */
37
38 void status_led_init(void);
39 void status_led_tick(unsigned long timestamp);
40 void status_led_set(int led, int state);
41
status_led_boot_blink(void)42 static inline void status_led_boot_blink(void)
43 {
44 #ifdef CONFIG_LED_STATUS_BOOT_ENABLE
45 status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_BLINKING);
46 #endif
47 }
48
49 /***** MVS v1 **********************************************************/
50 #if (defined(CONFIG_MVS) && CONFIG_MVS < 2)
51 # define STATUS_LED_PAR im_ioport.iop_pdpar
52 # define STATUS_LED_DIR im_ioport.iop_pddir
53 # undef STATUS_LED_ODR
54 # define STATUS_LED_DAT im_ioport.iop_pddat
55
56 # define STATUS_LED_ACTIVE 1 /* LED on for bit == 1 */
57
58 /***** Someone else defines these *************************************/
59 #elif defined(STATUS_LED_PAR)
60 /*
61 * ADVICE: Define in your board configuration file rather than
62 * filling this file up with lots of custom board stuff.
63 */
64
65 #elif defined(CONFIG_LED_STATUS_BOARD_SPECIFIC)
66 /* led_id_t is unsigned long mask */
67 typedef unsigned long led_id_t;
68
69 extern void __led_toggle (led_id_t mask);
70 extern void __led_init (led_id_t mask, int state);
71 extern void __led_set (led_id_t mask, int state);
72 void __led_blink(led_id_t mask, int freq);
73 #else
74 # error Status LED configuration missing
75 #endif
76 /************************************************************************/
77
78 #ifndef CONFIG_LED_STATUS_BOARD_SPECIFIC
79 # include <asm/status_led.h>
80 #endif
81
82 #else
83
status_led_init(void)84 static inline void status_led_init(void) { }
status_led_set(int led,int state)85 static inline void status_led_set(int led, int state) { }
status_led_boot_blink(void)86 static inline void status_led_boot_blink(void) { }
87
88 #endif /* CONFIG_LED_STATUS */
89
90 /*
91 * Coloured LEDs API
92 */
93 #ifndef __ASSEMBLY__
94 void coloured_LED_init(void);
95 void red_led_on(void);
96 void red_led_off(void);
97 void green_led_on(void);
98 void green_led_off(void);
99 void yellow_led_on(void);
100 void yellow_led_off(void);
101 void blue_led_on(void);
102 void blue_led_off(void);
103 #else
104 .extern LED_init
105 .extern red_led_on
106 .extern red_led_off
107 .extern yellow_led_on
108 .extern yellow_led_off
109 .extern green_led_on
110 .extern green_led_off
111 .extern blue_led_on
112 .extern blue_led_off
113 #endif
114
115 #endif /* _STATUS_LED_H_ */
116