From: Ziping Chen <techping.c...@gmail.com> The status of a GPIO-connected LED can be read back by reading the GPO value.
Add the support for get_status function in led_gpio driver. Signed-off-by: Ziping Chen <techping.c...@gmail.com> --- drivers/led/led_gpio.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c index 5b11990..b64721e 100644 --- a/drivers/led/led_gpio.c +++ b/drivers/led/led_gpio.c @@ -28,6 +28,16 @@ static int gpio_led_set_on(struct udevice *dev, int on) return dm_gpio_set_value(&priv->gpio, on); } +static int gpio_led_get_status(struct udevice *dev) +{ + struct led_gpio_priv *priv = dev_get_priv(dev); + + if (!dm_gpio_is_valid(&priv->gpio)) + return -EREMOTEIO; + + return dm_gpio_get_value(&priv->gpio); +} + static int led_gpio_probe(struct udevice *dev) { struct led_uclass_plat *uc_plat = dev_get_uclass_platdata(dev); @@ -88,6 +98,7 @@ static int led_gpio_bind(struct udevice *parent) static const struct led_ops gpio_led_ops = { .set_on = gpio_led_set_on, + .get_status = gpio_led_get_status, }; static const struct udevice_id led_gpio_ids[] = { -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot