mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v2 08/10] ARM: i.MX8MP: skov: fixup skov,imx8mp-board-version DT property for the kernel
Date: Mon,  2 Oct 2023 12:16:52 +0200	[thread overview]
Message-ID: <20231002101654.2373000-9-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20231002101654.2373000-1-o.rempel@pengutronix.de>

Fixup Skov specific skov,imx8mp-board-version property for the kernel DT,
to keep it compatible with the imx6 version.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx8mp/board.c | 41 +++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/skov-imx8mp/board.c b/arch/arm/boards/skov-imx8mp/board.c
index 3a1cd83bbd..3b6eb7b080 100644
--- a/arch/arm/boards/skov-imx8mp/board.c
+++ b/arch/arm/boards/skov-imx8mp/board.c
@@ -14,6 +14,13 @@
 #include <mach/imx/generic.h>
 #include <mach/imx/iomux-mx8mp.h>
 
+struct skov_imx8mp_priv {
+	struct device *dev;
+	int variant_id;
+};
+
+static struct skov_imx8mp_priv *skov_imx8mp_priv;
+
 #define GPIO_HW_VARIANT  {\
 	{IMX_GPIO_NR(1, 8), GPIOF_DIR_IN | GPIOF_ACTIVE_HIGH, "var0"}, \
 	{IMX_GPIO_NR(1, 9), GPIOF_DIR_IN | GPIOF_ACTIVE_HIGH, "var1"}, \
@@ -78,6 +85,22 @@ static const struct board_description imx8mp_variants[] = {
 	},
 };
 
+static int skov_imx8mp_fixup(struct device_node *root, void *data)
+{
+	struct device_node *chosen = of_create_node(root, "/chosen");
+	const char *of_board = "skov,imx8mp-board-version";
+	struct skov_imx8mp_priv *priv = data;
+	struct device *dev = priv->dev;
+	int ret;
+
+	ret = of_property_write_u32(chosen, of_board, priv->variant_id);
+	if (ret)
+		dev_err(dev,  "Failed to fixup %s: %pe\n", of_board,
+			ERR_PTR(ret));
+
+	return 0;
+}
+
 static int skov_imx8mp_get_variant_id(uint *id)
 {
 	struct gpio gpios_rev[] = GPIO_HW_VARIANT;
@@ -133,9 +156,10 @@ static int skov_imx8mp_get_hdmi(struct device *dev)
 	return val;
 }
 
-static int skov_imx8mp_init_variant(struct device *dev)
+static int skov_imx8mp_init_variant(struct skov_imx8mp_priv *priv)
 {
 	const struct board_description *variant;
+	struct device *dev = priv->dev;
 	const char *compatible;
 	unsigned int v = 0;
 	int ret;
@@ -144,6 +168,8 @@ static int skov_imx8mp_init_variant(struct device *dev)
 	if (ret)
 		return ret;
 
+	priv->variant_id = v;
+
 	if (v >= ARRAY_SIZE(imx8mp_variants)) {
 		dev_err(dev, "Invalid variant %u\n", v);
 		return -EINVAL;
@@ -234,9 +260,20 @@ static void skov_imx8mp_init_storage(struct device *dev)
 
 static int skov_imx8mp_probe(struct device *dev)
 {
+	struct skov_imx8mp_priv *priv;
+	int ret;
+
+	priv = xzalloc(sizeof(*priv));
+	priv->dev = dev;
+	skov_imx8mp_priv = priv;
+
 	skov_imx8mp_init_storage(dev);
 
-	skov_imx8mp_init_variant(dev);
+	skov_imx8mp_init_variant(priv);
+
+	ret = of_register_fixup(skov_imx8mp_fixup, priv);
+	if (ret)
+		dev_err(dev, "Failed to register fixup: %pe\n", ERR_PTR(ret));
 
 	return 0;
 }
-- 
2.39.2




  parent reply	other threads:[~2023-10-02 10:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 10:16 [PATCH v2 00/10] SKOV maintenance Oleksij Rempel
2023-10-02 10:16 ` [PATCH v2 01/10] arm: dts: imx8mp-skov: Add reserved-memory for ramoops pstore Oleksij Rempel
2023-10-02 10:16 ` [PATCH v2 02/10] arm: dts: imx8mp-skov: Add pins for hardware variant detection Oleksij Rempel
2023-10-02 10:16 ` [PATCH v2 03/10] arm: dts: imx8mp-skov: Switch to GPT for eMMC partitioning Oleksij Rempel
2023-10-02 10:16 ` [PATCH v2 04/10] arm: dts: imx8mp-skov: Switch to GPT for SD partitioning Oleksij Rempel
2023-10-02 10:16 ` [PATCH v2 05/10] arm: dts: imx8mp-skov: Add barebox state backend in DTS Oleksij Rempel
2023-10-02 10:16 ` [PATCH v2 06/10] ARM: i.MX8MP: skov: refactor bootsource and BBU handlers Oleksij Rempel
2023-10-02 10:16 ` [PATCH v2 07/10] ARM: i.MX8MP: skov: Add hardware variant support Oleksij Rempel
2023-10-02 10:16 ` Oleksij Rempel [this message]
2023-10-02 10:16 ` [PATCH v2 09/10] net: lib: add ether_addr_inc() helper Oleksij Rempel
2023-10-04  6:41   ` Sascha Hauer
2023-10-05  6:48     ` Ahmad Fatoum
2023-10-05  7:07       ` Oleksij Rempel
2023-10-06 11:44         ` Sascha Hauer
2023-10-02 10:16 ` [PATCH v2 10/10] ARM: i.MX8MP: skov: assign Ethernet addresses to all ports Oleksij Rempel
2023-10-05  6:52   ` Ahmad Fatoum

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=20231002101654.2373000-9-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --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