]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARM: imx6: Adapt device tree selection in DH board file
authorPhilip Oberfichtner <pro@denx.de>
Fri, 20 May 2022 08:46:26 +0000 (10:46 +0200)
committerStefano Babic <sbabic@denx.de>
Fri, 20 May 2022 10:36:49 +0000 (12:36 +0200)
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>
board/dhelectronics/dh_imx6/dh_imx6.c

index 6059f96e806a15d0bc1f3a44154370b8d9345bc3..e8aba83e1ab772d7c2f3e83568c18aaa81eca677 100644 (file)
@@ -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