image: android: Add routine to get dtbo params
[oweals/u-boot.git] / common / image-fdt.c
index eb552ca207ca03904068e6172f78931d9de42dc3..dbb1e6e131c8e06c745320a6b27eb8d9b435b462 100644 (file)
 #include <common.h>
 #include <fdt_support.h>
 #include <fdtdec.h>
+#include <env.h>
 #include <errno.h>
 #include <image.h>
 #include <linux/libfdt.h>
 #include <mapmem.h>
 #include <asm/io.h>
+#include <tee/optee.h>
 
 #ifndef CONFIG_SYS_FDT_PAD
 #define CONFIG_SYS_FDT_PAD 0x3000
@@ -33,7 +35,7 @@ static void fdt_error(const char *msg)
        puts(" - must RESET the board to recover.\n");
 }
 
-#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
+#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 static const image_header_t *image_get_fdt(ulong fdt_addr)
 {
        const image_header_t *fdt_hdr = map_sysmem(fdt_addr, 0);
@@ -263,7 +265,7 @@ error:
 int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
 {
-#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
+#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
        const image_header_t *fdt_hdr;
        ulong           load, load_end;
        ulong           image_start, image_data, image_end;
@@ -283,7 +285,8 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
        *of_flat_tree = NULL;
        *of_size = 0;
 
-       img_addr = (argc == 0) ? load_addr : simple_strtoul(argv[0], NULL, 16);
+       img_addr = (argc == 0) ? image_load_addr :
+                       simple_strtoul(argv[0], NULL, 16);
        buf = map_sysmem(img_addr, 0);
 
        if (argc > 2)
@@ -302,7 +305,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                        else if (images->fit_uname_os)
                                default_addr = (ulong)images->fit_hdr_os;
                        else
-                               default_addr = load_addr;
+                               default_addr = image_load_addr;
 
                        if (fit_parse_conf(select, default_addr,
                                           &fdt_addr, &fit_uname_config)) {
@@ -344,7 +347,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                 */
                buf = map_sysmem(fdt_addr, 0);
                switch (genimg_get_format(buf)) {
-#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
+#if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
                case IMAGE_FORMAT_LEGACY:
                        /* verify fdt_addr points to a valid image header */
                        printf("## Flattened Device Tree from Legacy Image at %08lx\n",
@@ -560,6 +563,13 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
                }
        }
 
+       fdt_ret = optee_copy_fdt_nodes(gd->fdt_blob, blob);
+       if (fdt_ret) {
+               printf("ERROR: transfer of optee nodes to new fdt failed: %s\n",
+                      fdt_strerror(fdt_ret));
+               goto err;
+       }
+
        /* Delete the old LMB reservation */
        if (lmb)
                lmb_free(lmb, (phys_addr_t)(u32)(uintptr_t)blob,