Skip to content

Commit 7abd037

Browse files
Yongqiang NiuJassiBrar
authored andcommitted
mailbox: mtk-cmdq: add gce ddr enable support flow
add gce ddr enable control flow when gce suspend/resume when all cmdq instruction task has been processed done, we need set this gce ddr enable to disable status to tell cmdq hardware gce there is none task need process, and the hardware can go into idle mode and no access ddr anymore, then the spm can go into suspend. the original issue is gce still access ddr when cmdq suspend function call, but there is no task run. so, we need control gce access ddr with this flow. when cmdq suspend function, there is no task need process, we can disable gce access ddr, to make sure system go into suspend success. Signed-off-by: Yongqiang Niu <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: CK Hu <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent 63f40a7 commit 7abd037

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/mailbox/mtk-cmdq-mailbox.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ struct gce_plat {
9494
u32 gce_num;
9595
};
9696

97+
static void cmdq_sw_ddr_enable(struct cmdq *cmdq, bool enable)
98+
{
99+
WARN_ON(clk_bulk_enable(cmdq->gce_num, cmdq->clocks));
100+
101+
if (enable)
102+
writel(GCE_DDR_EN | GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
103+
else
104+
writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
105+
106+
clk_bulk_disable(cmdq->gce_num, cmdq->clocks);
107+
}
108+
97109
u8 cmdq_get_shift_pa(struct mbox_chan *chan)
98110
{
99111
struct cmdq *cmdq = container_of(chan->mbox, struct cmdq, mbox);
@@ -322,6 +334,9 @@ static int cmdq_suspend(struct device *dev)
322334
if (task_running)
323335
dev_warn(dev, "exist running task(s) in suspend\n");
324336

337+
if (cmdq->sw_ddr_en)
338+
cmdq_sw_ddr_enable(cmdq, false);
339+
325340
clk_bulk_unprepare(cmdq->gce_num, cmdq->clocks);
326341

327342
return 0;
@@ -333,13 +348,20 @@ static int cmdq_resume(struct device *dev)
333348

334349
WARN_ON(clk_bulk_prepare(cmdq->gce_num, cmdq->clocks));
335350
cmdq->suspended = false;
351+
352+
if (cmdq->sw_ddr_en)
353+
cmdq_sw_ddr_enable(cmdq, true);
354+
336355
return 0;
337356
}
338357

339358
static int cmdq_remove(struct platform_device *pdev)
340359
{
341360
struct cmdq *cmdq = platform_get_drvdata(pdev);
342361

362+
if (cmdq->sw_ddr_en)
363+
cmdq_sw_ddr_enable(cmdq, false);
364+
343365
clk_bulk_unprepare(cmdq->gce_num, cmdq->clocks);
344366
return 0;
345367
}

0 commit comments

Comments
 (0)