mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-29 22:10:51 -04:00
pinctrl: renesas: rzt2h: Skip PFC mode configuration if already set
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>
This commit is contained in:
committed by
Geert Uytterhoeven
parent
ccf707ca74
commit
f9fb67bc77
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user