Re: [PATCH 2/2] gpio: rcar: Add R-Car X5H (R8A78000) support

From: Geert Uytterhoeven

Date: Tue Jul 07 2026 - 03:00:08 EST


Hi Marek,

Thanks for your patch!

On Mon, 6 Jul 2026 at 21:44, Marek Vasut <marek.vasut@xxxxxxxxxxx> wrote:
> On 7/6/26 11:19 AM, Bartosz Golaszewski wrote:
> >> +static inline int gpio_rcar_remap_offset(struct gpio_rcar_priv *p, int *offs)
> >> +{
>
> I am hoping to get some input on this remap function.

I haven't looked at your patch in detail yet, but the remap function
was the first thing that struck my eyes. This might impact performance
of bit-banging and of the sloppy logic analyzer.
Have you looked at the code generated by the compiler?
Perhaps it would be better to use a table, like sci_port_params.regs[]
in the sh-sci driver, and riic_of_data.regs in the riic driver?

> >> + /* R-Car Gen4 and older do not need any offset remap. */
> >> + if (!p->info.has_layout_gen5)
> >> + return 0;
> >> +
> >> + /*
> >> + * R-Car Gen5 register layout is slightly different and the offsets
> >> + * that have to be added to or subtracted from each register offset
> >> + * can be divided into five groups, listed below.
> >> + */
> >> + switch (*offs) {
> >> + case IOINTSEL...OUTDT:
> >> + return 0;
> >> + case INDT:
> >> + *offs += 0x10;
> >> + return 0;
> >> + case INTDT...EDGLEVEL:
> >> + fallthrough;
> >> + case BOTHEDGE:
> >> + *offs += 0x70;
> >> + return 0;
> >> + case OUTDTSEL:
> >> + *offs -= 0x34;
> >> + return 0;
> >> + case INEN:
> >> + *offs -= 0x38;
> >> + return 0;
> >> + default:
> >> + /*
> >> + * This here must never be reached, if this is reached, that
> >> + * means there is a catastrophic failure in the driver. Skip
> >> + * any IO read/write to prevent further damage.
> >> + */
> >> + WARN_ON(1);
> >> + return -EINVAL;
> >> + }
> >> +}
> >> +

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds