]> Git Repo - J-u-boot.git/blobdiff - common/image-fdt.c
common: Drop asm/global_data.h from common header
[J-u-boot.git] / common / image-fdt.c
index 270732278e6295876525d976db5941c44eb23e3b..0157cce32d58d7825beb1a7f55c47c582e3dfd02 100644 (file)
@@ -15,7 +15,9 @@
 #include <errno.h>
 #include <image.h>
 #include <lmb.h>
+#include <log.h>
 #include <malloc.h>
+#include <asm/global_data.h>
 #include <linux/libfdt.h>
 #include <mapmem.h>
 #include <asm/io.h>
@@ -264,8 +266,8 @@ error:
  *     1, if fdt image is found but corrupted
  *     of_flat_tree and of_size are set to 0 if no fdt exists
  */
-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)
+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 CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
        const image_header_t *fdt_hdr;
@@ -406,6 +408,9 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                                        &fit_uname_config,
                                        arch, &load, &len);
 
+                               if (fdt_noffset < 0)
+                                       goto error;
+
                                images->fit_hdr_fdt = map_sysmem(fdt_addr, 0);
                                images->fit_uname_fdt = fit_uname_fdt;
                                images->fit_noffset_fdt = fdt_noffset;
@@ -425,7 +430,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                        break;
                default:
                        puts("ERROR: Did not find a cmdline Flattened Device Tree\n");
-                       goto no_fdt;
+                       goto error;
                }
 
                printf("   Booting using the fdt blob at %#08lx\n", fdt_addr);
@@ -464,10 +469,20 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 #ifdef CONFIG_ANDROID_BOOT_IMAGE
        } else if (genimg_get_format(buf) == IMAGE_FORMAT_ANDROID) {
                struct andr_img_hdr *hdr = buf;
-               ulong fdt_data, fdt_len;
+               ulong           fdt_data, fdt_len;
+               u32                     fdt_size, dtb_idx;
+               /*
+                * Firstly check if this android boot image has dtb field.
+                */
+               dtb_idx = (u32)env_get_ulong("adtb_idx", 10, 0);
+               if (android_image_get_dtb_by_index((ulong)hdr, dtb_idx, &fdt_addr, &fdt_size)) {
+                       fdt_blob = (char *)map_sysmem(fdt_addr, 0);
+                       if (fdt_check_header(fdt_blob))
+                               goto no_fdt;
 
-               if (!android_image_get_second(hdr, &fdt_data, &fdt_len) &&
-                   !fdt_check_header((char *)fdt_data)) {
+                       debug("## Using FDT in Android image dtb area with idx %u\n", dtb_idx);
+               } else if (!android_image_get_second(hdr, &fdt_data, &fdt_len) &&
+                       !fdt_check_header((char *)fdt_data)) {
                        fdt_blob = (char *)fdt_data;
                        if (fdt_totalsize(fdt_blob) != fdt_len)
                                goto error;
@@ -546,8 +561,20 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
                printf("ERROR: arch-specific fdt fixup failed\n");
                goto err;
        }
+
+       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;
+       }
+
        /* Update ethernet nodes */
        fdt_fixup_ethernet(blob);
+#if CONFIG_IS_ENABLED(CMD_PSTORE)
+       /* Append PStore configuration */
+       fdt_fixup_pstore(blob);
+#endif
        if (IMAGE_OF_BOARD_SETUP) {
                fdt_ret = ft_board_setup(blob, gd->bd);
                if (fdt_ret) {
@@ -565,13 +592,6 @@ 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,
This page took 0.027438 seconds and 4 git commands to generate.