2015-06-23 15:38:45 -06:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Google, Inc
|
|
|
|
* Written by Simon Glass <sjg@chromium.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LED_H
|
|
|
|
#define __LED_H
|
|
|
|
|
|
|
|
/**
|
2017-04-10 11:34:53 -06:00
|
|
|
* struct led_uc_plat - Platform data the uclass stores about each device
|
2015-06-23 15:38:45 -06:00
|
|
|
*
|
|
|
|
* @label: LED label
|
|
|
|
*/
|
2017-04-10 11:34:53 -06:00
|
|
|
struct led_uc_plat {
|
2015-06-23 15:38:45 -06:00
|
|
|
const char *label;
|
|
|
|
};
|
|
|
|
|
2017-04-10 11:34:54 -06:00
|
|
|
enum led_state_t {
|
|
|
|
LEDST_OFF = 0,
|
|
|
|
LEDST_ON = 1,
|
|
|
|
|
|
|
|
LEDST_COUNT,
|
|
|
|
};
|
|
|
|
|
2015-06-23 15:38:45 -06:00
|
|
|
struct led_ops {
|
|
|
|
/**
|
2017-04-10 11:34:54 -06:00
|
|
|
* set_state() - set the state of an LED
|
2015-06-23 15:38:45 -06:00
|
|
|
*
|
|
|
|
* @dev: LED device to change
|
2017-04-10 11:34:54 -06:00
|
|
|
* @state: LED state to set
|
2015-06-23 15:38:45 -06:00
|
|
|
* @return 0 if OK, -ve on error
|
|
|
|
*/
|
2017-04-10 11:34:54 -06:00
|
|
|
int (*set_state)(struct udevice *dev, enum led_state_t state);
|
2015-06-23 15:38:45 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
#define led_get_ops(dev) ((struct led_ops *)(dev)->driver->ops)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* led_get_by_label() - Find an LED device by label
|
|
|
|
*
|
|
|
|
* @label: LED label to look up
|
|
|
|
* @devp: Returns the associated device, if found
|
2015-07-06 12:54:33 -06:00
|
|
|
* @return 0 if found, -ENODEV if not found, other -ve on error
|
2015-06-23 15:38:45 -06:00
|
|
|
*/
|
|
|
|
int led_get_by_label(const char *label, struct udevice **devp);
|
|
|
|
|
|
|
|
/**
|
2017-04-10 11:34:54 -06:00
|
|
|
* led_set_state() - set the state of an LED
|
2015-06-23 15:38:45 -06:00
|
|
|
*
|
|
|
|
* @dev: LED device to change
|
2017-04-10 11:34:54 -06:00
|
|
|
* @state: LED state to set
|
2015-06-23 15:38:45 -06:00
|
|
|
* @return 0 if OK, -ve on error
|
|
|
|
*/
|
2017-04-10 11:34:54 -06:00
|
|
|
int led_set_state(struct udevice *dev, enum led_state_t state);
|
2015-06-23 15:38:45 -06:00
|
|
|
|
|
|
|
#endif
|