Re: [PATCH v2 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
Matti Vaittinen <[email protected]> Mon, 10 Aug 2026 08:47:38 +0300
| Newsgroups | org.kernel.vger.linux-clk,dev.linux.lists.mfd,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel,org.kernel.vger.linux-rtc |
|---|---|
| Message-ID | <[email protected]> |
On 07/08/2026 23:29, Linus Walleij wrote: > 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. Allright, I'll take a look at the gpio-regmap again. Thanks for letting me know ... > > 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? ... and thanks for going the extra mile and giving me this pointer. Helps a lot! :) I wish all reviewers had the time to give this specific suggestions - although, I understand this is not always feasible with the amount of reviews/tasks to handle. Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~