]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm64: zynqmp: Create fdtfile from compatible string
authorMichal Simek <michal.simek@xilinx.com>
Thu, 14 Feb 2019 12:14:30 +0000 (13:14 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 27 Feb 2019 07:53:08 +0000 (08:53 +0100)
distro boot expects that fdtfile name is setup for alternative DTB.
Create this file based on the first platform compatible string.
This should ensure that one rootfs can store multiple DTBs for different
boards.
Reflect structure which is used in Linux kernel. It means dtbs are
strored in xilinx folder.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
board/xilinx/zynqmp/zynqmp.c

index 2b14f9799894dceaa2f4213306e42cc423ad4515..2ebf0700a57f0b30f434a2a81f774dfbba8d4b04 100644 (file)
@@ -515,6 +515,36 @@ static u32 reset_reason(void)
        return ret;
 }
 
+static int set_fdtfile(void)
+{
+       char *compatible, *fdtfile;
+       const char *suffix = ".dtb";
+       const char *vendor = "xilinx/";
+
+       if (env_get("fdtfile"))
+               return 0;
+
+       compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", NULL);
+       if (compatible) {
+               debug("Compatible: %s\n", compatible);
+
+               /* Discard vendor prefix */
+               strsep(&compatible, ",");
+
+               fdtfile = calloc(1, strlen(vendor) + strlen(compatible) +
+                                strlen(suffix) + 1);
+               if (!fdtfile)
+                       return -ENOMEM;
+
+               sprintf(fdtfile, "%s%s%s", vendor, compatible, suffix);
+
+               env_set("fdtfile", fdtfile);
+               free(fdtfile);
+       }
+
+       return 0;
+}
+
 int board_late_init(void)
 {
        u32 reg = 0;
@@ -537,6 +567,10 @@ int board_late_init(void)
                return 0;
        }
 
+       ret = set_fdtfile();
+       if (ret)
+               return ret;
+
        ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, &reg);
        if (ret)
                return -EINVAL;