summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-05-19 13:55:43 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-05-19 13:55:43 +0200
commit1e284880fb5b339bc922faa6cdb7fa4274838578 (patch)
treea3d606e6aaa3626ddedaf3c19fea6cdbc3fb3235 /arch
parent764fdbaba337e3b58f31ce7b177c4e7c0ba2088d (diff)
parent38f240bc08205857b3fc3d25cb9ba69931d9b50a (diff)
downloadbarebox-1e284880fb5b339bc922faa6cdb7fa4274838578.tar.gz
barebox-1e284880fb5b339bc922faa6cdb7fa4274838578.tar.xz
Merge branch 'for-next/of-board'
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boards/protonic-imx6/board.c42
-rw-r--r--arch/arm/boards/skov-imx6/board.c40
2 files changed, 22 insertions, 60 deletions
diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c
index 52cf39917a..cdbb8debe6 100644
--- a/arch/arm/boards/protonic-imx6/board.c
+++ b/arch/arm/boards/protonic-imx6/board.c
@@ -126,6 +126,22 @@ static const struct gpio prt_imx6_kvg_gpios[] = {
},
};
+static int prt_of_fixup_hwrev(struct prt_imx6_priv *priv)
+{
+ const char *compat;
+ char *buf;
+
+ compat = of_device_get_match_compatible(priv->dev);
+
+ buf = xasprintf("%s-m%u-r%u", compat, priv->hw_id,
+ priv->hw_rev);
+ barebox_set_of_machine_compatible(buf);
+
+ free(buf);
+
+ return 0;
+}
+
static int prt_imx6_read_rfid(struct prt_imx6_priv *priv, void *buf,
size_t size)
{
@@ -196,30 +212,12 @@ static int prt_imx6_set_mac(struct prt_imx6_priv *priv,
return 0;
}
-static int prt_of_fixup_serial(struct device_node *dstroot, void *arg)
-{
- struct device_node *srcroot = arg;
- const char *ser;
- int len;
-
- ser = of_get_property(srcroot, "serial-number", &len);
- return of_set_property(dstroot, "serial-number", ser, len, 1);
-}
-
-static void prt_oftree_fixup_serial(const char *serial)
-{
- struct device_node *root = of_get_root_node();
-
- of_set_property(root, "serial-number", serial, strlen(serial) + 1, 1);
- of_register_fixup(prt_of_fixup_serial, root);
-}
-
static int prt_imx6_set_serial(struct prt_imx6_priv *priv,
struct prti6q_rfid_contents *rfid)
{
rfid->serial[9] = 0; /* Failsafe */
dev_info(priv->dev, "Serial number: %s\n", rfid->serial);
- prt_oftree_fixup_serial(rfid->serial);
+ barebox_set_serial_number(rfid->serial);
return 0;
}
@@ -815,7 +813,6 @@ exit_get_dcfg:
static int prt_imx6_probe(struct device_d *dev)
{
struct prt_imx6_priv *priv;
- const char *name, *ptr;
struct param_d *p;
int ret;
@@ -824,9 +821,7 @@ 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->name = of_get_machine_compatible();
pr_info("Detected machine type: %s\n", priv->name);
@@ -836,6 +831,7 @@ static int prt_imx6_probe(struct device_d *dev)
pr_info(" HW type: %d\n", priv->hw_id);
pr_info(" HW revision: %d\n", priv->hw_rev);
+ prt_of_fixup_hwrev(priv);
ret = prt_imx6_get_dcfg(priv);
if (ret)
diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 2702bc1de9..bceb215a01 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -312,55 +312,21 @@ static int skov_board_no = -1;
static bool skov_have_switch = true;
static const char *no_switch_suffix = "-noswitch";
-static void fixup_machine_compatible(const char *compat,
- struct device_node *root)
-{
- int cclen = 0, clen = strlen(compat) + 1;
- const char *curcompat;
- void *buf;
-
- if (!root) {
- root = of_get_root_node();
- if (!root)
- return;
- }
-
- curcompat = of_get_property(root, "compatible", &cclen);
-
- buf = xzalloc(cclen + clen);
-
- memcpy(buf, compat, clen);
- memcpy(buf + clen, curcompat, cclen);
-
- /*
- * Prepend the compatible from board entry to the machine compatible.
- * Used to match bootspec entries against it.
- */
- of_set_property(root, "compatible", buf, cclen + clen, true);
-
- free(buf);
-}
-
static void fixup_noswitch_machine_compatible(struct device_node *root)
{
const char *compat = imx6_variants[skov_board_no].dts_compatible;
const char *generic = "skov,imx6";
- size_t size, size_generic;
char *buf;
- size = strlen(compat) + strlen(no_switch_suffix) + 1;
- size_generic = strlen(generic) + strlen(no_switch_suffix) + 1;
- size = max(size, size_generic);
-
/* add generic compatible, so systemd&co can make right decisions */
buf = xasprintf("%s%s", generic, no_switch_suffix);
- fixup_machine_compatible(buf, root);
+ of_prepend_machine_compatible(root, buf);
/* add specific compatible as fallback, in case this board has new
* challenges.
*/
buf = xasprintf("%s%s", compat, no_switch_suffix);
- fixup_machine_compatible(buf, root);
+ of_prepend_machine_compatible(root, buf);
free(buf);
}
@@ -648,7 +614,7 @@ static int skov_imx6_probe(struct device_d *dev)
globalvar_add_simple("board.dts", variant->dts_compatible);
globalvar_add_simple("board.display", variant->display ?: NULL);
- fixup_machine_compatible(variant->dts_compatible, NULL);
+ of_prepend_machine_compatible(NULL, variant->dts_compatible);
skov_init_board(variant);