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

zl020895 zl020895 at 163.com
Sun Sep 20 20:52:33 PDT 2026


Hi Linus,

Thanks for the review. v8 will skip the pre-direction gpio_regmap_set() when
write_data_after_dir is set. The gpio_regmap_set() returns stay
ignored, per Andy.

0014: added your Reviewed-by.

Best regards,
Long Zhao

At 2026-09-21 06:02:48, "Linus Walleij" <linusw at kernel.org> wrote:
>Hi Long,
>
>thanks for your patch!
>
>On Tue, Sep 15, 2026 at 1:15 PM Long Zhao via B4 Relay
><devnull+longzhao.ambarella.com at kernel.org> wrote:
>
>
>> From: Long Zhao <longzhao at ambarella.com>
>>
>> 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 at ambarella.com>
>
>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


More information about the linux-arm-kernel mailing list