1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
16 #ifdef CONFIG_LED_BLINK
24 * struct led_uc_plat - Platform data the uclass stores about each device
27 * @default_state: LED default state
31 enum led_state_t default_state;
35 * struct led_uc_priv - Private data the uclass stores about each device
37 * @period_ms: Flash period in milliseconds
45 * set_state() - set the state of an LED
47 * @dev: LED device to change
48 * @state: LED state to set
49 * @return 0 if OK, -ve on error
51 int (*set_state)(struct udevice *dev, enum led_state_t state);
54 * led_get_state() - get the state of an LED
56 * @dev: LED device to change
57 * @return LED state led_state_t, or -ve on error
59 enum led_state_t (*get_state)(struct udevice *dev);
61 #ifdef CONFIG_LED_BLINK
63 * led_set_period() - set the blink period of an LED
65 * Thie records the period if supported, or returns -ENOSYS if not.
66 * To start the LED blinking, use set_state().
68 * @dev: LED device to change
69 * @period_ms: LED blink period in milliseconds
70 * @return 0 if OK, -ve on error
72 int (*set_period)(struct udevice *dev, int period_ms);
76 #define led_get_ops(dev) ((struct led_ops *)(dev)->driver->ops)
79 * led_get_by_label() - Find an LED device by label
81 * @label: LED label to look up
82 * @devp: Returns the associated device, if found
83 * Return: 0 if found, -ENODEV if not found, other -ve on error
85 int led_get_by_label(const char *label, struct udevice **devp);
88 * led_set_state() - set the state of an LED
90 * @dev: LED device to change
91 * @state: LED state to set
92 * Return: 0 if OK, -ve on error
94 int led_set_state(struct udevice *dev, enum led_state_t state);
97 * led_get_state() - get the state of an LED
99 * @dev: LED device to change
100 * Return: LED state led_state_t, or -ve on error
102 enum led_state_t led_get_state(struct udevice *dev);
105 * led_set_period() - set the blink period of an LED
107 * @dev: LED device to change
108 * @period_ms: LED blink period in milliseconds
109 * Return: 0 if OK, -ve on error
111 int led_set_period(struct udevice *dev, int period_ms);