/src/barebox/include/led.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | | #ifndef __LED_H |
3 | | #define __LED_H |
4 | | |
5 | | #include <linux/list.h> |
6 | | |
7 | | #include <errno.h> |
8 | | #include <of.h> |
9 | | |
10 | | struct led { |
11 | | void (*set)(struct led *, unsigned int value); |
12 | | int max_value; |
13 | | const char *name; |
14 | | int num; |
15 | | struct list_head list; |
16 | | |
17 | | int blink; |
18 | | int flash; |
19 | | unsigned int *blink_states; |
20 | | int blink_nr_states; |
21 | | int blink_next_state; |
22 | | uint64_t blink_next_event; |
23 | | }; |
24 | | |
25 | | struct led *led_by_number(int no); |
26 | | struct led *led_by_name(const char *name); |
27 | | struct led *led_by_name_or_number(const char *str); |
28 | | |
29 | | static inline int led_get_number(struct led *led) |
30 | 0 | { |
31 | 0 | return led->num; |
32 | 0 | } Unexecuted instantiation: startup.c:led_get_number Unexecuted instantiation: misc.c:led_get_number Unexecuted instantiation: state_variables.c:led_get_number Unexecuted instantiation: parser.c:led_get_number Unexecuted instantiation: barebox.c:led_get_number Unexecuted instantiation: boot.c:led_get_number Unexecuted instantiation: fastboot.c:led_get_number Unexecuted instantiation: core.c:led_get_number Unexecuted instantiation: led-gpio.c:led_get_number Unexecuted instantiation: led-triggers.c:led_get_number Unexecuted instantiation: of_net.c:led_get_number Unexecuted instantiation: loads.c:led_get_number Unexecuted instantiation: bfetch.c:led_get_number Unexecuted instantiation: led.c:led_get_number Unexecuted instantiation: trigger.c:led_get_number Unexecuted instantiation: tftp.c:led_get_number Unexecuted instantiation: dhcp.c:led_get_number Unexecuted instantiation: ip-route-get.c:led_get_number Unexecuted instantiation: host.c:led_get_number Unexecuted instantiation: parameter.c:led_get_number Unexecuted instantiation: lib.c:led_get_number Unexecuted instantiation: eth.c:led_get_number Unexecuted instantiation: skbuff.c:led_get_number Unexecuted instantiation: net.c:led_get_number Unexecuted instantiation: sntp.c:led_get_number Unexecuted instantiation: ping.c:led_get_number Unexecuted instantiation: dns.c:led_get_number Unexecuted instantiation: ifup.c:led_get_number Unexecuted instantiation: nfs.c:led_get_number |
33 | | |
34 | | int led_set_num(int num, unsigned int value); |
35 | | int led_set(struct led *led, unsigned int value); |
36 | | int led_blink(struct led *led, unsigned int on_ms, unsigned int off_ms); |
37 | | int led_blink_pattern(struct led *led, const unsigned int *pattern, |
38 | | unsigned int pattern_len); |
39 | | int led_flash(struct led *led, unsigned int duration_ms); |
40 | | int led_register(struct led *led); |
41 | | void led_unregister(struct led *led); |
42 | | void led_unregister(struct led *led); |
43 | | |
44 | | /* LED trigger support */ |
45 | | enum led_trigger { |
46 | | LED_TRIGGER_PANIC, |
47 | | LED_TRIGGER_HEARTBEAT, |
48 | | LED_TRIGGER_NET_RX, |
49 | | LED_TRIGGER_NET_TX, |
50 | | LED_TRIGGER_NET_TXRX, |
51 | | LED_TRIGGER_DEFAULT_ON, |
52 | | LED_TRIGGER_MAX, |
53 | | LED_TRIGGER_INVALID = LED_TRIGGER_MAX, |
54 | | }; |
55 | | |
56 | | enum trigger_type { |
57 | | TRIGGER_ENABLE, |
58 | | TRIGGER_DISABLE, |
59 | | TRIGGER_FLASH, |
60 | | }; |
61 | | |
62 | | #ifdef CONFIG_LED_TRIGGERS |
63 | | int led_set_trigger(enum led_trigger trigger, struct led *led); |
64 | | void led_trigger_disable(struct led *led); |
65 | | void led_trigger(enum led_trigger trigger, enum trigger_type); |
66 | | #else |
67 | | static inline int led_set_trigger(enum led_trigger trigger, struct led *led) |
68 | | { |
69 | | return 0; |
70 | | } |
71 | | |
72 | | static inline void led_trigger(enum led_trigger trigger, enum trigger_type type) |
73 | | { |
74 | | } |
75 | | #endif |
76 | | |
77 | | void led_triggers_show_info(void); |
78 | | const char *trigger_name(enum led_trigger trigger); |
79 | | enum led_trigger trigger_by_name(const char *name); |
80 | | |
81 | | void led_of_parse_trigger(struct led *led, struct device_node *np); |
82 | | |
83 | | /* gpio LED support */ |
84 | | struct gpio_led { |
85 | | int gpio; |
86 | | bool active_low; |
87 | | struct led led; |
88 | | }; |
89 | | |
90 | | struct gpio_bicolor_led { |
91 | | int gpio_c0, gpio_c1; |
92 | | bool active_low; |
93 | | struct led led; |
94 | | }; |
95 | | |
96 | | struct gpio_rgb_led { |
97 | | int gpio_r, gpio_g, gpio_b; |
98 | | bool active_low; |
99 | | struct led led; |
100 | | }; |
101 | | |
102 | | #ifdef CONFIG_LED_GPIO |
103 | | int led_gpio_register(struct gpio_led *led); |
104 | | void led_gpio_unregister(struct gpio_led *led); |
105 | | #else |
106 | | static inline int led_gpio_register(struct gpio_led *led) |
107 | | { |
108 | | return -ENOSYS; |
109 | | } |
110 | | |
111 | | static inline void led_gpio_unregister(struct gpio_led *led) |
112 | | { |
113 | | } |
114 | | #endif |
115 | | |
116 | | #ifdef CONFIG_LED_GPIO_BICOLOR |
117 | | int led_gpio_bicolor_register(struct gpio_bicolor_led *led); |
118 | | void led_gpio_bicolor_unregister(struct gpio_bicolor_led *led); |
119 | | #else |
120 | | static inline int led_gpio_bicolor_register(struct gpio_bicolor_led *led) |
121 | | { |
122 | | return -ENOSYS; |
123 | | } |
124 | | |
125 | | static inline void led_gpio_bicolor_unregister(struct gpio_bicolor_led *led) |
126 | | { |
127 | | } |
128 | | #endif |
129 | | |
130 | | #ifdef CONFIG_LED_GPIO_RGB |
131 | | int led_gpio_rgb_register(struct gpio_rgb_led *led); |
132 | | void led_gpio_rgb_unregister(struct gpio_rgb_led *led); |
133 | | #else |
134 | | static inline int led_gpio_rgb_register(struct gpio_rgb_led *led) |
135 | | { |
136 | | return -ENOSYS; |
137 | | } |
138 | | |
139 | | static inline void led_gpio_rgb_unregister(struct gpio_rgb_led *led) |
140 | | { |
141 | | } |
142 | | #endif |
143 | | |
144 | | #endif /* __LED_H */ |