Skip to content

Commit d5eb4d5

Browse files
MrVanmathieupoirier
authored andcommitted
remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API switch case
Introduce imx_dsp_rproc_scu_api_{start, stop, detect_mode}() helper functions for i.MX variants using IMX_RPROC_SCU_API to manage remote processors. Allows the removal of the IMX_RPROC_SCU_API 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-9-adafd342d07b@nxp.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent 9f356d1 commit d5eb4d5

2 files changed

Lines changed: 29 additions & 21 deletions

File tree

drivers/remoteproc/imx_dsp_rproc.c

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,13 @@ static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
346346
return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
347347
}
348348

349+
static int imx_dsp_rproc_scu_api_start(struct rproc *rproc)
350+
{
351+
struct imx_dsp_rproc *priv = rproc->priv;
352+
353+
return imx_sc_pm_cpu_start(priv->ipc_handle, IMX_SC_R_DSP, true, rproc->bootaddr);
354+
}
355+
349356
/*
350357
* Start function for rproc_ops
351358
*
@@ -368,12 +375,6 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
368375
}
369376

370377
switch (dcfg->method) {
371-
case IMX_RPROC_SCU_API:
372-
ret = imx_sc_pm_cpu_start(priv->ipc_handle,
373-
IMX_SC_R_DSP,
374-
true,
375-
rproc->bootaddr);
376-
break;
377378
case IMX_RPROC_RESET_CONTROLLER:
378379
ret = reset_control_deassert(priv->run_stall);
379380
break;
@@ -398,6 +399,13 @@ static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
398399
return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop);
399400
}
400401

402+
static int imx_dsp_rproc_scu_api_stop(struct rproc *rproc)
403+
{
404+
struct imx_dsp_rproc *priv = rproc->priv;
405+
406+
return imx_sc_pm_cpu_start(priv->ipc_handle, IMX_SC_R_DSP, false, rproc->bootaddr);
407+
}
408+
401409
/*
402410
* Stop function for rproc_ops
403411
* It clears the REMOTE_IS_READY flags
@@ -421,12 +429,6 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
421429
}
422430

423431
switch (dcfg->method) {
424-
case IMX_RPROC_SCU_API:
425-
ret = imx_sc_pm_cpu_start(priv->ipc_handle,
426-
IMX_SC_R_DSP,
427-
false,
428-
rproc->bootaddr);
429-
break;
430432
case IMX_RPROC_RESET_CONTROLLER:
431433
ret = reset_control_assert(priv->run_stall);
432434
break;
@@ -1055,6 +1057,13 @@ static int imx_dsp_rproc_mmio_detect_mode(struct rproc *rproc)
10551057
return 0;
10561058
}
10571059

1060+
static int imx_dsp_rproc_scu_api_detect_mode(struct rproc *rproc)
1061+
{
1062+
struct imx_dsp_rproc *priv = rproc->priv;
1063+
1064+
return imx_scu_get_handle(&priv->ipc_handle);
1065+
}
1066+
10581067
/**
10591068
* imx_dsp_rproc_detect_mode() - detect DSP control mode
10601069
* @priv: private data pointer
@@ -1078,11 +1087,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
10781087
return dcfg->ops->detect_mode(priv->rproc);
10791088

10801089
switch (dsp_dcfg->dcfg->method) {
1081-
case IMX_RPROC_SCU_API:
1082-
ret = imx_scu_get_handle(&priv->ipc_handle);
1083-
if (ret)
1084-
return ret;
1085-
break;
10861090
case IMX_RPROC_RESET_CONTROLLER:
10871091
priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
10881092
if (IS_ERR(priv->run_stall)) {
@@ -1320,6 +1324,12 @@ static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_mmio = {
13201324
.detect_mode = imx_dsp_rproc_mmio_detect_mode,
13211325
};
13221326

1327+
static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_scu_api = {
1328+
.start = imx_dsp_rproc_scu_api_start,
1329+
.stop = imx_dsp_rproc_scu_api_stop,
1330+
.detect_mode = imx_dsp_rproc_scu_api_detect_mode,
1331+
};
1332+
13231333
/* Specific configuration for i.MX8MP */
13241334
static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
13251335
.att = imx_dsp_rproc_att_imx8mp,
@@ -1352,7 +1362,7 @@ static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
13521362
static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
13531363
.att = imx_dsp_rproc_att_imx8qxp,
13541364
.att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
1355-
.method = IMX_RPROC_SCU_API,
1365+
.ops = &imx_dsp_rproc_ops_scu_api,
13561366
};
13571367

13581368
static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
@@ -1363,7 +1373,7 @@ static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
13631373
static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
13641374
.att = imx_dsp_rproc_att_imx8qm,
13651375
.att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
1366-
.method = IMX_RPROC_SCU_API,
1376+
.ops = &imx_dsp_rproc_ops_scu_api,
13671377
};
13681378

13691379
static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {

drivers/remoteproc/imx_rproc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ enum imx_rproc_method {
2020
IMX_RPROC_NONE,
2121
/* Through ARM SMCCC */
2222
IMX_RPROC_SMC,
23-
/* Through System Control Unit API */
24-
IMX_RPROC_SCU_API,
2523
/* Through Reset Controller API */
2624
IMX_RPROC_RESET_CONTROLLER,
2725
};

0 commit comments

Comments
 (0)