[PATCH net v4] net: pcs: rzn1-miic: Clear MIIC protection state before unprotect sequence

From: Yoshihisa Yamamoto

Date: Thu Sep 24 2026 - 06:37:27 EST


On RZ/T2H and RZ/N1D MIIC, writing 0x0000 to the MIIC protection
register clears the protection state machine.

The initial protection state cannot be assumed to be constant,
as it may be influenced by previous activity before the driver
takes ownership of the hardware.

Clear the protection state before issuing the unprotect sequence
so that register access always starts from a known state, regardless
of any previous activity.

Fixes: 7dc54d3b8d91 ("net: pcs: add Renesas MII converter driver")
Signed-off-by: Yoshihisa Yamamoto <yoshihisa.yamamoto.xn@xxxxxxxxxxx>
---
V4:
- Clarify commit message
- Point Fixes tag to 7dc54d3b8d91, as the issue also affects RZ/N1D

v3: https://lore.kernel.org/all/TYCPR01MB7481CE8351FDB2CDCA229955A4872@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Add Fixes tag

v2: https://lore.kernel.org/all/TYCPR01MB748157ECB6B92D8E3FFD433BA4B82@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Fix indentation

v1: https://lore.kernel.org/all/TYCPR01MB748139F059DF2459B9813416A4B92@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

drivers/net/pcs/pcs-rzn1-miic.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
index 2b72fa98ddf1..279f709c889b 100644
--- a/drivers/net/pcs/pcs-rzn1-miic.c
+++ b/drivers/net/pcs/pcs-rzn1-miic.c
@@ -270,6 +270,9 @@ static struct miic_port *phylink_pcs_to_miic_port(struct phylink_pcs *pcs)

static void miic_unlock_regs(struct miic *miic)
{
+ /* Clear protection state */
+ writel(0x0000, miic->base + MIIC_PRCMD);
+
/* Unprotect register writes */
writel(0x00A5, miic->base + MIIC_PRCMD);
writel(0x0001, miic->base + MIIC_PRCMD);
--
2.34.1