@@ -50,6 +50,8 @@ struct clk_scu {
5050 u8 clk_type ;
5151
5252 /* for state save&restore */
53+ struct clk_hw * parent ;
54+ u8 parent_index ;
5355 bool is_enabled ;
5456 u32 rate ;
5557};
@@ -337,6 +339,8 @@ static u8 clk_scu_get_parent(struct clk_hw *hw)
337339 return 0 ;
338340 }
339341
342+ clk -> parent_index = msg .data .resp .parent ;
343+
340344 return msg .data .resp .parent ;
341345}
342346
@@ -345,6 +349,7 @@ static int clk_scu_set_parent(struct clk_hw *hw, u8 index)
345349 struct clk_scu * clk = to_clk_scu (hw );
346350 struct imx_sc_msg_set_clock_parent msg ;
347351 struct imx_sc_rpc_msg * hdr = & msg .hdr ;
352+ int ret ;
348353
349354 hdr -> ver = IMX_SC_RPC_VERSION ;
350355 hdr -> svc = IMX_SC_RPC_SVC_PM ;
@@ -355,7 +360,16 @@ static int clk_scu_set_parent(struct clk_hw *hw, u8 index)
355360 msg .clk = clk -> clk_type ;
356361 msg .parent = index ;
357362
358- return imx_scu_call_rpc (ccm_ipc_handle , & msg , true);
363+ ret = imx_scu_call_rpc (ccm_ipc_handle , & msg , true);
364+ if (ret ) {
365+ pr_err ("%s: failed to set clock parent %d\n" ,
366+ clk_hw_get_name (hw ), ret );
367+ return ret ;
368+ }
369+
370+ clk -> parent_index = index ;
371+
372+ return 0 ;
359373}
360374
361375static int sc_pm_clock_enable (struct imx_sc_ipc * ipc , u16 resource ,
@@ -547,6 +561,8 @@ static int __maybe_unused imx_clk_scu_suspend(struct device *dev)
547561 (rsrc_id == IMX_SC_R_A72 ))
548562 return 0 ;
549563
564+ clk -> parent = clk_hw_get_parent (& clk -> hw );
565+
550566 /* DC SS needs to handle bypass clock using non-cached clock rate */
551567 if (clk -> rsrc_id == IMX_SC_R_DC_0_VIDEO0 ||
552568 clk -> rsrc_id == IMX_SC_R_DC_0_VIDEO1 ||
@@ -557,6 +573,10 @@ static int __maybe_unused imx_clk_scu_suspend(struct device *dev)
557573 clk -> rate = clk_hw_get_rate (& clk -> hw );
558574 clk -> is_enabled = clk_hw_is_enabled (& clk -> hw );
559575
576+ if (clk -> parent )
577+ dev_dbg (dev , "save parent %s idx %u\n" , clk_hw_get_name (clk -> parent ),
578+ clk -> parent_index );
579+
560580 if (clk -> rate )
561581 dev_dbg (dev , "save rate %d\n" , clk -> rate );
562582
@@ -576,6 +596,13 @@ static int __maybe_unused imx_clk_scu_resume(struct device *dev)
576596 (rsrc_id == IMX_SC_R_A72 ))
577597 return 0 ;
578598
599+ if (clk -> parent ) {
600+ ret = clk_scu_set_parent (& clk -> hw , clk -> parent_index );
601+ dev_dbg (dev , "restore parent %s idx %u %s\n" ,
602+ clk_hw_get_name (clk -> parent ),
603+ clk -> parent_index , !ret ? "success" : "failed" );
604+ }
605+
579606 if (clk -> rate ) {
580607 ret = clk_scu_set_rate (& clk -> hw , clk -> rate , 0 );
581608 dev_dbg (dev , "restore rate %d %s\n" , clk -> rate ,
0 commit comments