@@ -50,6 +50,8 @@ struct clk_scu {
50
50
u8 clk_type ;
51
51
52
52
/* for state save&restore */
53
+ struct clk_hw * parent ;
54
+ u8 parent_index ;
53
55
bool is_enabled ;
54
56
u32 rate ;
55
57
};
@@ -337,6 +339,8 @@ static u8 clk_scu_get_parent(struct clk_hw *hw)
337
339
return 0 ;
338
340
}
339
341
342
+ clk -> parent_index = msg .data .resp .parent ;
343
+
340
344
return msg .data .resp .parent ;
341
345
}
342
346
@@ -345,6 +349,7 @@ static int clk_scu_set_parent(struct clk_hw *hw, u8 index)
345
349
struct clk_scu * clk = to_clk_scu (hw );
346
350
struct imx_sc_msg_set_clock_parent msg ;
347
351
struct imx_sc_rpc_msg * hdr = & msg .hdr ;
352
+ int ret ;
348
353
349
354
hdr -> ver = IMX_SC_RPC_VERSION ;
350
355
hdr -> svc = IMX_SC_RPC_SVC_PM ;
@@ -355,7 +360,16 @@ static int clk_scu_set_parent(struct clk_hw *hw, u8 index)
355
360
msg .clk = clk -> clk_type ;
356
361
msg .parent = index ;
357
362
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 ;
359
373
}
360
374
361
375
static 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)
547
561
(rsrc_id == IMX_SC_R_A72 ))
548
562
return 0 ;
549
563
564
+ clk -> parent = clk_hw_get_parent (& clk -> hw );
565
+
550
566
/* DC SS needs to handle bypass clock using non-cached clock rate */
551
567
if (clk -> rsrc_id == IMX_SC_R_DC_0_VIDEO0 ||
552
568
clk -> rsrc_id == IMX_SC_R_DC_0_VIDEO1 ||
@@ -557,6 +573,10 @@ static int __maybe_unused imx_clk_scu_suspend(struct device *dev)
557
573
clk -> rate = clk_hw_get_rate (& clk -> hw );
558
574
clk -> is_enabled = clk_hw_is_enabled (& clk -> hw );
559
575
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
+
560
580
if (clk -> rate )
561
581
dev_dbg (dev , "save rate %d\n" , clk -> rate );
562
582
@@ -576,6 +596,13 @@ static int __maybe_unused imx_clk_scu_resume(struct device *dev)
576
596
(rsrc_id == IMX_SC_R_A72 ))
577
597
return 0 ;
578
598
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
+
579
606
if (clk -> rate ) {
580
607
ret = clk_scu_set_rate (& clk -> hw , clk -> rate , 0 );
581
608
dev_dbg (dev , "restore rate %d %s\n" , clk -> rate ,
0 commit comments