Re: [PATCH v7 08/15] gpiolib: regmap: add write_data_after_dir quirk

From: Linus Walleij

Date: Sun Sep 20 2026 - 18:03:20 EST


Hi Long,

thanks for your patch!

On Tue, Sep 15, 2026 at 1:15 PM Long Zhao via B4 Relay
<devnull+longzhao.ambarella.com@xxxxxxxxxx> wrote:


> From: Long Zhao <longzhao@xxxxxxxxxxxxx>
>
> Some controllers ignore data-register writes while a line is still an
> input. Optionally write the output value again after switching the
> direction, matching the existing PL061 behaviour.
>
> Signed-off-by: Long Zhao <longzhao@xxxxxxxxxxxxx>

OK I see.

(...)


> @@ -271,9 +272,22 @@ static int gpio_regmap_direction_output(struct gpio_chip *chip,
> return ret;
> }
>
> - gpio_regmap_set(chip, offset, value);
> + ret = gpio_regmap_set(chip, offset, value);
> + if (ret)
> + return ret;

if (!gpio->write_data_after_dir) {
ret = gpio_regmap_set(chip, offset, value);
if (ret)
return ret;
}

There is no point in doing something you know will not
work.

> + ret = gpio_regmap_set_direction(chip, offset, true);
> + if (ret)
> + return ret;
>
> - return gpio_regmap_set_direction(chip, offset, true);
> + /*
> + * gpio value is set again, because pl061 doesn't allow to set value of
> + * a gpio pin before configuring it in OUT mode.
> + */
> + if (gpio->write_data_after_dir)
> + return gpio_regmap_set(chip, offset, value);

Then there is Andy's comment as well.

The rest looks good.

Yours,
Linus Walleij