Re: [PATCH v6 5/8] gpio: regmap: Add gpio_regmap_operation and value_xlate support

From: Andy Shevchenko

Date: Tue Jul 21 2026 - 07:06:39 EST


On Tue, Jul 21, 2026 at 02:57:59PM +0800, 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.
>
> 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.

...

> +/**
> + * 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.
> + *
> + * 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).

> + *

Unneeded blank line. Also not the big deal. Update only if new version is needed.

> + */
> +enum gpio_regmap_operation {
> + GPIO_REGMAP_GET_OP,
> + GPIO_REGMAP_SET_OP,
> + GPIO_REGMAP_GET_DIR_OP,
> + GPIO_REGMAP_SET_DIR_OP,
> + GPIO_REGMAP_IN,
> + GPIO_REGMAP_OUT,
> +};

--
With Best Regards,
Andy Shevchenko