Skip to content

Commit 3d70074

Browse files
bijudasgeertu
authored andcommitted
clk: renesas: rzg2l: Add support for critical resets
Some reset lines must remain deasserted at all times after boot, as asserting them would disable critical system functionality with no owning driver to restore them. This mirrors the existing crit_mod_clks mechanism which protects critical module clocks from being disabled. On RZ/G2L family SoCs, the DMA reset must be remain deasserted for routing some peripheral interrupts to CPU. Add crit_resets and num_crit_resets fields to struct rzg2l_cpg_info to allow SoC-specific data tables to declare reset IDs that must never be asserted. Introduce rzg2l_cpg_deassert_crit_resets() to iterate over all critical resets and deassert them. Call it both at probe time and during resume to ensure critical peripherals are held out of reset after power-on and suspend/resume cycles. Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://patch.msgid.link/20260324114329.268249-3-biju.das.jz@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent 44ed098 commit 3d70074

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

drivers/clk/renesas/rzg2l-cpg.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,13 @@ static int __rzg2l_cpg_assert(struct reset_controller_dev *rcdev,
17651765
dev_dbg(rcdev->dev, "%s id:%ld offset:0x%x\n",
17661766
assert ? "assert" : "deassert", id, CLK_RST_R(reg));
17671767

1768+
if (assert) {
1769+
for (unsigned int i = 0; i < priv->info->num_crit_resets; i++) {
1770+
if (id == priv->info->crit_resets[i])
1771+
return 0;
1772+
}
1773+
}
1774+
17681775
if (!assert)
17691776
value |= mask;
17701777
writel(value, priv->base + CLK_RST_R(reg));
@@ -1802,6 +1809,20 @@ static int rzg2l_cpg_deassert(struct reset_controller_dev *rcdev,
18021809
return __rzg2l_cpg_assert(rcdev, id, false);
18031810
}
18041811

1812+
static int rzg2l_cpg_deassert_crit_resets(struct reset_controller_dev *rcdev,
1813+
const struct rzg2l_cpg_info *info)
1814+
{
1815+
int ret;
1816+
1817+
for (unsigned int i = 0; i < info->num_crit_resets; i++) {
1818+
ret = rzg2l_cpg_deassert(rcdev, info->crit_resets[i]);
1819+
if (ret)
1820+
return ret;
1821+
}
1822+
1823+
return 0;
1824+
}
1825+
18051826
static int rzg2l_cpg_reset(struct reset_controller_dev *rcdev,
18061827
unsigned long id)
18071828
{
@@ -2051,13 +2072,22 @@ static int __init rzg2l_cpg_probe(struct platform_device *pdev)
20512072
if (error)
20522073
return error;
20532074

2075+
error = rzg2l_cpg_deassert_crit_resets(&priv->rcdev, info);
2076+
if (error)
2077+
return error;
2078+
20542079
debugfs_create_file("mstop", 0444, NULL, priv, &rzg2l_mod_clock_mstop_fops);
20552080
return 0;
20562081
}
20572082

20582083
static int rzg2l_cpg_resume(struct device *dev)
20592084
{
20602085
struct rzg2l_cpg_priv *priv = dev_get_drvdata(dev);
2086+
int ret;
2087+
2088+
ret = rzg2l_cpg_deassert_crit_resets(&priv->rcdev, priv->info);
2089+
if (ret)
2090+
return ret;
20612091

20622092
rzg2l_mod_clock_init_mstop(priv);
20632093

drivers/clk/renesas/rzg2l-cpg.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ struct rzg2l_reset {
276276
* @crit_mod_clks: Array with Module Clock IDs of critical clocks that
277277
* should not be disabled without a knowledgeable driver
278278
* @num_crit_mod_clks: Number of entries in crit_mod_clks[]
279+
* @crit_resets: Array with Reset IDs of critical resets that should not be
280+
* asserted without a knowledgeable driver
281+
* @num_crit_resets: Number of entries in crit_resets[]
279282
* @has_clk_mon_regs: Flag indicating whether the SoC has CLK_MON registers
280283
*/
281284
struct rzg2l_cpg_info {
@@ -302,6 +305,10 @@ struct rzg2l_cpg_info {
302305
const unsigned int *crit_mod_clks;
303306
unsigned int num_crit_mod_clks;
304307

308+
/* Critical Resets that should not be asserted */
309+
const unsigned int *crit_resets;
310+
unsigned int num_crit_resets;
311+
305312
bool has_clk_mon_regs;
306313
};
307314

0 commit comments

Comments
 (0)