Re: [PATCH v2 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
Linus Walleij <[email protected]> Fri, 7 Aug 2026 22:29:40 +0200
| Newsgroups | dev.linux.lists.mfd,org.kernel.vger.linux-clk,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel,org.kernel.vger.linux-rtc |
|---|---|
| Message-ID | <CAD++jLmatJFfqhNWfgx=qUW2fEwuatxmJR7NyJLAv45LfLHZnw@mail.gmail.com> |
Hi Matti, thanks for your patch! On Tue, Aug 4, 2026 at 12:23 PM Matti Vaittinen <[email protected]> wrote: > +static int bd73800gpio_get(struct gpio_chip *chip, unsigned int offset) > +{ > + struct bd73800_gpio *data = gpiochip_get_data(chip); > + struct bd73800_gpio_pin_cfg *pin = &data->pin[offset]; > + int ret, val; > + > + /* Only pins configured as GPI via OTP can have their status read */ > + if (pin->state != BD73800_PIN_GPI) { > + dev_dbg(data->dev, "pin %d (%x) not input. State %d\n", offset, > + pin->mask, pin->state); > + return -EINVAL; > + } > + > + ret = regmap_read(data->regmap, BD73800_REG_INT_5_SRC, &val); > + if (ret) > + return ret; > + > + return val & pin->mask; > +} > + > +static int bd73800gpo_set(struct gpio_chip *chip, unsigned int offset, > + int value) > +{ > + struct bd73800_gpio *data = gpiochip_get_data(chip); > + struct bd73800_gpio_pin_cfg *pin = &data->pin[offset]; > + > + if (pin->state != BD73800_PIN_GPO) { > + dev_dbg(data->dev, "pin %d (%d) not output. State %d\n", > + offset, pin->mask, pin->state); > + > + return -EINVAL; > + } > + > + if (value) > + return regmap_set_bits(data->regmap, BD73800_REG_GPO_OUT, > + pin->mask); > + > + return regmap_clear_bits(data->regmap, BD73800_REG_GPO_OUT, pin->mask); > +} These can probably be handled by the latest version of gpio-regmap helpers (the version in linux-next). We now support both input-only and output-only in gpio-regmap. Latest <linux/gpio/regmap.h>: * @fixed_direction_mask: * (Optional) Bitmap representing the GPIO lines that * make use of the @fixed_direction_output list to * enforce direction of the GPIO. If this is NULL * and @fixed_direction_output is defined, ALL GPIOs * are assumed to be fixed direction (out or in). * @fixed_direction_output: * (Optional) Bitmap representing the fixed direction of * the GPIO lines. Useful when there are GPIO lines with a * fixed direction mixed together in the same register. It seems you can set up the fixed_direction_output mask from OTP and just use the library, right? Yours, Linus Walleij