[PATCH v1 5/5] ARM: boards: protonic-imx6: add HW revision specific machine compatible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently we use generic/pinned machine compatible for different HW
revisions. With this patch we extend this compatible string with HW
revision specific.

Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
 arch/arm/boards/protonic-imx6/board.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c
index 0fadd148b4..1a1e5540ee 100644
--- a/arch/arm/boards/protonic-imx6/board.c
+++ b/arch/arm/boards/protonic-imx6/board.c
@@ -85,6 +85,7 @@ struct prt_imx6_priv {
 	const struct prt_machine_data *dcfg;
 	unsigned int hw_id;
 	unsigned int hw_rev;
+	const char *compatible;
 	const char *name;
 	unsigned int usb_delay;
 	unsigned int no_usb_check;
@@ -126,6 +127,20 @@ static const struct gpio prt_imx6_kvg_gpios[] = {
 	},
 };
 
+static int prt_of_fixup_hwrev(struct device_node *dstroot, void *arg)
+{
+	struct prt_imx6_priv *priv = prt_priv;
+	char *buf;
+
+	buf = xasprintf("%s,model:%u,rev:%u", priv->compatible, priv->hw_id,
+			priv->hw_rev);
+	of_fixup_machine_compatible(dstroot, buf);
+
+	free(buf);
+
+	return 0;
+}
+
 static int prt_imx6_read_rfid(struct prt_imx6_priv *priv, void *buf,
 			      size_t size)
 {
@@ -797,7 +812,7 @@ exit_get_dcfg:
 static int prt_imx6_probe(struct device_d *dev)
 {
 	struct prt_imx6_priv *priv;
-	const char *name, *ptr;
+	const char *ptr;
 	struct param_d *p;
 	int ret;
 
@@ -806,9 +821,9 @@ static int prt_imx6_probe(struct device_d *dev)
 		return -ENOMEM;
 
 	priv->dev = dev;
-	name = of_device_get_match_compatible(priv->dev);
-	ptr = strchr(name, ',');
-	priv->name =  ptr ? ptr + 1 : name;
+	priv->compatible = of_device_get_match_compatible(priv->dev);
+	ptr = strchr(priv->compatible, ',');
+	priv->name =  ptr ? ptr + 1 : priv->compatible;
 
 	pr_info("Detected machine type: %s\n", priv->name);
 
@@ -841,6 +856,8 @@ static int prt_imx6_probe(struct device_d *dev)
 
 	prt_priv = priv;
 
+	of_register_fixup(prt_of_fixup_hwrev, NULL);
+
 	return 0;
 free_priv:
 	kfree(priv);
-- 
2.30.2


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



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux