From: Peng Fan <peng.fan@nxp.com>
To: Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
Frank Li <frank.li@nxp.com>
Cc: Hiago De Franco <hiago.franco@toradex.com>,
linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
Frank Li <Frank.Li@nxp.com>
Subject: [PATCH v2 1/6] remoteproc: imx_rproc: Introduce start/stop/detect_mode ops for imx_rproc_dcfg
Date: Wed, 10 Sep 2025 15:11:45 +0800 [thread overview]
Message-ID: <20250910-imx-rproc-cleanup-v2-1-10386685b8a9@nxp.com> (raw)
In-Reply-To: <20250910-imx-rproc-cleanup-v2-0-10386685b8a9@nxp.com>
Simplify the logic in imx_rproc_start(), imx_rproc_stop() and
imx_rproc_detect_mode(), introduce start, stop and detect_mode ops for the
imx_rproc_dcfg structure. 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: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_rproc.c | 15 +++++++++++++++
drivers/remoteproc/imx_rproc.h | 7 +++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index a6eef0080ca9e46efe60dcb3878b9efdbdc0f08e..5cdc5045e57566e817170ed3c708dad6108d2e46 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -376,6 +376,11 @@ static int imx_rproc_start(struct rproc *rproc)
if (ret)
return ret;
+ if (dcfg->ops && dcfg->ops->start) {
+ ret = dcfg->ops->start(rproc);
+ goto start_ret;
+ }
+
switch (dcfg->method) {
case IMX_RPROC_MMIO:
if (priv->gpr) {
@@ -398,6 +403,7 @@ static int imx_rproc_start(struct rproc *rproc)
return -EOPNOTSUPP;
}
+start_ret:
if (ret)
dev_err(dev, "Failed to enable remote core!\n");
@@ -412,6 +418,11 @@ static int imx_rproc_stop(struct rproc *rproc)
struct arm_smccc_res res;
int ret;
+ if (dcfg->ops && dcfg->ops->stop) {
+ ret = dcfg->ops->stop(rproc);
+ goto stop_ret;
+ }
+
switch (dcfg->method) {
case IMX_RPROC_MMIO:
if (priv->gpr) {
@@ -440,6 +451,7 @@ static int imx_rproc_stop(struct rproc *rproc)
return -EOPNOTSUPP;
}
+stop_ret:
if (ret)
dev_err(dev, "Failed to stop remote core\n");
else
@@ -933,6 +945,9 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
u32 val;
u8 pt;
+ if (dcfg->ops && dcfg->ops->detect_mode)
+ return dcfg->ops->detect_mode(priv->rproc);
+
switch (dcfg->method) {
case IMX_RPROC_NONE:
priv->rproc->state = RPROC_DETACHED;
diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
index cfd38d37e1467d1d9e6f89be146c0b53262b92a0..3a9adaaf048b396102feeb45488cd2ff125a807a 100644
--- a/drivers/remoteproc/imx_rproc.h
+++ b/drivers/remoteproc/imx_rproc.h
@@ -31,6 +31,12 @@ enum imx_rproc_method {
/* dcfg flags */
#define IMX_RPROC_NEED_SYSTEM_OFF BIT(0)
+struct imx_rproc_plat_ops {
+ int (*start)(struct rproc *rproc);
+ int (*stop)(struct rproc *rproc);
+ int (*detect_mode)(struct rproc *rproc);
+};
+
struct imx_rproc_dcfg {
u32 src_reg;
u32 src_mask;
@@ -42,6 +48,7 @@ struct imx_rproc_dcfg {
size_t att_size;
enum imx_rproc_method method;
u32 flags;
+ const struct imx_rproc_plat_ops *ops;
};
#endif /* _IMX_RPROC_H */
--
2.37.1
next prev parent reply other threads:[~2025-09-10 7:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 7:11 [PATCH v2 0/6] remoteproc: imx_proc: Simplify driver by removing the switch-case Peng Fan
2025-09-10 7:11 ` Peng Fan [this message]
2025-09-10 7:11 ` [PATCH v2 2/6] remoteproc: imx_rproc: Move imx_rproc_dcfg closer to imx_rproc_of_match Peng Fan
2025-09-10 7:11 ` [PATCH v2 3/6] remoteproc: imx_rproc: Simplify IMX_RPROC_MMIO switch case Peng Fan
2025-09-10 7:11 ` [PATCH v2 4/6] remoteproc: imx_rproc: Simplify IMX_RPROC_SCU_API " Peng Fan
2025-09-10 7:11 ` [PATCH v2 5/6] remoteproc: imx_rproc: Simplify IMX_RPROC_SMC " Peng Fan
2025-09-10 7:11 ` [PATCH v2 6/6] remoteproc: imx_rproc: Clean up after ops introduction Peng Fan
2025-09-10 15:53 ` Frank Li
2025-09-11 1:13 ` Peng Fan
2025-09-12 6:11 ` Peng Fan
2025-09-12 8:58 ` Daniel Baluta
2025-09-12 14:14 ` Mathieu Poirier
2025-09-12 14:37 ` Frank Li
2025-09-15 16:27 ` [PATCH v2 0/6] remoteproc: imx_proc: Simplify driver by removing the switch-case Mathieu Poirier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250910-imx-rproc-cleanup-v2-1-10386685b8a9@nxp.com \
--to=peng.fan@nxp.com \
--cc=andersson@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=festevam@gmail.com \
--cc=frank.li@nxp.com \
--cc=hiago.franco@toradex.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®