pinctrl: renesas: rzg2l: Fix OEN resume
authorBiju Das <biju.das.jz@bp.renesas.com>
Sun, 17 Aug 2025 14:30:19 +0000 (15:30 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 8 Sep 2025 10:02:55 +0000 (12:02 +0200)
Writing to the PFC_OEN register is controlled by the write protect
register (PWPR).  Currently the OEN register write in resume() is done
without enabling write access in PWPR leading to incorrect operation.

Fixes: cd39805be85b ("pinctrl: renesas: rzg2l: Unify OEN handling across RZ/{G2L,V2H,V2N}")
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
[geert: Move spin_*lock*() calls inside if-statements]
Link: https://lore.kernel.org/20250817143024.165471-2-biju.das.jz@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
drivers/pinctrl/renesas/pinctrl-rzg2l.c

index b182b3b..f72814d 100644 (file)
@@ -3165,6 +3165,8 @@ static int rzg2l_pinctrl_resume_noirq(struct device *dev)
        const struct rzg2l_hwcfg *hwcfg = pctrl->data->hwcfg;
        const struct rzg2l_register_offsets *regs = &hwcfg->regs;
        struct rzg2l_pinctrl_reg_cache *cache = pctrl->cache;
+       unsigned long flags;
+       u8 pwpr;
        int ret;
 
        if (!atomic_read(&pctrl->wakeup_path)) {
@@ -3174,7 +3176,16 @@ static int rzg2l_pinctrl_resume_noirq(struct device *dev)
        }
 
        writeb(cache->qspi, pctrl->base + QSPI);
+       if (pctrl->data->hwcfg->oen_pwpr_lock) {
+               spin_lock_irqsave(&pctrl->lock, flags);
+               pwpr = readb(pctrl->base + regs->pwpr);
+               writeb(pwpr | PWPR_REGWE_B, pctrl->base + regs->pwpr);
+       }
        writeb(cache->oen, pctrl->base + pctrl->data->hwcfg->regs.oen);
+       if (pctrl->data->hwcfg->oen_pwpr_lock) {
+               writeb(pwpr & ~PWPR_REGWE_B, pctrl->base + regs->pwpr);
+               spin_unlock_irqrestore(&pctrl->lock, flags);
+       }
        for (u8 i = 0; i < 2; i++) {
                if (regs->sd_ch)
                        writeb(cache->sd_ch[i], pctrl->base + SD_CH(regs->sd_ch, i));