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_uc_plat - Platform data the uclass stores about each device 13 * 14 * @label: LED label 15 */ 16 struct led_uc_plat { 17 const char *label; 18 }; 19 20 enum led_state_t { 21 LEDST_OFF = 0, 22 LEDST_ON = 1, 23 24 LEDST_COUNT, 25 }; 26 27 struct led_ops { 28 /** 29 * set_state() - set the state of an LED 30 * 31 * @dev: LED device to change 32 * @state: LED state to set 33 * @return 0 if OK, -ve on error 34 */ 35 int (*set_state)(struct udevice *dev, enum led_state_t state); 36 }; 37 38 #define led_get_ops(dev) ((struct led_ops *)(dev)->driver->ops) 39 40 /** 41 * led_get_by_label() - Find an LED device by label 42 * 43 * @label: LED label to look up 44 * @devp: Returns the associated device, if found 45 * @return 0 if found, -ENODEV if not found, other -ve on error 46 */ 47 int led_get_by_label(const char *label, struct udevice **devp); 48 49 /** 50 * led_set_state() - set the state of an LED 51 * 52 * @dev: LED device to change 53 * @state: LED state to set 54 * @return 0 if OK, -ve on error 55 */ 56 int led_set_state(struct udevice *dev, enum led_state_t state); 57 58 #endif 59