xref: /openbmc/u-boot/include/led.h (revision be059e88)
1 /*
2  * Copyright (c) 2015 Google, Inc
3  * Written by Simon Glass <sjg@chromium.org>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #ifndef __LED_H
9 #define __LED_H
10 
11 /**
12  * struct led_uclass_plat - Platform data the uclass stores about each device
13  *
14  * @label:	LED label
15  */
16 struct led_uclass_plat {
17 	const char *label;
18 };
19 
20 struct led_ops {
21 	/**
22 	 * set_on() - set the state of an LED
23 	 *
24 	 * @dev:	LED device to change
25 	 * @on:		1 to turn the LED on, 0 to turn it off
26 	 * @return 0 if OK, -ve on error
27 	 */
28 	int (*set_on)(struct udevice *dev, int on);
29 };
30 
31 #define led_get_ops(dev)	((struct led_ops *)(dev)->driver->ops)
32 
33 /**
34  * led_get_by_label() - Find an LED device by label
35  *
36  * @label:	LED label to look up
37  * @devp:	Returns the associated device, if found
38  * @return 0 if found, -ENODEV if not found, other -ve on error
39  */
40 int led_get_by_label(const char *label, struct udevice **devp);
41 
42 /**
43  * led_set_on() - set the state of an LED
44  *
45  * @dev:	LED device to change
46  * @on:		1 to turn the LED on, 0 to turn it off
47  * @return 0 if OK, -ve on error
48  */
49 int led_set_on(struct udevice *dev, int on);
50 
51 #endif
52