1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
11 * struct led_uc_plat - Platform data the uclass stores about each device
20 * struct led_uc_priv - Private data the uclass stores about each device
22 * @period_ms: Flash period in milliseconds
32 #ifdef CONFIG_LED_BLINK
41 * set_state() - set the state of an LED
43 * @dev: LED device to change
44 * @state: LED state to set
45 * @return 0 if OK, -ve on error
47 int (*set_state)(struct udevice *dev, enum led_state_t state);
50 * led_get_state() - get the state of an LED
52 * @dev: LED device to change
53 * @return LED state led_state_t, or -ve on error
55 enum led_state_t (*get_state)(struct udevice *dev);
57 #ifdef CONFIG_LED_BLINK
59 * led_set_period() - set the blink period of an LED
61 * Thie records the period if supported, or returns -ENOSYS if not.
62 * To start the LED blinking, use set_state().
64 * @dev: LED device to change
65 * @period_ms: LED blink period in milliseconds
66 * @return 0 if OK, -ve on error
68 int (*set_period)(struct udevice *dev, int period_ms);
72 #define led_get_ops(dev) ((struct led_ops *)(dev)->driver->ops)
75 * led_get_by_label() - Find an LED device by label
77 * @label: LED label to look up
78 * @devp: Returns the associated device, if found
79 * @return 0 if found, -ENODEV if not found, other -ve on error
81 int led_get_by_label(const char *label, struct udevice **devp);
84 * led_set_state() - set the state of an LED
86 * @dev: LED device to change
87 * @state: LED state to set
88 * @return 0 if OK, -ve on error
90 int led_set_state(struct udevice *dev, enum led_state_t state);
93 * led_get_state() - get the state of an LED
95 * @dev: LED device to change
96 * @return LED state led_state_t, or -ve on error
98 enum led_state_t led_get_state(struct udevice *dev);
101 * led_set_period() - set the blink period of an LED
103 * @dev: LED device to change
104 * @period_ms: LED blink period in milliseconds
105 * @return 0 if OK, -ve on error
107 int led_set_period(struct udevice *dev, int period_ms);
110 * led_default_state() - set the default state for all the LED
112 * This enables all leds which have default state.
113 * see Documentation/devicetree/bindings/leds/common.txt
116 int led_default_state(void);