clk: imx: scu: add parent save and restore
Add clock parent save and restore. Reviewed-by: Anson Huang <Anson.Huang@nxp.com> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>5.4-rM2-2.2.x-imx-squashed
parent
4872753779
commit
53f2c5daa3
|
@ -53,6 +53,8 @@ struct clk_scu {
|
|||
u8 clk_type;
|
||||
|
||||
/* for state save&restore */
|
||||
struct clk_hw *parent;
|
||||
u8 parent_index;
|
||||
bool is_enabled;
|
||||
u32 rate;
|
||||
};
|
||||
|
@ -340,6 +342,8 @@ static u8 clk_scu_get_parent(struct clk_hw *hw)
|
|||
return 0;
|
||||
}
|
||||
|
||||
clk->parent_index = msg.data.resp.parent;
|
||||
|
||||
return msg.data.resp.parent;
|
||||
}
|
||||
|
||||
|
@ -348,6 +352,7 @@ static int clk_scu_set_parent(struct clk_hw *hw, u8 index)
|
|||
struct clk_scu *clk = to_clk_scu(hw);
|
||||
struct imx_sc_msg_set_clock_parent msg;
|
||||
struct imx_sc_rpc_msg *hdr = &msg.hdr;
|
||||
int ret;
|
||||
|
||||
hdr->ver = IMX_SC_RPC_VERSION;
|
||||
hdr->svc = IMX_SC_RPC_SVC_PM;
|
||||
|
@ -358,7 +363,16 @@ static int clk_scu_set_parent(struct clk_hw *hw, u8 index)
|
|||
msg.clk = clk->clk_type;
|
||||
msg.parent = index;
|
||||
|
||||
return imx_scu_call_rpc(ccm_ipc_handle, &msg, true);
|
||||
ret = imx_scu_call_rpc(ccm_ipc_handle, &msg, true);
|
||||
if (ret) {
|
||||
pr_err("%s: failed to set clock parent %d\n",
|
||||
clk_hw_get_name(hw), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
clk->parent_index = index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sc_pm_clock_enable(struct imx_sc_ipc *ipc, u16 resource,
|
||||
|
@ -549,6 +563,8 @@ int __maybe_unused imx_clk_scu_suspend(struct device *dev)
|
|||
(rsrc_id == IMX_SC_R_A72))
|
||||
return 0;
|
||||
|
||||
clk->parent = clk_hw_get_parent(&clk->hw);
|
||||
|
||||
/* DC SS needs to handle bypass clock using non-cached clock rate */
|
||||
if (clk->rsrc_id == IMX_SC_R_DC_0_VIDEO0 ||
|
||||
clk->rsrc_id == IMX_SC_R_DC_0_VIDEO1 ||
|
||||
|
@ -557,8 +573,13 @@ int __maybe_unused imx_clk_scu_suspend(struct device *dev)
|
|||
clk->rate = clk_scu_recalc_rate(&clk->hw, 0);
|
||||
else
|
||||
clk->rate = clk_hw_get_rate(&clk->hw);
|
||||
|
||||
clk->is_enabled = clk_hw_is_enabled(&clk->hw);
|
||||
|
||||
if (clk->parent)
|
||||
dev_dbg(dev, "save parent %s idx %u\n", clk_hw_get_name(clk->parent),
|
||||
clk->parent_index);
|
||||
|
||||
if (clk->rate)
|
||||
dev_dbg(dev, "save rate %d\n", clk->rate);
|
||||
|
||||
|
@ -578,6 +599,13 @@ int __maybe_unused imx_clk_scu_resume(struct device *dev)
|
|||
(rsrc_id == IMX_SC_R_A72))
|
||||
return 0;
|
||||
|
||||
if (clk->parent) {
|
||||
ret = clk_scu_set_parent(&clk->hw, clk->parent_index);
|
||||
dev_dbg(dev, "restore parent %s idx %u %s\n",
|
||||
clk_hw_get_name(clk->parent),
|
||||
clk->parent_index, !ret ? "success" : "failed");
|
||||
}
|
||||
|
||||
if (clk->rate) {
|
||||
ret = clk_scu_set_rate(&clk->hw, clk->rate, 0);
|
||||
dev_dbg(dev, "restore rate %d %s\n", clk->rate,
|
||||
|
|
Loading…
Reference in New Issue