mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/7] remoteproc: imx: use function hooks in SoC data
Date: Mon,  5 Oct 2020 11:53:42 +0200	[thread overview]
Message-ID: <20201005095346.27957-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20201005095346.27957-1-s.hauer@pengutronix.de>

Replace the register offset/masks/values in driver data with function
hooks to prepare the driver for adding SoCs that do not fit into this
one-register-write scheme.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/remoteproc/imx_rproc.c | 79 +++++++++++++++++++++-------------
 1 file changed, 48 insertions(+), 31 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index fb27d25d8e..86eba4fcd4 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -43,9 +43,6 @@
 #define IMX6SX_SW_M4C_NON_SCLR_RST	BIT(4)
 #define IMX6SX_SW_M4C_RST		BIT(3)
 
-#define IMX6SX_M4_START			(IMX6SX_ENABLE_M4 | IMX6SX_SW_M4P_RST \
-					 | IMX6SX_SW_M4C_RST)
-#define IMX6SX_M4_STOP			IMX6SX_SW_M4C_NON_SCLR_RST
 #define IMX6SX_M4_RST_MASK		(IMX6SX_ENABLE_M4 | IMX6SX_SW_M4P_RST \
 					 | IMX6SX_SW_M4C_NON_SCLR_RST \
 					 | IMX6SX_SW_M4C_RST)
@@ -77,12 +74,10 @@ struct imx_rproc_att {
 };
 
 struct imx_rproc_dcfg {
-	u32				src_reg;
-	u32				src_mask;
-	u32				src_start;
-	u32				src_stop;
 	const struct imx_rproc_att	*att;
 	size_t				att_size;
+	int (*rproc_start)(struct rproc *rproc);
+	int (*rproc_stop)(struct rproc *rproc);
 };
 
 struct imx_rproc {
@@ -144,52 +139,74 @@ static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
 	{ 0x80000000, 0x80000000, 0x60000000, 0 },
 };
 
+static int imx6sx_rproc_start(struct rproc *rproc)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	return regmap_update_bits(priv->regmap,
+			IMX6SX_SRC_SCR,
+			IMX6SX_M4_RST_MASK,
+			IMX6SX_ENABLE_M4 | IMX6SX_SW_M4P_RST | IMX6SX_SW_M4C_RST);
+}
+
+static int imx6sx_rproc_stop(struct rproc *rproc)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	return regmap_update_bits(priv->regmap,
+			IMX6SX_SRC_SCR,
+			IMX6SX_M4_RST_MASK,
+			IMX6SX_SW_M4C_NON_SCLR_RST);
+}
+
+static int imx7d_rproc_start(struct rproc *rproc)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	return regmap_update_bits(priv->regmap,
+			IMX7D_SRC_SCR,
+			IMX7D_M4_RST_MASK,
+			IMX7D_M4_START);
+}
+
+static int imx7d_rproc_stop(struct rproc *rproc)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	return regmap_update_bits(priv->regmap,
+			IMX7D_SRC_SCR,
+			IMX7D_M4_RST_MASK,
+			IMX7D_M4_STOP);
+}
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
-	.src_reg	= IMX6SX_SRC_SCR,
-	.src_mask	= IMX6SX_M4_RST_MASK,
-	.src_start	= IMX6SX_M4_START,
-	.src_stop	= IMX6SX_M4_STOP,
 	.att		= imx_rproc_att_imx6sx,
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx6sx),
+	.rproc_start	= imx6sx_rproc_start,
+	.rproc_stop	= imx6sx_rproc_stop,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
-	.src_reg	= IMX7D_SRC_SCR,
-	.src_mask	= IMX7D_M4_RST_MASK,
-	.src_start	= IMX7D_M4_START,
-	.src_stop	= IMX7D_M4_STOP,
 	.att		= imx_rproc_att_imx7d,
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx7d),
+	.rproc_start	= imx7d_rproc_start,
+	.rproc_stop	= imx7d_rproc_stop,
 };
 
 static int imx_rproc_start(struct rproc *rproc)
 {
 	struct imx_rproc *priv = rproc->priv;
 	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
-	struct device_d *dev = priv->dev;
-	int ret;
-
-	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
-				 dcfg->src_mask, dcfg->src_start);
-	if (ret)
-		dev_err(dev, "Failed to enable M4!\n");
 
-	return ret;
+	return dcfg->rproc_start(rproc);
 }
 
 static int imx_rproc_stop(struct rproc *rproc)
 {
 	struct imx_rproc *priv = rproc->priv;
 	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
-	struct device_d *dev = priv->dev;
-	int ret;
-
-	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
-				 dcfg->src_mask, dcfg->src_stop);
-	if (ret)
-		dev_err(dev, "Failed to stop M4!\n");
 
-	return ret;
+	return dcfg->rproc_stop(rproc);
 }
 
 static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-10-05  9:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05  9:53 [PATCH 0/7] remoteproc: Add i.MX8M Cortex-M[47] support Sascha Hauer
2020-10-05  9:53 ` [PATCH 1/7] remoteproc: imx: Fix off-by-one error Sascha Hauer
2020-10-05 12:23   ` Lucas Stach
2020-10-07  7:06     ` Sascha Hauer
2020-10-05  9:53 ` [PATCH 2/7] remoteproc: imx: Change SoC order in code Sascha Hauer
2020-10-05  9:53 ` Sascha Hauer [this message]
2020-10-05  9:53 ` [PATCH 4/7] remoteproc: imx: Add i.MX8M support Sascha Hauer
2020-10-05  9:53 ` [PATCH 5/7] clk: i.MX8MQ: Add Cortex-M4 clk Sascha Hauer
2020-10-05  9:53 ` [PATCH 6/7] ARM: dts: i.MX8MQ: Add Cortex-M4 Coprocessor node Sascha Hauer
2020-10-05 12:05   ` Rouven Czerwinski
2020-10-07  7:07     ` Sascha Hauer
2020-10-05  9:53 ` [PATCH 7/7] ARM: dts: i.MX8MP: Add Cortex-M7 " Sascha Hauer

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=20201005095346.27957-4-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --subject='Re: [PATCH 3/7] remoteproc: imx: use function hooks in SoC data' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox