remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg

Allow each platform to provide its own implementation of start/stop/
detect_mode operations, and prepare to eliminate the need for multiple
switch-case statements.

Improve code readability and maintainability by encapsulating
platform-specific behavior.

No functional changes.

Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Frank Li <Frank.Li@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-6-adafd342d07b@nxp.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
This commit is contained in:
Peng Fan 2025-11-19 12:21:51 +08:00 committed by Mathieu Poirier
parent 8049dc7b63
commit 606e481169

View File

@ -404,6 +404,11 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
struct device *dev = rproc->dev.parent;
int ret;
if (dcfg->ops && dcfg->ops->start) {
ret = dcfg->ops->start(rproc);
goto start_ret;
}
switch (dcfg->method) {
case IMX_RPROC_MMIO:
ret = regmap_update_bits(priv->regmap,
@ -424,6 +429,7 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
return -EOPNOTSUPP;
}
start_ret:
if (ret)
dev_err(dev, "Failed to enable remote core!\n");
else if (priv->flags & WAIT_FW_READY)
@ -449,6 +455,11 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
return 0;
}
if (dcfg->ops && dcfg->ops->stop) {
ret = dcfg->ops->stop(rproc);
goto stop_ret;
}
switch (dcfg->method) {
case IMX_RPROC_MMIO:
ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask,
@ -467,6 +478,7 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
return -EOPNOTSUPP;
}
stop_ret:
if (ret)
dev_err(dev, "Failed to stop remote core\n");
else
@ -1085,10 +1097,14 @@ static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
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)
return dcfg->ops->detect_mode(priv->rproc);
switch (dsp_dcfg->dcfg->method) {
case IMX_RPROC_SCU_API:
ret = imx_scu_get_handle(&priv->ipc_handle);