remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER switch case

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 <Frank.Li@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Tested-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20251119-imx-dsp-2025-11-19-v4-10-adafd342d07b@nxp.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
This commit is contained in:
Peng Fan
2025-11-19 12:21:55 +08:00
committed by Mathieu Poirier
parent d5eb4d512f
commit 3f5c1277a9
2 changed files with 38 additions and 33 deletions

View File

@@ -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 = {

View File

@@ -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 */