From: Biju Das biju.das.jz@bp.renesas.com
[ Upstream commit 837afa592c6234be82acb5d23e0a39e9befdaa85 ]
Renesas RZ/G3E supports a power-saving mode where power to most of the SoC components is lost, including the PIN controller. Save and restore the Schmitt control register contents to ensure the functionality is preserved after a suspend/resume cycle.
Signed-off-by: Biju Das biju.das.jz@bp.renesas.com Reviewed-by: Claudiu Beznea claudiu.beznea.uj@bp.renesas.com Tested-by: Claudiu Beznea claudiu.beznea.uj@bp.renesas.com # on RZ/G3S Reviewed-by: Geert Uytterhoeven geert+renesas@glider.be Link: https://lore.kernel.org/20250819084022.20512-1-biju.das.jz@bp.renesas.com Signed-off-by: Geert Uytterhoeven geert+renesas@glider.be Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES — the patch fixes a suspend/resume regression on RZ/G3E-class parts without introducing risky behaviour.
**Key Points** - Extends the suspend cache to cover Schmitt-trigger registers so their runtime configuration survives deep sleep (`drivers/pinctrl/renesas/pinctrl-rzg2l.c:318`). - Allocates `cache->smt` for every port and captures the live register contents during suspend (`drivers/pinctrl/renesas/pinctrl- rzg2l.c:2711`), mirroring how pull-up/down and IOLH state are already handled. - Restores the saved Schmitt values only on ports advertising `PIN_CFG_SMT`, preventing writes on hardware that lacks the block (`drivers/pinctrl/renesas/pinctrl-rzg2l.c:2986` and `drivers/pinctrl/renesas/pinctrl-rzg2l.c:3026`). - Without this change, any pin configured with `PIN_CONFIG_INPUT_SCHMITT_ENABLE` (see support added in commit 725933a54f71) reverts to the default after system suspend because the controller loses power in RZ/G3E low-power modes; that is a user- visible functional bug.
**Dependencies** - Requires prior Schmitt-trigger support (commit 725933a54f71) and the existing suspend cache framework for pull-up/down registers (commit b2bd65fbb6173) so that the new field fits cleanly.
**Next Steps** - 1) Cherry-pick this change together with the prerequisites above into any stable branch shipping RZ/G3E/RZ/V2H pinctrl support so Schmitt- trigger inputs keep working across suspend.
drivers/pinctrl/renesas/pinctrl-rzg2l.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index c52263c2a7b09..4c25d2a7966a0 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -320,6 +320,7 @@ struct rzg2l_pinctrl_pin_settings { * @iolh: IOLH registers cache * @pupd: PUPD registers cache * @ien: IEN registers cache + * @smt: SMT registers cache * @sd_ch: SD_CH registers cache * @eth_poc: ET_POC registers cache * @eth_mode: ETH_MODE register cache @@ -333,6 +334,7 @@ struct rzg2l_pinctrl_reg_cache { u32 *iolh[2]; u32 *ien[2]; u32 *pupd[2]; + u32 *smt; u8 sd_ch[2]; u8 eth_poc[2]; u8 eth_mode; @@ -2719,6 +2721,10 @@ static int rzg2l_pinctrl_reg_cache_alloc(struct rzg2l_pinctrl *pctrl) if (!cache->pfc) return -ENOMEM;
+ cache->smt = devm_kcalloc(pctrl->dev, nports, sizeof(*cache->smt), GFP_KERNEL); + if (!cache->smt) + return -ENOMEM; + for (u8 i = 0; i < 2; i++) { u32 n_dedicated_pins = pctrl->data->n_dedicated_pins;
@@ -2980,7 +2986,7 @@ static void rzg2l_pinctrl_pm_setup_regs(struct rzg2l_pinctrl *pctrl, bool suspen struct rzg2l_pinctrl_reg_cache *cache = pctrl->cache;
for (u32 port = 0; port < nports; port++) { - bool has_iolh, has_ien, has_pupd; + bool has_iolh, has_ien, has_pupd, has_smt; u32 off, caps; u8 pincnt; u64 cfg; @@ -2993,6 +2999,7 @@ static void rzg2l_pinctrl_pm_setup_regs(struct rzg2l_pinctrl *pctrl, bool suspen has_iolh = !!(caps & (PIN_CFG_IOLH_A | PIN_CFG_IOLH_B | PIN_CFG_IOLH_C)); has_ien = !!(caps & PIN_CFG_IEN); has_pupd = !!(caps & PIN_CFG_PUPD); + has_smt = !!(caps & PIN_CFG_SMT);
if (suspend) RZG2L_PCTRL_REG_ACCESS32(suspend, pctrl->base + PFC(off), cache->pfc[port]); @@ -3031,6 +3038,9 @@ static void rzg2l_pinctrl_pm_setup_regs(struct rzg2l_pinctrl *pctrl, bool suspen cache->ien[1][port]); } } + + if (has_smt) + RZG2L_PCTRL_REG_ACCESS32(suspend, pctrl->base + SMT(off), cache->smt[port]); } }