Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: imx: scu: add parent save and restore

Add clock parent save and restore.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Reviewed-by: Abel Vesa <abel.vesa@nxp.com>
Signed-off-by: Abel Vesa <abel.vesa@nxp.com>

authored by

Dong Aisheng and committed by
Abel Vesa
a82327cc 7487986c

+28 -1
+28 -1
drivers/clk/imx/clk-scu.c
··· 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 }; ··· 339 337 return 0; 340 338 } 341 339 340 + clk->parent_index = msg.data.resp.parent; 341 + 342 342 return msg.data.resp.parent; 343 343 } 344 344 ··· 349 345 struct clk_scu *clk = to_clk_scu(hw); 350 346 struct imx_sc_msg_set_clock_parent msg; 351 347 struct imx_sc_rpc_msg *hdr = &msg.hdr; 348 + int ret; 352 349 353 350 hdr->ver = IMX_SC_RPC_VERSION; 354 351 hdr->svc = IMX_SC_RPC_SVC_PM; ··· 360 355 msg.clk = clk->clk_type; 361 356 msg.parent = index; 362 357 363 - return imx_scu_call_rpc(ccm_ipc_handle, &msg, true); 358 + ret = imx_scu_call_rpc(ccm_ipc_handle, &msg, true); 359 + if (ret) { 360 + pr_err("%s: failed to set clock parent %d\n", 361 + clk_hw_get_name(hw), ret); 362 + return ret; 363 + } 364 + 365 + clk->parent_index = index; 366 + 367 + return 0; 364 368 } 365 369 366 370 static int sc_pm_clock_enable(struct imx_sc_ipc *ipc, u16 resource, ··· 561 547 (rsrc_id == IMX_SC_R_A72)) 562 548 return 0; 563 549 550 + clk->parent = clk_hw_get_parent(&clk->hw); 551 + 564 552 /* DC SS needs to handle bypass clock using non-cached clock rate */ 565 553 if (clk->rsrc_id == IMX_SC_R_DC_0_VIDEO0 || 566 554 clk->rsrc_id == IMX_SC_R_DC_0_VIDEO1 || ··· 572 556 else 573 557 clk->rate = clk_hw_get_rate(&clk->hw); 574 558 clk->is_enabled = clk_hw_is_enabled(&clk->hw); 559 + 560 + if (clk->parent) 561 + dev_dbg(dev, "save parent %s idx %u\n", clk_hw_get_name(clk->parent), 562 + clk->parent_index); 575 563 576 564 if (clk->rate) 577 565 dev_dbg(dev, "save rate %d\n", clk->rate); ··· 595 575 if ((rsrc_id == IMX_SC_R_A35) || (rsrc_id == IMX_SC_R_A53) || 596 576 (rsrc_id == IMX_SC_R_A72)) 597 577 return 0; 578 + 579 + if (clk->parent) { 580 + ret = clk_scu_set_parent(&clk->hw, clk->parent_index); 581 + dev_dbg(dev, "restore parent %s idx %u %s\n", 582 + clk_hw_get_name(clk->parent), 583 + clk->parent_index, !ret ? "success" : "failed"); 584 + } 598 585 599 586 if (clk->rate) { 600 587 ret = clk_scu_set_rate(&clk->hw, clk->rate, 0);