led.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef __LED_H
  8. #define __LED_H
  9. /**
  10. * struct led_uclass_plat - Platform data the uclass stores about each device
  11. *
  12. * @label: LED label
  13. */
  14. struct led_uclass_plat {
  15. const char *label;
  16. };
  17. struct led_ops {
  18. /**
  19. * set_on() - set the state of an LED
  20. *
  21. * @dev: LED device to change
  22. * @on: 1 to turn the LED on, 0 to turn it off
  23. * @return 0 if OK, -ve on error
  24. */
  25. int (*set_on)(struct udevice *dev, int on);
  26. };
  27. #define led_get_ops(dev) ((struct led_ops *)(dev)->driver->ops)
  28. /**
  29. * led_get_by_label() - Find an LED device by label
  30. *
  31. * @label: LED label to look up
  32. * @devp: Returns the associated device, if found
  33. * @return 0 if found, -ENODEV if not found, other -ve on error
  34. */
  35. int led_get_by_label(const char *label, struct udevice **devp);
  36. /**
  37. * led_set_on() - set the state of an LED
  38. *
  39. * @dev: LED device to change
  40. * @on: 1 to turn the LED on, 0 to turn it off
  41. * @return 0 if OK, -ve on error
  42. */
  43. int led_set_on(struct udevice *dev, int on);
  44. #endif