Re: [PATCH v2 2/7] gpio: regmap: Add configurable dir/value order

From: Andy Shevchenko
Date: Tue May 18 2021 - 06:39:50 EST


+Matti

On Tue, May 18, 2021 at 11:39 AM Michael Walle <michael@xxxxxxxx> wrote:
> Am 2021-05-17 21:28, schrieb Sander Vanheule:

...

> Instead of adding a new one, we can also just check no_set_on_input
> in gpio_regmap_direction_output(), which I'd prefer.

+! here.

> static int gpio_regmap_direction_output(struct gpio_chip *chip,
> unsigned int offset, int value)
> {
> struct gpio_regmap *gpio = gpiochip_get_data(chip);
> int ret;
>
> if (gpio->no_set_on_input) {
> /* some smart comment here, also mention gliches */
> ret = gpio_regmap_set_direction(chip, offset, true);
> gpio_regmap_set(chip, offset, value);
> } else {
> gpio_regmap_set(chip, offset, value);
> ret = gpio_regmap_set_direction(chip, offset, true);
> }
>
> return ret;
> }

...

> > + * @no_set_on_input: Set if output value can only be set when the
> > direction
> > + * is configured as output.
>
> set_direction_first ?

Perhaps we need to establish rather something like

/* Broken hardware can't set value on input pin, we have to set it to
output first */
#define GPIO_REGMAP_QUIRK_... BIT(0)

unsigned int quirks;

?

--
With Best Regards,
Andy Shevchenko