[PATCH v2 2/5] clk: renesas: rzg2l: Re-assert reset on deassert timeout

Tommaso Merciai
2025-09-03T08:28:43Z

Prevent issues during reset deassertion by re-asserting the reset if a
timeout occurs when trying to deassert. This ensures the reset line is in a
known state and improves reliability for hardware that may not immediately
clear the reset monitor bit.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
v1->v2:
- Collected GUytterhoeven tag
- Removed dev_warn() in __rzg2l_cpg_assert()

drivers/clk/renesas/rzg2l-cpg.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
index 1143ce0afed47..8e9fea7f7dccb 100644
--- a/drivers/clk/renesas/rzg2l-cpg.c
+++ b/drivers/clk/renesas/rzg2l-cpg.c
@@ -1667,9 +1667,15 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
return 0;
}

- return readl_poll_timeout_atomic(priv->base + reg, value,
- assert == !!(value & mask),
- 10, 200);
+ ret = readl_poll_timeout_atomic(priv->base + reg, value,
+ assert == !!(value & mask),
+ 10, 200);
+ if (ret && !assert) {
+ value = mask << 16;
+ writel(value, priv->base + CLK_RST_R(info->resets[id].off));
+ }
+
+ return ret;
}

static int rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
--
2.43.0