Re: [PATCH v2 2/2] leds: rgb: lp5860: add enable-gpio

From: Lee Jones

Date: Thu Mar 19 2026 - 11:07:05 EST


On Tue, 10 Mar 2026, Steffen Trumtrar wrote:

> The VIO_EN pin can either be connected with VIO power supply or GPIO.
> Get the GPIO from DT if provided and set it on chip enable and disable.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar@xxxxxxxxxxxxxx>
> ---
> drivers/leds/rgb/leds-lp5860-core.c | 10 ++++++++++
> include/linux/platform_data/leds-lp5860.h | 1 +
> 2 files changed, 11 insertions(+)
>
> diff --git a/drivers/leds/rgb/leds-lp5860-core.c b/drivers/leds/rgb/leds-lp5860-core.c
> index 28b4d86e11f1a..1f349aa53f7a9 100644
> --- a/drivers/leds/rgb/leds-lp5860-core.c
> +++ b/drivers/leds/rgb/leds-lp5860-core.c
> @@ -61,6 +61,9 @@ static int lp5860_set_mc_brightness(struct led_classdev *cdev,
>
> static int lp5860_chip_enable_toggle(struct lp5860 *led, int enable)
> {
> + if (led->enable_gpiod)

gpiod_direction_output() validates this for you.

> + gpiod_direction_output(led->enable_gpiod, enable);
> +
> return regmap_write(led->regmap, LP5860_REG_CHIP_EN, enable);
> }
>
> @@ -170,6 +173,13 @@ int lp5860_device_init(struct device *dev)
> struct lp5860 *lp = dev_get_drvdata(dev);
> int ret;
>
> + lp->enable_gpiod = devm_gpiod_get_optional(lp->dev, "enable", GPIOD_ASIS);
> + if (IS_ERR(lp->enable_gpiod))
> + return PTR_ERR(lp->enable_gpiod);
> +
> + if (lp->enable_gpiod)

gpiod_set_consumer_name() validates this for you.

> + gpiod_set_consumer_name(lp->enable_gpiod, "LP5860 VIO enable");
> +
> ret = lp5860_chip_enable_toggle(lp, LP5860_CHIP_ENABLE);
> if (ret)
> return ret;
> diff --git a/include/linux/platform_data/leds-lp5860.h b/include/linux/platform_data/leds-lp5860.h
> index 7bc69a7a550dd..7258d0674ce59 100644
> --- a/include/linux/platform_data/leds-lp5860.h
> +++ b/include/linux/platform_data/leds-lp5860.h
> @@ -257,6 +257,7 @@ struct lp5860_led {
> struct lp5860 {
> struct device *dev;
> struct regmap *regmap;
> + struct gpio_desc *enable_gpiod;
> unsigned int leds_count;
>
> DECLARE_FLEX_ARRAY(struct lp5860_led, leds);
>
> --
> 2.51.0
>
>

--
Lee Jones [李琼斯]