On Fri, Oct 31, 2025 at 05:08:39PM +0800, Peng Fan wrote:
> Introduce imx_dsp_rproc_reset_ctr_{start, stop, detect_mode}() helper
> functions for i.MX variants using IMX_RPROC_RESET_CONTROLLER to manage
> remote processors.
>
> Allows the removal of the IMX_RPROC_RESET_CONTROLLER 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 <[email protected]>
> ---

Reviewed-by: Frank Li <[email protected]>

>  drivers/remoteproc/imx_dsp_rproc.c | 69 
> +++++++++++++++++++++-----------------
>  drivers/remoteproc/imx_rproc.h     |  2 --
>  2 files changed, 38 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c 
> b/drivers/remoteproc/imx_dsp_rproc.c
> index 
> 56e94754d5c5feba112227c45b0f99a4fe868926..009e08df8fd42e1bf6ca00393e940071d33ec518
>  100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -347,6 +347,13 @@ static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
>       return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, 
> dcfg->src_start);
>  }
>
> +static int imx_dsp_rproc_reset_ctrl_start(struct rproc *rproc)
> +{
> +     struct imx_dsp_rproc *priv = rproc->priv;
> +
> +     return reset_control_deassert(priv->run_stall);
> +}
> +
>  static int imx_dsp_rproc_scu_api_start(struct rproc *rproc)
>  {
>       struct imx_dsp_rproc *priv = rproc->priv;
> @@ -375,13 +382,7 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
>               goto start_ret;
>       }
>
> -     switch (dcfg->method) {
> -     case IMX_RPROC_RESET_CONTROLLER:
> -             ret = reset_control_deassert(priv->run_stall);
> -             break;
> -     default:
> -             return -EOPNOTSUPP;
> -     }
> +     return -EOPNOTSUPP;
>
>  start_ret:
>       if (ret)
> @@ -401,6 +402,13 @@ static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
>       return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, 
> dcfg->src_stop);
>  }
>
> +static int imx_dsp_rproc_reset_ctrl_stop(struct rproc *rproc)
> +{
> +     struct imx_dsp_rproc *priv = rproc->priv;
> +
> +     return reset_control_assert(priv->run_stall);
> +}
> +
>  static int imx_dsp_rproc_scu_api_stop(struct rproc *rproc)
>  {
>       struct imx_dsp_rproc *priv = rproc->priv;
> @@ -430,13 +438,7 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
>               goto stop_ret;
>       }
>
> -     switch (dcfg->method) {
> -     case IMX_RPROC_RESET_CONTROLLER:
> -             ret = reset_control_assert(priv->run_stall);
> -             break;
> -     default:
> -             return -EOPNOTSUPP;
> -     }
> +     return -EOPNOTSUPP;
>
>  stop_ret:
>       if (ret)
> @@ -1059,6 +1061,20 @@ static int imx_dsp_rproc_mmio_detect_mode(struct rproc 
> *rproc)
>       return 0;
>  }
>
> +static int imx_dsp_rproc_reset_ctrl_detect_mode(struct rproc *rproc)
> +{
> +     struct imx_dsp_rproc *priv = rproc->priv;
> +     struct device *dev = rproc->dev.parent;
> +
> +     priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
> +     if (IS_ERR(priv->run_stall)) {
> +             dev_err(dev, "Failed to get DSP runstall reset control\n");
> +             return PTR_ERR(priv->run_stall);
> +     }
> +
> +     return 0;
> +}
> +
>  static int imx_dsp_rproc_scu_api_detect_mode(struct rproc *rproc)
>  {
>       struct imx_dsp_rproc *priv = rproc->priv;
> @@ -1082,26 +1098,11 @@ 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;
> -     int ret = 0;
>
>       if (dcfg->ops && dcfg->ops->detect_mode)
>               return dcfg->ops->detect_mode(priv->rproc);
>
> -     switch (dsp_dcfg->dcfg->method) {
> -     case IMX_RPROC_RESET_CONTROLLER:
> -             priv->run_stall = devm_reset_control_get_exclusive(dev, 
> "runstall");
> -             if (IS_ERR(priv->run_stall)) {
> -                     dev_err(dev, "Failed to get DSP runstall reset 
> control\n");
> -                     return PTR_ERR(priv->run_stall);
> -             }
> -             break;
> -     default:
> -             ret = -EOPNOTSUPP;
> -             break;
> -     }
> -
> -     return ret;
> +     return -EOPNOTSUPP;
>  }
>
>  static const char *imx_dsp_clks_names[DSP_RPROC_CLK_MAX] = {
> @@ -1326,6 +1327,12 @@ static const struct imx_rproc_plat_ops 
> imx_dsp_rproc_ops_mmio = {
>       .detect_mode    = imx_dsp_rproc_mmio_detect_mode,
>  };
>
> +static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_reset_ctrl = {
> +     .start          = imx_dsp_rproc_reset_ctrl_start,
> +     .stop           = imx_dsp_rproc_reset_ctrl_stop,
> +     .detect_mode    = imx_dsp_rproc_reset_ctrl_detect_mode,
> +};
> +
>  static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_scu_api = {
>       .start          = imx_dsp_rproc_scu_api_start,
>       .stop           = imx_dsp_rproc_scu_api_stop,
> @@ -1336,7 +1343,7 @@ static const struct imx_rproc_plat_ops 
> imx_dsp_rproc_ops_scu_api = {
>  static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
>       .att            = imx_dsp_rproc_att_imx8mp,
>       .att_size       = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
> -     .method         = IMX_RPROC_RESET_CONTROLLER,
> +     .ops            = &imx_dsp_rproc_ops_reset_ctrl,
>  };
>
>  static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
> diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
> index 
> a6b4625e8be76c6eb6a5d8ef45eb5f3aec5fe375..6a7359f05178a937d02b027fe4166319068bd65c
>  100644
> --- a/drivers/remoteproc/imx_rproc.h
> +++ b/drivers/remoteproc/imx_rproc.h
> @@ -20,8 +20,6 @@ enum imx_rproc_method {
>       IMX_RPROC_NONE,
>       /* Through ARM SMCCC */
>       IMX_RPROC_SMC,
> -     /* Through Reset Controller API */
> -     IMX_RPROC_RESET_CONTROLLER,
>  };
>
>  /* dcfg flags */
>
> --
> 2.37.1
>

Reply via email to