Linux IIO development
 help / color / mirror / Atom feed
From: "Yu-Chun Lin [林祐君]" <eleanor.lin@realtek.com>
To: "Michael Walle" <mwalle@kernel.org>,
	"linusw@kernel.org" <linusw@kernel.org>,
	"andriy.shevchenko@intel.com" <andriy.shevchenko@intel.com>,
	"brgl@kernel.org" <brgl@kernel.org>,
	"TY_Chang[張子逸]" <tychang@realtek.com>,
	"wbg@kernel.org" <wbg@kernel.org>,
	"mathieu.dubois-briand@bootlin.com"
	<mathieu.dubois-briand@bootlin.com>,
	"nuno.sa@analog.com" <nuno.sa@analog.com>,
	"Michael.Hennerich@analog.com" <Michael.Hennerich@analog.com>,
	"jic23@kernel.org" <jic23@kernel.org>,
	"andy@kernel.org" <andy@kernel.org>,
	"u.kleine-koenig@baylibre.com" <u.kleine-koenig@baylibre.com>,
	"dakr@kernel.org" <dakr@kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"o-takashi@sakamocchi.jp" <o-takashi@sakamocchi.jp>
Cc: "dlechner@baylibre.com" <dlechner@baylibre.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux@analog.com" <linux@analog.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"CY_Huang[黃鉦晏]" <cy.huang@realtek.com>,
	"James Tai [戴志峰]" <james.tai@realtek.com>
Subject: RE: [PATCH v6 5/8] gpio: regmap: Add gpio_regmap_operation and value_xlate support
Date: Tue, 21 Jul 2026 10:34:01 +0000	[thread overview]
Message-ID: <5eca2915f98e4cb8ab182ccc01b0fa33@realtek.com> (raw)
In-Reply-To: <DK42BVHLGJV1.1TC0EG2OJA7ON@kernel.org>

Hi Michael,

> Hi
>
> Thanks! Looks very good, a few comments below.
>
> On Tue Jul 21, 2026 at 8:57 AM CEST, Yu-Chun Lin wrote:
>> Extend the reg_mask_xlate callback with an operation type parameter 
>> (enum gpio_regmap_operation) to allow drivers to return different 
>> register/mask combinations depending on the specific GPIO operation.
>>
>> In addition, introduce a new optional 'value_xlate' callback. This 
>> routine allows drivers to translate or modify the register value and 
>> mask immediately before a write operation. It is particularly useful 
>> for hardware that requires additional control bits, such as a 
>> write-enable bit, to be appended to the data dynamically.
>
> Please split that into two patches.
>

I will split the value_xlate and reg_mask_xlate changes into separate
patches.

>> Consequently, update all existing drivers utilizing the gpio-regmap 
>> framework (across drivers/gpio, drivers/iio, and drivers/pinctrl) to 
>> accommodate the new reg_mask_xlate function signature.
>>
>> Suggested-by: Linus Walleij <linusw@kernel.org>
>> Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>
>> ---
>> Changes in v6:
>> - Remove removed the hardcoded write-enable workarounds.
>> - Retain the necessary prototype updates in every driver using custom 
>> reg_mask_xlate
>> - Add value_xlate to dynamically adjust the register mask and value 
>> right before the actual register write operation.
>> ---
>>  drivers/gpio/gpio-104-idi-48.c        |  7 +--
>>  drivers/gpio/gpio-i8255.c             |  4 +-
>>  drivers/gpio/gpio-idio-16.c           |  6 +--
>>  drivers/gpio/gpio-max7360.c           |  1 +
>>  drivers/gpio/gpio-pcie-idio-24.c      |  6 +--
>>  drivers/gpio/gpio-regmap.c            | 62 ++++++++++++++++++++++-----
>>  drivers/iio/adc/ad7173.c              |  8 ++--
>>  drivers/iio/addac/stx104.c            |  6 +--
>>  drivers/pinctrl/bcm/pinctrl-bcm63xx.c |  1 +
>>  drivers/pinctrl/pinctrl-tps6594.c     |  1 +
>>  include/linux/gpio/regmap.h           | 44 +++++++++++++++++--
>>  11 files changed, 115 insertions(+), 31 deletions(-)
>>
>
>..
>
>> diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h 
>> index a3ba8242c353..45a30f50043f 100644
>> --- a/include/linux/gpio/regmap.h
>> +++ b/include/linux/gpio/regmap.h
>> @@ -13,6 +13,36 @@ struct regmap;
>>  #define GPIO_REGMAP_ADDR_ZERO ((unsigned int)(-1))  #define 
>> GPIO_REGMAP_ADDR(addr) ((addr) ? : GPIO_REGMAP_ADDR_ZERO)
>>  
>> +/**
>> + * enum gpio_regmap_operation - Operation type for reg_mask_xlate 
>> +callback
>> + *
>> + * This enum is used to distinguish between different types of GPIO 
>> +operations
>> + * so that the reg_mask_xlate callback can return the appropriate 
>> +mask for each
>> + * operation type.
>
> "Traditionally it was inferred from the base regsister. But that might not
> always work, for example if all the control bits of one GPIO lives in the
> same register. The user is free to choose which method they'll use."
>

Understood. I will add this background context to the comment.

Best Regards,
Yu-Chun

>> + *
>> + * Value operations:
>> + * @GPIO_REGMAP_GET_OP: Mask for reading direction to detect if GPIO is input or output.
>> + *                      Used in gpio_regmap_get() to determine the GPIO direction.
>> + * @GPIO_REGMAP_IN: Mask for reading input value. Used when GPIO is configured as input.
>> + * @GPIO_REGMAP_OUT: Mask for reading output value. Used when GPIO is configured as output.
>> + *
>> + * Output operations:
>> + * @GPIO_REGMAP_SET_OP: Mask for setting GPIO output value.
>> + *
>> + * Direction operations:
>> + * @GPIO_REGMAP_GET_DIR_OP: Mask for reading GPIO direction (input/output).
>> + * @GPIO_REGMAP_SET_DIR_OP: Mask for setting GPIO direction (input/output).
>> + *
>> + */

  reply	other threads:[~2026-07-21 10:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  6:57 [PATCH v6 0/8] gpio: realtek: Add support for Realtek DHC RTD1625 Yu-Chun Lin
2026-07-21  6:57 ` [PATCH v6 1/8] Revert "gpio: realtek: Add driver for Realtek DHC RTD1625 SoC" Yu-Chun Lin
2026-07-21 10:39   ` Andy Shevchenko
2026-07-21  6:57 ` [PATCH v6 2/8] gpio: regmap: Provide default IRQ resource request and release callbacks Yu-Chun Lin
2026-07-21  7:05   ` Michael Walle
2026-07-21  6:57 ` [PATCH v6 3/8] gpio: regmap: Apply default resource callbacks for regmap IRQ chip Yu-Chun Lin
2026-07-21  7:07   ` Michael Walle
2026-07-21  6:57 ` [PATCH v6 4/8] gpio: regmap: Order kernel-doc descriptions with the actual appearance Yu-Chun Lin
2026-07-21  7:07   ` Michael Walle
2026-07-21 10:43   ` Andy Shevchenko
2026-07-21  6:57 ` [PATCH v6 5/8] gpio: regmap: Add gpio_regmap_operation and value_xlate support Yu-Chun Lin
2026-07-21  7:15   ` Michael Walle
2026-07-21 10:34     ` Yu-Chun Lin [林祐君] [this message]
2026-07-21 10:46   ` Andy Shevchenko
2026-07-21  6:58 ` [PATCH v6 6/8] gpio: regmap: Add set_config callback Yu-Chun Lin
2026-07-21  7:23   ` Michael Walle
2026-07-21 10:46     ` Yu-Chun Lin [林祐君]
2026-07-21 11:18       ` Michael Walle
2026-07-21 12:10         ` Yu-Chun Lin [林祐君]
2026-07-21  6:58 ` [PATCH v6 7/8] gpio: regmap: Add IRQ enable/disable helpers Yu-Chun Lin
2026-07-21  7:24   ` Michael Walle
2026-07-21 10:54   ` Andy Shevchenko
2026-07-21  6:58 ` [PATCH v6 8/8] gpio: realtek: Add driver for Realtek DHC RTD1625 SoC Yu-Chun Lin
2026-07-21 11:12   ` Andy Shevchenko
2026-07-21 12:09     ` Yu-Chun Lin [林祐君]

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=5eca2915f98e4cb8ab182ccc01b0fa33@realtek.com \
    --to=eleanor.lin@realtek.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=brgl@kernel.org \
    --cc=cy.huang@realtek.com \
    --cc=dakr@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=james.tai@realtek.com \
    --cc=jic23@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=mathieu.dubois-briand@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=o-takashi@sakamocchi.jp \
    --cc=tychang@realtek.com \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=wbg@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox