1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
13 * struct led_uc_plat - Platform data the uclass stores about each device
22 * struct led_uc_priv - Private data the uclass stores about each device
24 * @period_ms: Flash period in milliseconds
34 #ifdef CONFIG_LED_BLINK
43 * set_state() - set the state of an LED
45 * @dev: LED device to change
46 * @state: LED state to set
47 * @return 0 if OK, -ve on error
49 int (*set_state)(struct udevice *dev, enum led_state_t state);
52 * led_get_state() - get the state of an LED
54 * @dev: LED device to change
55 * @return LED state led_state_t, or -ve on error
57 enum led_state_t (*get_state)(struct udevice *dev);
59 #ifdef CONFIG_LED_BLINK
61 * led_set_period() - set the blink period of an LED
63 * Thie records the period if supported, or returns -ENOSYS if not.
64 * To start the LED blinking, use set_state().
66 * @dev: LED device to change
67 * @period_ms: LED blink period in milliseconds
68 * @return 0 if OK, -ve on error
70 int (*set_period)(struct udevice *dev, int period_ms);
74 #define led_get_ops(dev) ((struct led_ops *)(dev)->driver->ops)
77 * led_get_by_label() - Find an LED device by label
79 * @label: LED label to look up
80 * @devp: Returns the associated device, if found
81 * @return 0 if found, -ENODEV if not found, other -ve on error
83 int led_get_by_label(const char *label, struct udevice **devp);
86 * led_set_state() - set the state of an LED
88 * @dev: LED device to change
89 * @state: LED state to set
90 * @return 0 if OK, -ve on error
92 int led_set_state(struct udevice *dev, enum led_state_t state);
95 * led_get_state() - get the state of an LED
97 * @dev: LED device to change
98 * @return LED state led_state_t, or -ve on error
100 enum led_state_t led_get_state(struct udevice *dev);
103 * led_set_period() - set the blink period of an LED
105 * @dev: LED device to change
106 * @period_ms: LED blink period in milliseconds
107 * @return 0 if OK, -ve on error
109 int led_set_period(struct udevice *dev, int period_ms);
112 * led_default_state() - set the default state for all the LED
114 * This enables all leds which have default state.
115 * see Documentation/devicetree/bindings/leds/common.txt
118 int led_default_state(void);