From: Peng Fan <[email protected]> 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. Reviewed-by: Frank Li <[email protected]> Reviewed-by: Daniel Baluta <[email protected]> Reviewed-by: Shengjiu Wang <[email protected]> Signed-off-by: Peng Fan <[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 91d041c15ac19f527f48c8189421f71fb7c9745e..6237e8db2eff759c2b7fcce5fb4a44e4ebaec8cf 100644 --- a/drivers/remoteproc/imx_dsp_rproc.c +++ b/drivers/remoteproc/imx_dsp_rproc.c @@ -346,6 +346,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; @@ -374,13 +381,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) @@ -399,6 +400,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; @@ -428,13 +436,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) @@ -1057,6 +1059,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; @@ -1080,26 +1096,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] = { @@ -1324,6 +1325,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, @@ -1334,7 +1341,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

