public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Peng Fan <peng.fan@nxp.com>
Cc: Bjorn Andersson <andersson@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Shengjiu Wang <shengjiu.wang@nxp.com>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	Iuliana Prodan <iuliana.prodan@nxp.com>,
	linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case
Date: Fri, 31 Oct 2025 15:09:17 -0400	[thread overview]
Message-ID: <aQUJEwjl1xx20dtQ@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20251031-imx-dsp-2025-10-31-v1-8-282f66f55804@nxp.com>

On Fri, Oct 31, 2025 at 05:08:37PM +0800, Peng Fan wrote:
> Introduce imx_dsp_rproc_mmio_{start, stop, detect_mode}() helper functions
> for i.MX variants using IMX_RPROC_MMIO to manage remote processors.
>
> Allows the removal of the IMX_RPROC_MMIO switch-case blocks from
> imx_dsp_rproc_[start,stop,detect_mode](), resulting in cleaner and more
> maintainable code.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_dsp_rproc.c | 63 +++++++++++++++++++++++++-------------
>  drivers/remoteproc/imx_rproc.h     |  2 --
>  2 files changed, 42 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index f28d25cab3f1d89e5cde37a04b528870a59abeed..456a46f163d3d823a25d16d11fb79fa9fceb2ddb 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -338,6 +338,15 @@ static int imx_dsp_rproc_handle_rsc(struct rproc *rproc, u32 rsc_type,
>  	return RSC_HANDLED;
>  }
>
> +static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
> +{
> +	struct imx_dsp_rproc *priv = rproc->priv;
> +	const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
> +	const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
> +
> +	return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
> +}
> +
>  /*
>   * Start function for rproc_ops
>   *
> @@ -360,12 +369,6 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
>  	}
>
>  	switch (dcfg->method) {
> -	case IMX_RPROC_MMIO:
> -		ret = regmap_update_bits(priv->regmap,
> -					 dcfg->src_reg,
> -					 dcfg->src_mask,
> -					 dcfg->src_start);
> -		break;
>  	case IMX_RPROC_SCU_API:
>  		ret = imx_sc_pm_cpu_start(priv->ipc_handle,
>  					  IMX_SC_R_DSP,
> @@ -388,6 +391,15 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
>  	return ret;
>  }
>
> +static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
> +{
> +	struct imx_dsp_rproc *priv = rproc->priv;
> +	const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
> +	const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;

can you add helper macro convert rproc to dcfg to avoid duplicate above
3 line codes.

Frank
> +
> +	return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop);
> +}
> +
>  /*
>   * Stop function for rproc_ops
>   * It clears the REMOTE_IS_READY flags
> @@ -411,10 +423,6 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
>  	}
>
>  	switch (dcfg->method) {
> -	case IMX_RPROC_MMIO:
> -		ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask,
> -					 dcfg->src_stop);
> -		break;
>  	case IMX_RPROC_SCU_API:
>  		ret = imx_sc_pm_cpu_start(priv->ipc_handle,
>  					  IMX_SC_R_DSP,
> @@ -1032,6 +1040,23 @@ static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
>  	return devm_pm_domain_attach_list(dev, NULL, &priv->pd_list);
>  }
>
> +static int imx_dsp_rproc_mmio_detect_mode(struct rproc *rproc)
> +{
> +	struct imx_dsp_rproc *priv = rproc->priv;
> +	struct device *dev = rproc->dev.parent;
> +	struct regmap *regmap;
> +
> +	regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,dsp-ctrl");
> +	if (IS_ERR(regmap)) {
> +		dev_err(dev, "failed to find syscon\n");
> +		return PTR_ERR(regmap);
> +	}
> +
> +	priv->regmap = regmap;
> +
> +	return 0;
> +}
> +
>  /**
>   * imx_dsp_rproc_detect_mode() - detect DSP control mode
>   * @priv: private data pointer
> @@ -1049,7 +1074,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
>  	const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
>  	const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
>  	struct device *dev = priv->rproc->dev.parent;
> -	struct regmap *regmap;
>  	int ret = 0;
>
>  	if (dcfg->ops && dcfg->ops->detect_mode)
> @@ -1061,15 +1085,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
>  		if (ret)
>  			return ret;
>  		break;
> -	case IMX_RPROC_MMIO:
> -		regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,dsp-ctrl");
> -		if (IS_ERR(regmap)) {
> -			dev_err(dev, "failed to find syscon\n");
> -			return PTR_ERR(regmap);
> -		}
> -
> -		priv->regmap = regmap;
> -		break;
>  	case IMX_RPROC_RESET_CONTROLLER:
>  		priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
>  		if (IS_ERR(priv->run_stall)) {
> @@ -1301,6 +1316,12 @@ static const struct dev_pm_ops imx_dsp_rproc_pm_ops = {
>  	RUNTIME_PM_OPS(imx_dsp_runtime_suspend, imx_dsp_runtime_resume, NULL)
>  };
>
> +static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_mmio = {
> +	.start		= imx_dsp_rproc_mmio_start,
> +	.stop		= imx_dsp_rproc_mmio_stop,
> +	.detect_mode	= imx_dsp_rproc_mmio_detect_mode,
> +};
> +
>  /* Specific configuration for i.MX8MP */
>  static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
>  	.att		= imx_dsp_rproc_att_imx8mp,
> @@ -1321,7 +1342,7 @@ static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
>  	.src_stop	= IMX8ULP_SYSCTRL0_DSP_STALL,
>  	.att		= imx_dsp_rproc_att_imx8ulp,
>  	.att_size	= ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
> -	.method		= IMX_RPROC_MMIO,
> +	.ops		= &imx_dsp_rproc_ops_mmio,
>  };
>
>  static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
> diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
> index aeed08bdfb5619c7afd7201589f417cfd6745818..912827c39c0dedeed76c13740efd42a8e7cf9c45 100644
> --- a/drivers/remoteproc/imx_rproc.h
> +++ b/drivers/remoteproc/imx_rproc.h
> @@ -18,8 +18,6 @@ struct imx_rproc_att {
>  /* Remote core start/stop method */
>  enum imx_rproc_method {
>  	IMX_RPROC_NONE,
> -	/* Through syscon regmap */
> -	IMX_RPROC_MMIO,
>  	/* Through ARM SMCCC */
>  	IMX_RPROC_SMC,
>  	/* Through System Control Unit API */
>
> --
> 2.37.1
>


  reply	other threads:[~2025-10-31 19:10 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31  9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
2025-10-31  9:08 ` [PATCH 01/11] remoteproc: imx_dsp_rproc: simplify power domain attach and error handling Peng Fan
2025-10-31 18:46   ` Frank Li
2025-10-31  9:08 ` [PATCH 02/11] remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper Peng Fan
2025-10-31 18:47   ` Frank Li
2025-10-31  9:08 ` [PATCH 03/11] remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper Peng Fan
2025-10-31 18:49   ` Frank Li
2025-11-05  9:24     ` Daniel Baluta
2025-10-31  9:08 ` [PATCH 04/11] remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors Peng Fan
2025-10-31 18:50   ` Frank Li
2025-10-31  9:08 ` [PATCH 05/11] remoteproc: imx_dsp_rproc: Drop extra space Peng Fan
2025-10-31 18:51   ` Frank Li
2025-10-31  9:08 ` [PATCH 06/11] remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg Peng Fan
2025-10-31 19:04   ` Frank Li
2025-11-04  4:24     ` Peng Fan
2025-10-31  9:08 ` [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match Peng Fan
2025-10-31 19:05   ` Frank Li
2025-10-31  9:08 ` [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case Peng Fan
2025-10-31 19:09   ` Frank Li [this message]
2025-11-04  4:25     ` Peng Fan
2025-10-31  9:08 ` [PATCH 09/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API " Peng Fan
2025-10-31 19:12   ` Frank Li
2025-10-31  9:08 ` [PATCH 10/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER " Peng Fan
2025-10-31 19:13   ` Frank Li
2025-10-31  9:08 ` [PATCH 11/11] remoteproc: imx_rproc: Remove enum imx_rproc_method Peng Fan
2025-10-31 19:15   ` Frank Li
2025-11-05  8:04 ` [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Shengjiu Wang
2025-11-05  9:31 ` Daniel Baluta
  -- strict thread matches above, loose matches on Subject: below --
2025-11-06  3:30 Peng Fan
2025-11-06  3:30 ` [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case Peng Fan
2025-11-06 16:12   ` Frank Li

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=aQUJEwjl1xx20dtQ@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=andersson@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=iuliana.prodan@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=peng.fan@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=shengjiu.wang@nxp.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