summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-04-10 11:34:56 -0600
committerSimon Glass <sjg@chromium.org>2017-04-14 19:38:57 -0600
commit9413ad4f0def2e06a5042106a6e1650a1aa03a5a (patch)
treec5c98725d3892bdda04e907ec2500502f16435b2 /drivers
parent8f4b612333ee0381eedf767c1c005a830886df27 (diff)
downloadu-boot-9413ad4f0def2e06a5042106a6e1650a1aa03a5a.tar.gz
u-boot-9413ad4f0def2e06a5042106a6e1650a1aa03a5a.tar.bz2
u-boot-9413ad4f0def2e06a5042106a6e1650a1aa03a5a.zip
dm: led: Support toggling LEDs
Add support for toggling an LED into the uclass interface. This can be efficiently implemented by the driver. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ziping Chen <techping.chan@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/led/led_gpio.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
index 789d15600f..4106ecb679 100644
--- a/drivers/led/led_gpio.c
+++ b/drivers/led/led_gpio.c
@@ -21,6 +21,7 @@ struct led_gpio_priv {
static int gpio_led_set_state(struct udevice *dev, enum led_state_t state)
{
struct led_gpio_priv *priv = dev_get_priv(dev);
+ int ret;
if (!dm_gpio_is_valid(&priv->gpio))
return -EREMOTEIO;
@@ -28,6 +29,12 @@ static int gpio_led_set_state(struct udevice *dev, enum led_state_t state)
case LEDST_OFF:
case LEDST_ON:
break;
+ case LEDST_TOGGLE:
+ ret = dm_gpio_get_value(&priv->gpio);
+ if (ret < 0)
+ return ret;
+ state = !ret;
+ break;
default:
return -ENOSYS;
}