blob: a856b3d9ff78312e042bd04e892bc6302aa32b5a [file] [log] [blame]
Simon Glasscce3aed2015-06-23 15:38:45 -06001/*
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/**
Simon Glassda01de92017-04-10 11:34:53 -060012 * struct led_uc_plat - Platform data the uclass stores about each device
Simon Glasscce3aed2015-06-23 15:38:45 -060013 *
14 * @label: LED label
15 */
Simon Glassda01de92017-04-10 11:34:53 -060016struct led_uc_plat {
Simon Glasscce3aed2015-06-23 15:38:45 -060017 const char *label;
18};
19
20struct led_ops {
21 /**
22 * set_on() - set the state of an LED
23 *
24 * @dev: LED device to change
25 * @on: 1 to turn the LED on, 0 to turn it off
26 * @return 0 if OK, -ve on error
27 */
28 int (*set_on)(struct udevice *dev, int on);
29};
30
31#define led_get_ops(dev) ((struct led_ops *)(dev)->driver->ops)
32
33/**
34 * led_get_by_label() - Find an LED device by label
35 *
36 * @label: LED label to look up
37 * @devp: Returns the associated device, if found
Simon Glassbf3ac8192015-07-06 12:54:33 -060038 * @return 0 if found, -ENODEV if not found, other -ve on error
Simon Glasscce3aed2015-06-23 15:38:45 -060039 */
40int led_get_by_label(const char *label, struct udevice **devp);
41
42/**
43 * led_set_on() - set the state of an LED
44 *
45 * @dev: LED device to change
46 * @on: 1 to turn the LED on, 0 to turn it off
47 * @return 0 if OK, -ve on error
48 */
49int led_set_on(struct udevice *dev, int on);
50
51#endif