public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Philip Oberfichtner <pro@denx.de>
To: u-boot@lists.denx.de
Cc: Stefano Babic <sbabic@denx.de>,
	Christoph Niedermaier <cniedermaier@dh-electronics.com>,
	Peng Fan <peng.fan@nxp.com>, Fabio Estevam <festevam@denx.de>,
	Marek Vasut <marex@denx.de>, Philip Oberfichtner <pro@denx.de>,
	Andreas Geisreiter <ageisreiter@dh-electronics.de>,
	Tom Rini <trini@konsulko.com>,
	u-boot@dh-electronics.com
Subject: [PATCH v2 8/8] ARM: imx6: Adapt device tree selection in DH board file
Date: Fri, 20 May 2022 10:46:26 +0200	[thread overview]
Message-ID: <20220520084626.656293-9-pro@denx.de> (raw)
In-Reply-To: <20220520084626.656293-1-pro@denx.de>

Before this commit device tree selection could rely solely on
differentiating the iMX6 processor variant Q and DL. After adding two new
carrier boards, the DRC02 and the picoITX, the interchangeability of SoMs
makes this approach infeasible.

It is now required to specify the carrier board (dhcom-drc02,
dhcom-picoitx or dhcom-pdk2) at compile time using
CONFIG_DEFAULT_DEVICETREE. The SoM is determined at runtime as before.

Signed-off-by: Philip Oberfichtner <pro@denx.de>

---

Changes in v2:
- Rewrite board_fit_config_name_match
- Return -EINVAL instead of -1

 board/dhelectronics/dh_imx6/dh_imx6.c | 31 +++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
index 6059f96e80..e8aba83e1a 100644
--- a/board/dhelectronics/dh_imx6/dh_imx6.c
+++ b/board/dhelectronics/dh_imx6/dh_imx6.c
@@ -225,16 +225,35 @@ int checkboard(void)
 }
 
 #ifdef CONFIG_MULTI_DTB_FIT
+static int strcmp_prefix(const char *s1, const char *s2)
+{
+	size_t n;
+
+	n = min(strlen(s1), strlen(s2));
+	return strncmp(s1, s2, n);
+}
+
 int board_fit_config_name_match(const char *name)
 {
-	if (is_mx6dq()) {
-		if (!strcmp(name, "imx6q-dhcom-pdk2"))
-			return 0;
-	} else if (is_mx6sdl()) {
-		if (!strcmp(name, "imx6dl-dhcom-pdk2"))
+	char *want;
+	char *have;
+
+	/* Test Board suffix, e.g. -dhcom-drc02 */
+	want = strchr(CONFIG_DEFAULT_DEVICE_TREE, '-');
+	have = strchr(name, '-');
+
+	if (!want || !have || strcmp(want, have))
+		return -EINVAL;
+
+	/* Test SoC prefix */
+	if (is_mx6dq() && !strcmp_prefix(name, "imx6q-"))
+		return 0;
+
+	if (is_mx6sdl()) {
+		if (!strcmp_prefix(name, "imx6s-") || !strcmp_prefix(name, "imx6dl-"))
 			return 0;
 	}
 
-	return -1;
+	return -EINVAL;
 }
 #endif
-- 
2.34.1


  parent reply	other threads:[~2022-05-20  8:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20  8:46 [PATCH v2 0/8] ARM: imx: Add support for iMX6QDL DHCOM DRC02 and DH picoITX Philip Oberfichtner
2022-05-20  8:46 ` [PATCH v2 1/8] ARM: imx6: Fix broken DT path in DH board file Philip Oberfichtner
2022-05-20 13:41   ` sbabic
2022-05-20  8:46 ` [PATCH v2 2/8] ARM: dts: imx: Migrate iMX6QDL DRC02 DTs from Linux Philip Oberfichtner
2022-05-20 13:44   ` sbabic
2022-05-20  8:46 ` [PATCH v2 3/8] ARM: dts: imx: Migrate iMX6QDL picoITX " Philip Oberfichtner
2022-05-20 13:43   ` sbabic
2022-05-20  8:46 ` [PATCH v2 4/8] ARM: imx6: Remove CONFIG_FEC_MXC_PHYADDR from DH header Philip Oberfichtner
2022-05-20 13:40   ` sbabic
2022-05-20  8:46 ` [PATCH v2 5/8] ARM: dts: imx: Simplify fec node for iMX6QDL DHCOM boards Philip Oberfichtner
2022-05-20 13:43   ` sbabic
2022-05-20  8:46 ` [PATCH v2 6/8] ARM: dts: imx: Configure FEC for iMX6QDL picoITX Philip Oberfichtner
2022-05-20 13:40   ` sbabic
2022-05-20  8:46 ` [PATCH v2 7/8] ARM: dts: imx: Configure FEC for iMX6QDL DRC02 Philip Oberfichtner
2022-05-20 13:42   ` sbabic
2022-05-20  8:46 ` Philip Oberfichtner [this message]
2022-05-20 10:57   ` [PATCH v2 8/8] ARM: imx6: Adapt device tree selection in DH board file Marek Vasut
2022-05-20 13:43   ` sbabic
2022-05-20 11:33 ` [PATCH v2 0/8] ARM: imx: Add support for iMX6QDL DHCOM DRC02 and DH picoITX Fabio Estevam

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=20220520084626.656293-9-pro@denx.de \
    --to=pro@denx.de \
    --cc=ageisreiter@dh-electronics.de \
    --cc=cniedermaier@dh-electronics.com \
    --cc=festevam@denx.de \
    --cc=marex@denx.de \
    --cc=peng.fan@nxp.com \
    --cc=sbabic@denx.de \
    --cc=trini@konsulko.com \
    --cc=u-boot@dh-electronics.com \
    --cc=u-boot@lists.denx.de \
    /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