Re: [PATCH v3 06/10] leds: pca995x: Add support for reset GPIO
From: Nora Schiffer
Date: Tue Sep 29 2026 - 05:30:41 EST
On Tue, 2026-09-29 at 10:14 +0100, Lee Jones wrote:
> On Tue, 22 Sep 2026, Nora Schiffer wrote:
>
> > The PCA9952/9955B/9956B have a reset pin. Use it to reset the LED driver
> > if provided in the Device Tree.
> >
> > Signed-off-by: Nora Schiffer <nora.schiffer@xxxxxxxxxxxxxxx>
> > ---
> > drivers/leds/leds-pca995x.c | 13 +++++++++++++
> > 1 file changed, 13 insertions(+)
> >
> > diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c
> > index e6122b33451ed..b528b2b4990a7 100644
> > --- a/drivers/leds/leds-pca995x.c
> > +++ b/drivers/leds/leds-pca995x.c
> > @@ -8,6 +8,8 @@
> > * Copyright 2023 Marek Vasut
> > */
> >
> > +#include <linux/delay.h>
> > +#include <linux/gpio/consumer.h>
> > #include <linux/i2c.h>
> > #include <linux/leds.h>
> > #include <linux/module.h>
> > @@ -121,6 +123,7 @@ static int pca995x_probe(struct i2c_client *client)
> > struct fwnode_handle *led_fwnodes[PCA995X_MAX_OUTPUTS] = { 0 };
> > struct device *dev = &client->dev;
> > const struct pca995x_chipdef *chipdef;
> > + struct gpio_desc *reset_gpio;
> > struct pca995x_chip *chip;
> > struct pca995x_led *led;
> > int i, reg, ret;
> > @@ -130,6 +133,16 @@ static int pca995x_probe(struct i2c_client *client)
> > if (!dev_fwnode(dev))
> > return -ENODEV;
> >
> > + reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> > + if (IS_ERR(reset_gpio))
> > + return dev_err_probe(dev, PTR_ERR(reset_gpio),
> > + "failed to request reset GPIO\n");
> > + if (reset_gpio) {
> > + udelay(3);
>
> It's strange to see delays _before_ actions.
devm_gpiod_get*() with GPIOD_OUT_HIGH asserts the reset GPIO if it was in a
different state before. We keep the chip in reset for 3us, de-assert the reset,
and then wait for ~1.5ms until the chip is back up. This is a common pattern
seen in various drivers.
>
> What are you delaying for exactly?
>
> > + gpiod_set_value_cansleep(reset_gpio, 0);
> > + usleep_range(1500, 1600);
> > + }
> > +
> > chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
> > if (!chip)
> > return -ENOMEM;
> > --
> > TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
> > Amtsgericht München, HRB 105018
> > Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
> > https://www.tq-group.com/
> >
>
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/