[PATCH 2/2] gpio: spacemit: Add GPIO support for K3 SoC
Bartosz Golaszewski
brgl at kernel.org
Fri Jan 2 04:04:27 PST 2026
On Fri, 2 Jan 2026 12:36:43 +0100, Yixun Lan <dlan at gentoo.org> said:
>
>> > static u32 spacemit_gpio_bank_index(struct spacemit_gpio_bank *gb)
>> > {
>> > return (u32)(gb - gb->sg->sgb);
>> > @@ -60,13 +70,14 @@ static u32 spacemit_gpio_bank_index(struct spacemit_gpio_bank *gb)
>> > static irqreturn_t spacemit_gpio_irq_handler(int irq, void *dev_id)
>> > {
>> > struct spacemit_gpio_bank *gb = dev_id;
>> > + struct spacemit_gpio *sg = gb->sg;
>> > unsigned long pending;
>> > u32 n, gedr;
>> >
>> > - gedr = readl(gb->base + SPACEMIT_GEDR);
>> > + gedr = readl(gb->base + to_spacemit_gpio_regs(sg)->gedr);
>>
>> Since you're already touching all these register accesses - can you
>> maybe provide dedicated wrapper functions around readl()/writel() and
>> avoid any file-wide changes in the future if anything requires further
>> modification?
>>
> can you elaborate a bit further on this?
> I don't get how a wrapper helper could help to avoid file-wide changes..
>
Just create functions called "spacemit_gpio_read/write()" that wrap the
readl()/writel() and its arguments.
Like:
static u32 spacemit_gpio_read(struct spacemit_gpio_bank *gb, unsigned long reg)
{
return readl(gb->base + func_to_convert_reg_enum_to_offset(reg));
}
Looks cleaner at call sites even if it's a bit more complex. Just create an
array mapping the register enum to offset and assign it to platform data.
Bart
More information about the linux-riscv
mailing list