]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pinctrl: renesas: rzt2h: Skip PFC mode configuration if already set
authorLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Wed, 13 May 2026 11:53:12 +0000 (12:53 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 25 May 2026 10:00:23 +0000 (12:00 +0200)
In rzt2h_pinctrl_set_pfc_mode(), read the PMC and PFC registers upfront
and skip the pin function configuration if the pin is already in
peripheral mode with the desired function.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20260513115312.1574367-3-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
drivers/pinctrl/renesas/pinctrl-rzt2h.c

index 4b790fa72b49d3a5f55efacaf32782f34b311bea..eb70aee39f1ae3c7617ce3c05f79ac91de265d5a 100644 (file)
@@ -191,6 +191,12 @@ static void rzt2h_pinctrl_set_pfc_mode(struct rzt2h_pinctrl *pctrl,
 
        guard(raw_spinlock_irqsave)(&pctrl->lock);
 
+       reg64 = rzt2h_pinctrl_readq(pctrl, port, PFC(port));
+       /* Check if pin is already configured to the desired function */
+       if ((rzt2h_pinctrl_readb(pctrl, port, PMC(port)) & BIT(pin)) &&
+           field_get(PFC_PIN_MASK(pin), reg64) == func)
+               return;
+
        /* Set pin to 'Non-use (Hi-Z input protection)'  */
        reg16 = rzt2h_pinctrl_readw(pctrl, port, PM(port));
        reg16 &= ~PM_PIN_MASK(pin);
@@ -200,7 +206,6 @@ static void rzt2h_pinctrl_set_pfc_mode(struct rzt2h_pinctrl *pctrl,
        rzt2h_pinctrl_set_gpio_en(pctrl, port, pin, true);
 
        /* Select Pin function mode with PFC register */
-       reg64 = rzt2h_pinctrl_readq(pctrl, port, PFC(port));
        reg64 &= ~PFC_PIN_MASK(pin);
        rzt2h_pinctrl_writeq(pctrl, port, reg64 | ((u64)func << (pin * 8)), PFC(port));