diff mbox series

[v2,8/8] ARM: imx6: Adapt device tree selection in DH board file

Message ID 20220520084626.656293-9-pro@denx.de
State Accepted
Commit bd8df1f7ddd055b254bfd4af56b5c454bf4c3f11
Delegated to: Stefano Babic
Headers show
Series ARM: imx: Add support for iMX6QDL DHCOM DRC02 and DH picoITX | expand

Commit Message

Philip Oberfichtner May 20, 2022, 8:46 a.m. UTC
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(-)

Comments

Marek Vasut May 20, 2022, 10:57 a.m. UTC | #1
On 5/20/22 10:46, Philip Oberfichtner wrote:
> 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>

Reviewed-by: Marek Vasut <marex@denx.de>
Stefano Babic May 20, 2022, 1:43 p.m. UTC | #2
> 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>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

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