Re: [PATCH v2 2/2] gpio: Add Siflower GPIO controller driver

From: Linus Walleij

Date: Tue Nov 17 2026 - 05:39:11 EST


Hi Joseph,

On Mon, Nov 9, 2026 at 9:09 PM Joseph Telaak via B4 Relay
<devnull+joseph.telaak.dev@xxxxxxxxxx> wrote:

> From: Qingfang Deng <qingfang.deng@xxxxxxxxxxxxxxx>
>
> Add a driver for the GPIO controller on Siflower SoCs.
> This controller is found on all current Siflower MIPS and RISC-V
> chips including SF19A2890, SF21A6826 and SF21H8898.
>
> Signed-off-by: Qingfang Deng <qingfang.deng@xxxxxxxxxxxxxxx>
> Signed-off-by: Chuanhong Guo <gch981213@xxxxxxxxx>
> [Joseph Telaak:
> - take it from Chuanhong's siflower-7.1 branch
> - depend on MACH_SIFLOWER_MIPS instead of OF_GPIO, longer Kconfig help
> - get the reset with devm_reset_control_get_exclusive_deasserted(),
> so it is asserted again only after the GPIO chip is removed, not in
> a .remove that ran first
> - drop .owner and the unused drvdata, and get priv with
> gpiochip_get_data()
> - drop the irq_set_affinity callback, which reached the parent
> through irq_to_desc(), not exported with SPARSE_IRQ
> - call gpiochip_disable_irq() and gpiochip_enable_irq() from mask
> and unmask, as an immutable irqchip must
> - find the group by its parent IRQ instead of assuming consecutive
> numbers
> - return 0 or 1 from .get
> - use readl() and writel() directly, without wrapper functions
> - take the number of lines from the match data, not from an
> ngpios property
> - include linux/math64.h, drop the unused linux/pinctrl/consumer.h,
> sort the includes, spell it "Siflower"
> - subject]
> Co-developed-by: Joseph Telaak <joseph@xxxxxxxxxx>
> Signed-off-by: Joseph Telaak <joseph@xxxxxxxxxx>
(...)

> +static int sf_gpio_get_value(struct gpio_chip *gc, unsigned int offset)
> +{
> + struct sf_gpio_priv *priv = gpiochip_get_data(gc);
> +
> + return !!readl(priv->base + GPIO_IR(offset));
> +}
> +
> +static int sf_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
> + int value)
> +{
> + struct sf_gpio_priv *priv = gpiochip_get_data(gc);
> +
> + writel(value, priv->base + GPIO_OR(offset));
> + return 0;
> +}
> +
> +static int sf_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
> +{
> + struct sf_gpio_priv *priv = gpiochip_get_data(gc);
> +
> + if (readl(priv->base + GPIO_OEN(offset)))
> + return GPIO_LINE_DIRECTION_IN;
> +
> + return GPIO_LINE_DIRECTION_OUT;
> +}
> +
> +static int sf_gpio_direction_input(struct gpio_chip *gc, unsigned int offset)
> +{
> + struct sf_gpio_priv *priv = gpiochip_get_data(gc);
> +
> + writel(1, priv->base + GPIO_OEN(offset));
> + return 0;
> +}
> +
> +static int sf_gpio_direction_output(struct gpio_chip *gc, unsigned int offset,
> + int value)
> +{
> + struct sf_gpio_priv *priv = gpiochip_get_data(gc);
> +
> + writel(value, priv->base + GPIO_OR(offset));
> + writel(0, priv->base + GPIO_OEN(offset));
> + return 0;
> +}

So this has one register per setting per GPIO line?

This is ideally handled with select GPIO_REGMAP
for gpio-regmap.c using regmap-mmio, see for example
see for example gpio-mvebu.c that does this elegantly.

Yours,
Linus Walleij