mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "jassisinghbrar@gmail.com" <jassisinghbrar@gmail.com>,
	"Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>
Cc: "Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
	"treapking@chromium.org" <treapking@chromium.org>,
	"Yongqiang Niu (牛永强)" <yongqiang.niu@mediatek.com>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"Xavier Chang (張獻文)" <Xavier.Chang@mediatek.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Sirius Wang (王皓昱)" <Sirius.Wang@mediatek.com>,
	"wenst@chromium.org" <wenst@chromium.org>,
	"Xiandong Wang (王先冬)" <Xiandong.Wang@mediatek.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] mailbox: mtk-cmdq: Refine GCE_GCTL_VALUE setting
Date: Mon, 24 Feb 2025 06:04:29 +0000	[thread overview]
Message-ID: <3077494e5e989db6e347bc7c681bb584ab20e593.camel@mediatek.com> (raw)
In-Reply-To: <20250224050812.3537569-1-jason-jh.lin@mediatek.com>

On Mon, 2025-02-24 at 13:01 +0800, Jason-JH Lin wrote:
> Add cmdq_gctl_value_toggle() to configure GCE_CTRL_BY_SW and GCE_DDR_EN
> together in same the GCE_GCTL_VALUE register.
> 
> Move this function into cmdq_runtime_resume() and cmdq_runtime_suspend()
> to ensure it can be called when the GCE clock is enabled.

Why need GCE clock to be enabled when toggle GCE_GCTL_VALUE register?
In some hardware, just need power on to access register. It's not necessary to enable clock.
If GCE need to enable clock to access register, add information here.

> 
> Fixes: 7abd037aa581 ("mailbox: mtk-cmdq: add gce ddr enable support flow")
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 41 +++++++++++++-----------------
>  1 file changed, 17 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index d186865b8dce..be17697d7785 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -92,16 +92,17 @@ struct gce_plat {
>  	u32 gce_num;
>  };
>  
> -static void cmdq_sw_ddr_enable(struct cmdq *cmdq, bool enable)
> +static void cmdq_gctl_value_toggle(struct cmdq *cmdq, bool ddr_enable)
>  {
> -	WARN_ON(clk_bulk_enable(cmdq->pdata->gce_num, cmdq->clocks));
> +	u32 val = (cmdq->pdata->control_by_sw) ? GCE_CTRL_BY_SW : 0;

u32 val = cmdq->pdata->control_by_sw ? GCE_CTRL_BY_SW : 0;

>  
> -	if (enable)
> -		writel(GCE_DDR_EN | GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
> -	else
> -		writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
> +	if (!cmdq->pdata->control_by_sw && !cmdq->pdata->sw_ddr_en)
> +		return;
>  
> -	clk_bulk_disable(cmdq->pdata->gce_num, cmdq->clocks);
> +	if (cmdq->pdata->sw_ddr_en && ddr_enable)
> +		val |= GCE_DDR_EN;
> +
> +	writel(val, cmdq->base + GCE_GCTL_VALUE);
>  }
>  
>  u8 cmdq_get_shift_pa(struct mbox_chan *chan)
> @@ -140,16 +141,10 @@ static void cmdq_thread_resume(struct cmdq_thread *thread)
>  static void cmdq_init(struct cmdq *cmdq)
>  {
>  	int i;
> -	u32 gctl_regval = 0;
>  
>  	WARN_ON(clk_bulk_enable(cmdq->pdata->gce_num, cmdq->clocks));
> -	if (cmdq->pdata->control_by_sw)
> -		gctl_regval = GCE_CTRL_BY_SW;
> -	if (cmdq->pdata->sw_ddr_en)
> -		gctl_regval |= GCE_DDR_EN;
>  
> -	if (gctl_regval)
> -		writel(gctl_regval, cmdq->base + GCE_GCTL_VALUE);
> +	cmdq_gctl_value_toggle(cmdq, true);
>  
>  	writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + CMDQ_THR_SLOT_CYCLES);
>  	for (i = 0; i <= CMDQ_MAX_EVENT; i++)
> @@ -315,14 +310,21 @@ static irqreturn_t cmdq_irq_handler(int irq, void *dev)
>  static int cmdq_runtime_resume(struct device *dev)
>  {
>  	struct cmdq *cmdq = dev_get_drvdata(dev);
> +	int ret;
>  
> -	return clk_bulk_enable(cmdq->pdata->gce_num, cmdq->clocks);
> +	ret = clk_bulk_enable(cmdq->pdata->gce_num, cmdq->clocks);
> +	if (ret)
> +		return ret;
> +
> +	cmdq_gctl_value_toggle(cmdq, true);
> +	return 0;
>  }
>  
>  static int cmdq_runtime_suspend(struct device *dev)
>  {
>  	struct cmdq *cmdq = dev_get_drvdata(dev);
>  
> +	cmdq_gctl_value_toggle(cmdq, false);
>  	clk_bulk_disable(cmdq->pdata->gce_num, cmdq->clocks);
>  	return 0;
>  }
> @@ -347,9 +349,6 @@ static int cmdq_suspend(struct device *dev)
>  	if (task_running)
>  		dev_warn(dev, "exist running task(s) in suspend\n");
>  
> -	if (cmdq->pdata->sw_ddr_en)
> -		cmdq_sw_ddr_enable(cmdq, false);
> -
>  	return pm_runtime_force_suspend(dev);
>  }
>  
> @@ -360,9 +359,6 @@ static int cmdq_resume(struct device *dev)
>  	WARN_ON(pm_runtime_force_resume(dev));
>  	cmdq->suspended = false;
>  
> -	if (cmdq->pdata->sw_ddr_en)
> -		cmdq_sw_ddr_enable(cmdq, true);
> -
>  	return 0;
>  }
>  
> @@ -370,9 +366,6 @@ static void cmdq_remove(struct platform_device *pdev)
>  {
>  	struct cmdq *cmdq = platform_get_drvdata(pdev);
>  
> -	if (cmdq->pdata->sw_ddr_en)
> -		cmdq_sw_ddr_enable(cmdq, false);
> -
>  	if (!IS_ENABLED(CONFIG_PM))
>  		cmdq_runtime_suspend(&pdev->dev);
>  


  reply	other threads:[~2025-02-24  6:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24  5:01 Jason-JH Lin
2025-02-24  6:04 ` CK Hu (胡俊光) [this message]
2025-02-24  9:57   ` Jason-JH Lin (林睿祥)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3077494e5e989db6e347bc7c681bb584ab20e593.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Jason-JH.Lin@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Singo.Chang@mediatek.com \
    --cc=Sirius.Wang@mediatek.com \
    --cc=Xavier.Chang@mediatek.com \
    --cc=Xiandong.Wang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=treapking@chromium.org \
    --cc=wenst@chromium.org \
    --cc=yongqiang.niu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®