Hi Claudiu, On Fri, Sep 29, 2023 at 7:39 AM Claudiu <claudiu.beznea@xxxxxxxxx> wrote: > From: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx> > > To get address that needs to be read/write for specific port > functionalities the P(), PM(), PMC(), PFC(), PIN(), IOLH() IEN(), ISEL() > macros are used. Some of these macros received as argument the hardware > port identifier, some hardware port offset address (e.g. ISEL() received > port identifier, IOLH() received port offset address). This makes hard to > extend the current driver for SoCs were port identifiers are not continuous > in memory map of pin controller. This is the case for RZ/G3S pin controller > were ports are mapped as follows: > > port offset port identifier > ----------- --------------- > 0x20 P0 > 0x21 P5 > 0x22 P6 > 0x23 P11 > 0x24 P12 > 0x25 P13 > 0x26 P14 > 0x27 P15 > 0x28 P16 > 0x29 P17 > 0x2a P18 > 0x30 P1 > 0x31 P2 > 0x32 P3 > 0x33 P4 > 0x34 P7 > 0x35 P8 > 0x36 P8 > 0x37 P10 > > To make this achievable change all the above macros used to get the address > of a port register for specific port functionality based on port hardware > address. Shortly, all the above macros will get as argument the port > offset address listed in the above table. > > With this RZG2L_SINGLE_PIN_GET_PORT_OFFSET(), RZG2L_PIN_ID_TO_PORT_OFFSET() > and RZG2L_GPIO_PORT_GET_INDEX() were replaced by > RZG2L_PIN_CFG_TO_PORT_OFFSET(), RZG2L_SINGLE_PIN_GET_CFGS() and > RZG2L_GPIO_PORT_GET_CFGS() were replaced by RZG2L_PIN_CFG_TO_CAPS(). > > Also rzg2l_pinctrl_set_pfc_mode() don't need port argument anymore. > Also rzg2l_gpio_direction_input() and rzg2l_gpio_direction_output() don't > need to translate port and bit locally as this can be done by > rzg2l_gpio_set_direction(). > > To use the same naming for port, bit/pin and register offset the > port_offset variable names in different places was replaced by variable > named off and there is no need to initialize anymore cfg and bit in > different code places. > > Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx> > Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> > Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> > --- > > Changes in v2: > - mentioned in commit description about the replacement of > RZG2L_GPIO_PORT_GET_INDEX() with RZG2L_PIN_CFG_TO_PORT_OFFSET() > - moved variable declaration inside for() > - got rid of local variable and used directly RZG2L_PIN_ID_TO_PORT() in > debug message from rzg2l_pinctrl_set_mux() function > - collected tags Thanks for the update! Sill queue in renesas-pinctrl-for-v6.7. > --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c > +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c > @@ -202,9 +202,11 @@ static int rzg2l_pinctrl_set_mux(struct pinctrl_dev *pctldev, > unsigned int group_selector) > { > struct rzg2l_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); > + const struct pinctrl_pin_desc *pin_desc; > + unsigned int *psel_val, *pin_data; > struct function_desc *func; > - unsigned int i, *psel_val; > struct group_desc *group; > + u32 pin, off; > int *pins; > > func = pinmux_generic_get_function(pctldev, func_selector); > @@ -217,12 +219,17 @@ static int rzg2l_pinctrl_set_mux(struct pinctrl_dev *pctldev, > psel_val = func->data; > pins = group->pins; > > - for (i = 0; i < group->num_pins; i++) { > - dev_dbg(pctrl->dev, "port:%u pin: %u PSEL:%u\n", > - RZG2L_PIN_ID_TO_PORT(pins[i]), RZG2L_PIN_ID_TO_PIN(pins[i]), > - psel_val[i]); > - rzg2l_pinctrl_set_pfc_mode(pctrl, RZG2L_PIN_ID_TO_PORT(pins[i]), > - RZG2L_PIN_ID_TO_PIN(pins[i]), psel_val[i]); > + for (unsigned int i = 0; i < group->num_pins; i++) { > + pin_desc = &pctrl->desc.pins[pins[i]]; > + pin_data = pin_desc->drv_data; > + > + pin = RZG2L_PIN_ID_TO_PIN(pins[i]); > + off = RZG2L_PIN_CFG_TO_PORT_OFFSET(*pin_data); In my comments on v1, I actually meant to combine these assignments to variables with the variable declarations. I will handle that while applying. > + > + dev_dbg(pctrl->dev, "port:%u pin: %u off:%x PSEL:%u\n", > + RZG2L_PIN_ID_TO_PORT(pins[i]), pin, off, psel_val[i]); > + > + rzg2l_pinctrl_set_pfc_mode(pctrl, pin, off, psel_val[i]); > } > > return 0; 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