All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Linus Walleij <linusw@kernel.org>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	Matti Vaittinen <matti.vaittinen@linux.dev>,
	Lee Jones <lee@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <bmasney@redhat.com>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	mfd@lists.linux.dev, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org
Subject: Re: [PATCH v2 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
Date: Thu, 13 Aug 2026 11:34:17 +0300	[thread overview]
Message-ID: <f5c241a2-00a8-4a32-bad5-3c89fb204b25@gmail.com> (raw)
In-Reply-To: <CAD++jLmatJFfqhNWfgx=qUW2fEwuatxmJR7NyJLAv45LfLHZnw@mail.gmail.com>

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
> <matti.vaittinen@linux.dev> 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?

The BD73800 uses different registers for 'out' and 'in'. So there aren't 
really "GPIO lines with a fixed direction mixed together in the same 
register".

I, however, see some good stuff being in the linux-next! Finally a bit 
of flexibility in a form of callbacks a driver can register is getting 
in. So I am somewhat hopeful the usability of gpio-regmap will finally 
increase.

I think the BD73800 can indeed use the gpio-regmap, by keeping the pin 
direction information in private data and adding a custom xlate, which 
errors out if get is requested for output pin, or set is requested for 
input. I am not sure how much of an improvement it is compared to the 
patch v2, but I'll give it a shot :) I believe the new -rc1 isn't that 
far away, and hopefully the gpio-regmap -stuff from the next will be in 
it together with the regulator stuff bindings depended.

Thanks again for the pointer!

Yours,
	-- Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~

  parent reply	other threads:[~2026-08-13  8:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 10:19 [PATCH v2 00/10] Support ROHM BD73800 Matti Vaittinen
2026-08-04 10:20 ` [PATCH v2 01/10] dt-bindings: mfd: common ROHM PMIC properties Matti Vaittinen
2026-08-07 20:23   ` Linus Walleij
2026-08-10  5:41     ` Matti Vaittinen
2026-08-12  1:42   ` Rob Herring (Arm)
2026-08-04 10:20 ` [PATCH v2 02/10] dt-bindings: rohm,bd*: Ref common ROHM bindings Matti Vaittinen
2026-08-12  1:43   ` Rob Herring (Arm)
2026-08-04 10:21 ` [PATCH v2 03/10] dt-bindings: regulator: ROHM BD73800 regulators Matti Vaittinen
2026-08-04 12:31   ` Rob Herring (Arm)
2026-08-04 10:21 ` [PATCH v2 04/10] dt-bindings: mfd: ROHM BD73800 PMIC Matti Vaittinen
2026-08-04 12:31   ` Rob Herring (Arm)
2026-08-04 10:21 ` [PATCH v2 05/10] mfd: Support for ROHM BD73800 PMIC core Matti Vaittinen
2026-08-13 10:59   ` Lee Jones
2026-08-04 10:22 ` [PATCH v2 06/10] rtc: bd70528: Support RTC on ROHM BD73800 Matti Vaittinen
2026-08-04 10:22 ` [PATCH v2 07/10] regulator: bd71828: Support " Matti Vaittinen
2026-08-04 16:56   ` Mark Brown
2026-08-04 10:23 ` [PATCH v2 08/10] clk: bd718x7: " Matti Vaittinen
2026-08-04 10:23 ` [PATCH v2 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs Matti Vaittinen
2026-08-07 20:29   ` Linus Walleij
2026-08-10  5:47     ` Matti Vaittinen
2026-08-13  8:34     ` Matti Vaittinen [this message]
2026-08-13 12:55       ` Matti Vaittinen
2026-08-04 10:23 ` [PATCH v2 10/10] MAINTAINERS: Add ROHM BD73800 PMIC files Matti Vaittinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5c241a2-00a8-4a32-bad5-3c89fb204b25@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bmasney@redhat.com \
    --cc=brgl@kernel.org \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=matti.vaittinen@linux.dev \
    --cc=mfd@lists.linux.dev \
    --cc=mturquette@baylibre.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.