]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
librem5: properly set the `fdtfile` env variable
authorArnaud Ferraris <arnaud.ferraris@collabora.com>
Fri, 27 Oct 2023 13:40:44 +0000 (15:40 +0200)
committerFabio Estevam <festevam@gmail.com>
Wed, 13 Dec 2023 13:00:43 +0000 (10:00 -0300)
In order to use the generic "distro boot" using an extlinux.conf file,
the `fdtfile` environment variable is mandatory. This commit ensure this
variable is properly constructed based on the detected board revision.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
board/purism/librem5/librem5.c

index 386ed1b4fb22d135c495f89adcee4c23ddb654a1..d0249e71f09aa1a84a6109f24aa558e2d39fbfde 100644 (file)
@@ -399,21 +399,46 @@ int board_init(void)
 int board_late_init(void)
 {
        if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) {
-               u32 rev;
+               /*
+                * Use the r4 dtb by default as those are the most
+                * widespread devices.
+                */
+               u32 rev, dtb_rev = 4;
                char rev_str[3];
+               char fdt_str[50];
 
                env_set("board_name", "librem5");
                if (fuse_read(9, 0, &rev)) {
                        env_set("board_rev", BOARD_REV_ERROR);
                } else if (rev == 0) {
+                       /*
+                        * If the fuses aren't burnt we should use either the
+                        * r2 or r3 DTB. The latter makes more sense as there
+                        * are far more r3 devices out there.
+                        */
+                       dtb_rev = 3;
                        env_set("board_rev", BOARD_REV_UNKNOWN);
                } else if (rev > 0) {
+                       if (rev == 1)
+                               dtb_rev = 2;
+                       else if (rev < dtb_rev)
+                               dtb_rev = rev;
+                       /*
+                        * FCC-approved devices report '5' as their board
+                        * revision but use the r4 DTB as the PCB's are
+                        * functionally identical.
+                        */
+                       else if (rev == 5)
+                               dtb_rev = 4;
                        sprintf(rev_str, "%u", rev);
                        env_set("board_rev", rev_str);
                }
 
                printf("Board name: %s\n", env_get("board_name"));
                printf("Board rev:  %s\n", env_get("board_rev"));
+
+               sprintf(fdt_str, "freescale/imx8mq-librem5-r%u.dtb", dtb_rev);
+               env_set("fdtfile", fdt_str);
        }
 
        if (is_usb_boot()) {