clk: starfive: jh7110: Don't save and restore isp / vout clock registers in sleep pm

Add reg_flags to identify clocks.
Don't save and restore isp / vout clocks in sleep pm.

Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
This commit is contained in:
Hal Feng 2024-04-23 17:18:53 +08:00
parent 3c692400f8
commit 9a1b3afddb
7 changed files with 34 additions and 5 deletions

View file

@ -121,6 +121,7 @@ static int jh7110_aoncrg_probe(struct platform_device *pdev)
clk->hw.init = &init;
clk->idx = idx;
clk->max_div = max & JH71X0_CLK_DIV_MASK;
clk->reg_flags = JH7110_CLK_AON_FLAG;
ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
if (ret)
@ -131,7 +132,7 @@ static int jh7110_aoncrg_probe(struct platform_device *pdev)
if (ret)
return ret;
return jh7110_reset_controller_register(priv, "rst-aon", 1);
return jh7110_reset_controller_register(priv, "rst-aon", JH7110_CLK_AON_FLAG);
}
static const struct of_device_id jh7110_aoncrg_match[] = {

View file

@ -180,6 +180,7 @@ static int jh7110_ispcrg_probe(struct platform_device *pdev)
clk->hw.init = &init;
clk->idx = idx;
clk->max_div = max & JH71X0_CLK_DIV_MASK;
clk->reg_flags = JH7110_CLK_ISP_FLAG;
ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
if (ret)
@ -190,7 +191,7 @@ static int jh7110_ispcrg_probe(struct platform_device *pdev)
if (ret)
goto err_exit;
ret = jh7110_reset_controller_register(priv, "rst-isp", 3);
ret = jh7110_reset_controller_register(priv, "rst-isp", JH7110_CLK_ISP_FLAG);
if (ret)
goto err_exit;

View file

@ -139,6 +139,7 @@ static int jh7110_stgcrg_probe(struct platform_device *pdev)
clk->hw.init = &init;
clk->idx = idx;
clk->max_div = max & JH71X0_CLK_DIV_MASK;
clk->reg_flags = JH7110_CLK_STG_FLAG;
ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
if (ret)
@ -149,7 +150,7 @@ static int jh7110_stgcrg_probe(struct platform_device *pdev)
if (ret)
return ret;
return jh7110_reset_controller_register(priv, "rst-stg", 2);
return jh7110_reset_controller_register(priv, "rst-stg", JH7110_CLK_STG_FLAG);
}
static const struct of_device_id jh7110_stgcrg_match[] = {

View file

@ -506,6 +506,7 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
clk->hw.init = &init;
clk->idx = idx;
clk->max_div = max & JH71X0_CLK_DIV_MASK;
clk->reg_flags = JH7110_CLK_SYS_FLAG;
ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
if (ret)
@ -516,7 +517,7 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
if (ret)
return ret;
ret = jh7110_reset_controller_register(priv, "rst-sys", 0);
ret = jh7110_reset_controller_register(priv, "rst-sys", JH7110_CLK_SYS_FLAG);
if (ret)
return ret;

View file

@ -187,6 +187,7 @@ static int jh7110_voutcrg_probe(struct platform_device *pdev)
clk->hw.init = &init;
clk->idx = idx;
clk->max_div = max & JH71X0_CLK_DIV_MASK;
clk->reg_flags = JH7110_CLK_VOUT_FLAG;
ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
if (ret)
@ -197,7 +198,7 @@ static int jh7110_voutcrg_probe(struct platform_device *pdev)
if (ret)
goto err_exit;
ret = jh7110_reset_controller_register(priv, "rst-vo", 4);
ret = jh7110_reset_controller_register(priv, "rst-vo", JH7110_CLK_VOUT_FLAG);
if (ret)
goto err_exit;

View file

@ -245,6 +245,9 @@ static int jh7110_clk_save_context(struct clk_hw *hw)
if (!clk || !priv)
return 0;
if (clk->reg_flags == JH7110_CLK_ISP_FLAG || clk->reg_flags == JH7110_CLK_VOUT_FLAG)
return 0;
spin_lock(&priv->rmw_lock);
clk->saved_reg = jh71x0_clk_reg_get(clk);
spin_unlock(&priv->rmw_lock);
@ -259,6 +262,9 @@ static void jh7110_clk_gate_restore_context(struct clk_hw *hw)
if (!clk)
return;
if (clk->reg_flags == JH7110_CLK_ISP_FLAG || clk->reg_flags == JH7110_CLK_VOUT_FLAG)
return;
jh71x0_clk_reg_rmw(clk, JH71X0_CLK_ENABLE, clk->saved_reg);
}
@ -269,6 +275,9 @@ static void jh7110_clk_div_restore_context(struct clk_hw *hw)
if (!clk)
return;
if (clk->reg_flags == JH7110_CLK_ISP_FLAG || clk->reg_flags == JH7110_CLK_VOUT_FLAG)
return;
jh71x0_clk_reg_rmw(clk, JH71X0_CLK_DIV_MASK, clk->saved_reg);
}
@ -279,6 +288,9 @@ static void jh7110_clk_mux_restore_context(struct clk_hw *hw)
if (!clk)
return;
if (clk->reg_flags == JH7110_CLK_ISP_FLAG || clk->reg_flags == JH7110_CLK_VOUT_FLAG)
return;
jh71x0_clk_reg_rmw(clk, JH71X0_CLK_MUX_MASK, clk->saved_reg);
}
@ -289,6 +301,9 @@ static void jh7110_clk_inv_restore_context(struct clk_hw *hw)
if (!clk)
return;
if (clk->reg_flags == JH7110_CLK_ISP_FLAG || clk->reg_flags == JH7110_CLK_VOUT_FLAG)
return;
jh71x0_clk_reg_rmw(clk, JH71X0_CLK_INVERT, clk->saved_reg);
}

View file

@ -7,6 +7,14 @@
#include <linux/device.h>
#include <linux/spinlock.h>
enum JH7110_CLOCK_FLAGS {
JH7110_CLK_SYS_FLAG = 0,
JH7110_CLK_AON_FLAG,
JH7110_CLK_STG_FLAG,
JH7110_CLK_ISP_FLAG,
JH7110_CLK_VOUT_FLAG,
};
/* register fields */
#define JH71X0_CLK_ENABLE BIT(31)
#define JH71X0_CLK_INVERT BIT(30)
@ -107,6 +115,7 @@ struct jh71x0_clk {
struct clk_hw hw;
unsigned int idx;
unsigned int max_div;
unsigned int reg_flags;
u32 saved_reg;
};