mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 09/15] reset: imx7: Add plubming to support multiple IP variants
Date: Thu, 31 Jan 2019 18:31:27 -0800	[thread overview]
Message-ID: <20190201023133.1078-10-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190201023133.1078-1-andrew.smirnov@gmail.com>

Port of a Linux commit cffaab878178c7842ab38690070d665adb3f41fd

  In order to enable supporting i.MX8MQ with this driver, convert it to
  expect variant specific bits to be passed via driver data.

  Cc: p.zabel@pengutronix.de
  Cc: Fabio Estevam <fabio.estevam@nxp.com>
  Cc: cphealy@gmail.com
  Cc: l.stach@pengutronix.de
  Cc: Leonard Crestez <leonard.crestez@nxp.com>
  Cc: "A.s. Dong" <aisheng.dong@nxp.com>
  Cc: Richard Zhu <hongxing.zhu@nxp.com>
  Cc: Rob Herring <robh@kernel.org>
  Cc: devicetree@vger.kernel.org
  Cc: linux-imx@nxp.com
  Cc: linux-arm-kernel@lists.infradead.org
  Cc: linux-kernel@vger.kernel.org
  Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/reset/reset-imx7.c | 50 +++++++++++++++++++++++++++-----------
 1 file changed, 36 insertions(+), 14 deletions(-)

diff --git a/drivers/reset/reset-imx7.c b/drivers/reset/reset-imx7.c
index 6dc5de16a..f723dc28e 100644
--- a/drivers/reset/reset-imx7.c
+++ b/drivers/reset/reset-imx7.c
@@ -22,10 +22,22 @@
 #include <linux/reset-controller.h>
 #include <mfd/syscon.h>
 #include <regmap.h>
+#include <of_device.h>
+
+struct imx7_src_signal {
+	unsigned int offset, bit;
+};
+
+struct imx7_src_variant {
+	const struct imx7_src_signal *signals;
+	unsigned int signals_num;
+	struct reset_control_ops ops;
+};
 
 struct imx7_src {
 	struct reset_controller_dev rcdev;
 	struct regmap *regmap;
+	const struct imx7_src_signal *signals;
 };
 
 enum imx7_src_registers {
@@ -40,9 +52,14 @@ enum imx7_src_registers {
 	SRC_DDRC_RCR		= 0x1000,
 };
 
-struct imx7_src_signal {
-	unsigned int offset, bit;
-};
+static int imx7_reset_update(struct imx7_src *imx7src,
+			     unsigned long id, unsigned int value)
+{
+	const struct imx7_src_signal *signal = &imx7src->signals[id];
+
+	return regmap_update_bits(imx7src->regmap,
+				  signal->offset, signal->bit, value);
+}
 
 static const struct imx7_src_signal imx7_src_signals[IMX7_RESET_NUM] = {
 	[IMX7_RESET_A7_CORE_POR_RESET0] = { SRC_A7RCR0, BIT(0) },
@@ -81,8 +98,8 @@ static int imx7_reset_set(struct reset_controller_dev *rcdev,
 			  unsigned long id, bool assert)
 {
 	struct imx7_src *imx7src = to_imx7_src(rcdev);
-	const struct imx7_src_signal *signal = &imx7_src_signals[id];
-	unsigned int value = assert ? signal->bit : 0;;
+	const unsigned int bit = imx7src->signals[id].bit;
+	unsigned int value = assert ? bit : 0;
 
 	switch (id) {
 	case IMX7_RESET_PCIEPHY:
@@ -95,12 +112,11 @@ static int imx7_reset_set(struct reset_controller_dev *rcdev,
 		break;
 
 	case IMX7_RESET_PCIE_CTRL_APPS_EN:
-		value = (assert) ? 0 : signal->bit;
+		value = assert ? 0 : bit;
 		break;
 	}
 
-	return regmap_update_bits(imx7src->regmap,
-				  signal->offset, signal->bit, value);
+	return imx7_reset_update(imx7src, id, value);
 }
 
 static int imx7_reset_assert(struct reset_controller_dev *rcdev,
@@ -115,31 +131,37 @@ static int imx7_reset_deassert(struct reset_controller_dev *rcdev,
 	return imx7_reset_set(rcdev, id, false);
 }
 
-static struct reset_control_ops imx7_reset_ops = {
-	.assert		= imx7_reset_assert,
-	.deassert	= imx7_reset_deassert,
+static const struct imx7_src_variant variant_imx7 = {
+	.signals = imx7_src_signals,
+	.signals_num = ARRAY_SIZE(imx7_src_signals),
+	.ops = {
+		.assert   = imx7_reset_assert,
+		.deassert = imx7_reset_deassert,
+	},
 };
 
 static int imx7_reset_probe(struct device_d *dev)
 {
 	struct imx7_src *imx7src;
+	const struct imx7_src_variant *variant = of_device_get_match_data(dev);
 
 	imx7src = xzalloc(sizeof(*imx7src));
+	imx7src->signals = variant->signals;
 	imx7src->regmap = syscon_node_to_regmap(dev->device_node);
 	if (IS_ERR(imx7src->regmap)) {
 		dev_err(dev, "Unable to get imx7-src regmap");
 		return PTR_ERR(imx7src->regmap);
 	}
 
-	imx7src->rcdev.nr_resets = IMX7_RESET_NUM;
-	imx7src->rcdev.ops       = &imx7_reset_ops;
+	imx7src->rcdev.nr_resets = variant->signals_num;
+	imx7src->rcdev.ops       = &variant->ops;
 	imx7src->rcdev.of_node   = dev->device_node;
 
 	return reset_controller_register(&imx7src->rcdev);
 }
 
 static const struct of_device_id imx7_reset_dt_ids[] = {
-	{ .compatible = "fsl,imx7d-src", },
+	{ .compatible = "fsl,imx7d-src", .data = &variant_imx7 },
 	{ /* sentinel */ },
 };
 
-- 
2.20.1


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

  parent reply	other threads:[~2019-02-01  2:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01  2:31 [PATCH 00/15] PCIE support for i.MX8MQ Andrey Smirnov
2019-02-01  2:31 ` [PATCH 01/15] PCI: dwc: Fix pointer width cast problem Andrey Smirnov
2019-02-01  2:31 ` [PATCH 02/15] ARM: aarch64: Add PCI fixups section to linker script Andrey Smirnov
2019-02-01  2:31 ` [PATCH 03/15] soc: imx: gpcv2: use A_CORE instread of A7 for more i.MX platforms Andrey Smirnov
2019-02-01  2:31 ` [PATCH 04/15] soc: imx: gpcv2: make pgc driver more generic for other " Andrey Smirnov
2019-02-01  2:31 ` [PATCH 05/15] soc: imx: gpcv2: Switch to SPDX identifier Andrey Smirnov
2019-02-01  2:31 ` [PATCH 06/15] soc: imx: gpcv2: prefix i.MX7 specific defines Andrey Smirnov
2019-02-01  2:31 ` [PATCH 07/15] soc: imx: gpcv2: add support for i.MX8MQ SoC Andrey Smirnov
2019-02-01  2:31 ` [PATCH 08/15] reset: Constify "ops" in struct reset_controller_dev Andrey Smirnov
2019-02-01  2:31 ` Andrey Smirnov [this message]
2019-02-01  2:31 ` [PATCH 10/15] include: Import dt-bindings/reset/imx8mq-reset.h Andrey Smirnov
2019-02-01  2:31 ` [PATCH 11/15] reset: imx7: Add support for i.MX8MQ IP block variant Andrey Smirnov
2019-02-01  2:31 ` [RFC 12/15] PCI: imx6: Introduce drvdata Andrey Smirnov
2019-02-01  2:31 ` [RFC 13/15] PCI: imx6: Mark PHY functions as i.MX6 specific Andrey Smirnov
2019-02-01  2:31 ` [RFC 14/15] PCI: imx6: Convert DIRECT_SPEED_CHANGE quirk code to use a flag Andrey Smirnov
2019-02-01  2:31 ` [RFC 15/15] PCI: imx6: Add support for i.MX8MQ Andrey Smirnov

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=20190201023133.1078-10-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.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