From 1ae680bbe77fe124916bd28a1dd6548847c56914 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Fri, 9 Jan 2026 20:08:05 +0800 Subject: [PATCH] remoteproc: imx_rproc: Add support for System Manager CPU API When the System Manager configuration places the M7 core in the same Logical Machine(LM) as the A55 cores (M7 LM ID equals A55 LM ID), Linux can control M7 using the CPU protocol API. For more details, see the previous patch that adds LMM API support. Changes include: - Introduce imx_rproc_ops_sm_cpu for CPU API operations. - Reuse imx_rproc_sm_detect_mode to detect shared LM and set priv->ops to imx_rproc_ops_sm_cpu. - Implement imx_rproc_sm_cpu_{start,stop} to handle M7 start and stop. Signed-off-by: Peng Fan Reviewed-by: Daniel Baluta Link: https://lore.kernel.org/r/20260109-imx95-rproc-2026-1-8-v6-5-d2fefb36263d@nxp.com Signed-off-by: Mathieu Poirier --- drivers/remoteproc/imx_rproc.c | 35 ++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index b254045d45ea..09f168d9ebbe 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -102,6 +102,7 @@ static void imx_rproc_free_mbox(void *data); /* Forward declarations for platform operations */ static const struct imx_rproc_plat_ops imx_rproc_ops_sm_lmm; +static const struct imx_rproc_plat_ops imx_rproc_ops_sm_cpu; struct imx_rproc { struct device *dev; @@ -326,6 +327,21 @@ static int imx_rproc_scu_api_start(struct rproc *rproc) return imx_sc_pm_cpu_start(priv->ipc_handle, priv->rsrc_id, true, priv->entry); } +static int imx_rproc_sm_cpu_start(struct rproc *rproc) +{ + struct imx_rproc *priv = rproc->priv; + const struct imx_rproc_dcfg *dcfg = priv->dcfg; + int ret; + + ret = scmi_imx_cpu_reset_vector_set(dcfg->cpuid, 0, true, false, false); + if (ret) { + dev_err(priv->dev, "Failed to set reset vector cpuid(%u): %d\n", dcfg->cpuid, ret); + return ret; + } + + return scmi_imx_cpu_start(dcfg->cpuid, true); +} + static int imx_rproc_sm_lmm_start(struct rproc *rproc) { struct imx_rproc *priv = rproc->priv; @@ -409,6 +425,14 @@ static int imx_rproc_scu_api_stop(struct rproc *rproc) return imx_sc_pm_cpu_start(priv->ipc_handle, priv->rsrc_id, false, priv->entry); } +static int imx_rproc_sm_cpu_stop(struct rproc *rproc) +{ + struct imx_rproc *priv = rproc->priv; + const struct imx_rproc_dcfg *dcfg = priv->dcfg; + + return scmi_imx_cpu_start(dcfg->cpuid, false); +} + static int imx_rproc_sm_lmm_stop(struct rproc *rproc) { struct imx_rproc *priv = rproc->priv; @@ -1129,8 +1153,9 @@ static int imx_rproc_sm_detect_mode(struct rproc *rproc) * If no, use Logical Machine API to manage M7. */ if (dcfg->lmid == info.lmid) { - dev_err(dev, "CPU Protocol OPS is not supported\n"); - return -EOPNOTSUPP; + priv->ops = &imx_rproc_ops_sm_cpu; + dev_info(dev, "Using CPU Protocol OPS\n"); + return 0; } priv->ops = &imx_rproc_ops_sm_lmm; @@ -1321,6 +1346,12 @@ static const struct imx_rproc_plat_ops imx_rproc_ops_sm_lmm = { .stop = imx_rproc_sm_lmm_stop, }; +static const struct imx_rproc_plat_ops imx_rproc_ops_sm_cpu = { + .detect_mode = imx_rproc_sm_detect_mode, + .start = imx_rproc_sm_cpu_start, + .stop = imx_rproc_sm_cpu_stop, +}; + static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mn_mmio = { .src_reg = IMX7D_SRC_SCR, .src_mask = IMX7D_M4_RST_MASK, -- 2.47.3