64e4e7ae5318811cbbae6cb7222da61574fa231c
[platform/kernel/u-boot.git] / common / spl / spl_fit.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2016 Google, Inc
4  * Written by Simon Glass <sjg@chromium.org>
5  */
6
7 #include <common.h>
8 #include <errno.h>
9 #include <fpga.h>
10 #include <gzip.h>
11 #include <image.h>
12 #include <log.h>
13 #include <malloc.h>
14 #include <spl.h>
15 #include <sysinfo.h>
16 #include <asm/cache.h>
17 #include <asm/global_data.h>
18 #include <linux/libfdt.h>
19
20 DECLARE_GLOBAL_DATA_PTR;
21
22 #ifndef CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ
23 #define CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ (64 * 1024)
24 #endif
25
26 #ifndef CONFIG_SYS_BOOTM_LEN
27 #define CONFIG_SYS_BOOTM_LEN    (64 << 20)
28 #endif
29
30 struct spl_fit_info {
31         const void *fit;        /* Pointer to a valid FIT blob */
32         size_t ext_data_offset; /* Offset to FIT external data (end of FIT) */
33         int images_node;        /* FDT offset to "/images" node */
34         int conf_node;          /* FDT offset to selected configuration node */
35 };
36
37 __weak void board_spl_fit_post_load(const void *fit)
38 {
39 }
40
41 __weak ulong board_spl_fit_size_align(ulong size)
42 {
43         return size;
44 }
45
46 static int find_node_from_desc(const void *fit, int node, const char *str)
47 {
48         int child;
49
50         if (node < 0)
51                 return -EINVAL;
52
53         /* iterate the FIT nodes and find a matching description */
54         for (child = fdt_first_subnode(fit, node); child >= 0;
55              child = fdt_next_subnode(fit, child)) {
56                 int len;
57                 const char *desc = fdt_getprop(fit, child, "description", &len);
58
59                 if (!desc)
60                         continue;
61
62                 if (!strcmp(desc, str))
63                         return child;
64         }
65
66         return -ENOENT;
67 }
68
69 /**
70  * spl_fit_get_image_name(): By using the matching configuration subnode,
71  * retrieve the name of an image, specified by a property name and an index
72  * into that.
73  * @fit:        Pointer to the FDT blob.
74  * @images:     Offset of the /images subnode.
75  * @type:       Name of the property within the configuration subnode.
76  * @index:      Index into the list of strings in this property.
77  * @outname:    Name of the image
78  *
79  * Return:      0 on success, or a negative error number
80  */
81 static int spl_fit_get_image_name(const struct spl_fit_info *ctx,
82                                   const char *type, int index,
83                                   const char **outname)
84 {
85         struct udevice *sysinfo;
86         const char *name, *str;
87         __maybe_unused int node;
88         int len, i;
89         bool found = true;
90
91         name = fdt_getprop(ctx->fit, ctx->conf_node, type, &len);
92         if (!name) {
93                 debug("cannot find property '%s': %d\n", type, len);
94                 return -EINVAL;
95         }
96
97         str = name;
98         for (i = 0; i < index; i++) {
99                 str = strchr(str, '\0') + 1;
100                 if (!str || (str - name >= len)) {
101                         found = false;
102                         break;
103                 }
104         }
105
106         if (!found && CONFIG_IS_ENABLED(SYSINFO) && !sysinfo_get(&sysinfo)) {
107                 int rc;
108                 /*
109                  * no string in the property for this index. Check if the
110                  * sysinfo-level code can supply one.
111                  */
112                 rc = sysinfo_get_fit_loadable(sysinfo, index - i - 1, type,
113                                               &str);
114                 if (rc && rc != -ENOENT)
115                         return rc;
116
117                 if (!rc) {
118                         /*
119                          * The sysinfo provided a name for a loadable.
120                          * Try to match it against the description properties
121                          * first. If no matching node is found, use it as a
122                          * node name.
123                          */
124                         int node;
125                         int images = fdt_path_offset(ctx->fit, FIT_IMAGES_PATH);
126
127                         node = find_node_from_desc(ctx->fit, images, str);
128                         if (node > 0)
129                                 str = fdt_get_name(ctx->fit, node, NULL);
130
131                         found = true;
132                 }
133         }
134
135         if (!found) {
136                 debug("no string for index %d\n", index);
137                 return -E2BIG;
138         }
139
140         *outname = str;
141         return 0;
142 }
143
144 /**
145  * spl_fit_get_image_node(): By using the matching configuration subnode,
146  * retrieve the name of an image, specified by a property name and an index
147  * into that.
148  * @fit:        Pointer to the FDT blob.
149  * @images:     Offset of the /images subnode.
150  * @type:       Name of the property within the configuration subnode.
151  * @index:      Index into the list of strings in this property.
152  *
153  * Return:      the node offset of the respective image node or a negative
154  *              error number.
155  */
156 static int spl_fit_get_image_node(const struct spl_fit_info *ctx,
157                                   const char *type, int index)
158 {
159         const char *str;
160         int err;
161         int node;
162
163         err = spl_fit_get_image_name(ctx, type, index, &str);
164         if (err)
165                 return err;
166
167         debug("%s: '%s'\n", type, str);
168
169         node = fdt_subnode_offset(ctx->fit, ctx->images_node, str);
170         if (node < 0) {
171                 pr_err("cannot find image node '%s': %d\n", str, node);
172                 return -EINVAL;
173         }
174
175         return node;
176 }
177
178 static int get_aligned_image_offset(struct spl_load_info *info, int offset)
179 {
180         /*
181          * If it is a FS read, get the first address before offset which is
182          * aligned to ARCH_DMA_MINALIGN. If it is raw read return the
183          * block number to which offset belongs.
184          */
185         if (info->filename)
186                 return offset & ~(ARCH_DMA_MINALIGN - 1);
187
188         return offset / info->bl_len;
189 }
190
191 static int get_aligned_image_overhead(struct spl_load_info *info, int offset)
192 {
193         /*
194          * If it is a FS read, get the difference between the offset and
195          * the first address before offset which is aligned to
196          * ARCH_DMA_MINALIGN. If it is raw read return the offset within the
197          * block.
198          */
199         if (info->filename)
200                 return offset & (ARCH_DMA_MINALIGN - 1);
201
202         return offset % info->bl_len;
203 }
204
205 static int get_aligned_image_size(struct spl_load_info *info, int data_size,
206                                   int offset)
207 {
208         data_size = data_size + get_aligned_image_overhead(info, offset);
209
210         if (info->filename)
211                 return data_size;
212
213         return (data_size + info->bl_len - 1) / info->bl_len;
214 }
215
216 /**
217  * spl_load_fit_image(): load the image described in a certain FIT node
218  * @info:       points to information about the device to load data from
219  * @sector:     the start sector of the FIT image on the device
220  * @ctx:        points to the FIT context structure
221  * @node:       offset of the DT node describing the image to load (relative
222  *              to @fit)
223  * @image_info: will be filled with information about the loaded image
224  *              If the FIT node does not contain a "load" (address) property,
225  *              the image gets loaded to the address pointed to by the
226  *              load_addr member in this struct.
227  *
228  * Return:      0 on success or a negative error number.
229  */
230 static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
231                               const struct spl_fit_info *ctx, int node,
232                               struct spl_image_info *image_info)
233 {
234         int offset;
235         size_t length;
236         int len;
237         ulong size;
238         ulong load_addr, load_ptr;
239         void *src;
240         ulong overhead;
241         int nr_sectors;
242         int align_len = ARCH_DMA_MINALIGN - 1;
243         uint8_t image_comp = -1, type = -1;
244         const void *data;
245         const void *fit = ctx->fit;
246         bool external_data = false;
247
248         if (IS_ENABLED(CONFIG_SPL_FPGA) ||
249             (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
250                 if (fit_image_get_type(fit, node, &type))
251                         puts("Cannot get image type.\n");
252                 else
253                         debug("%s ", genimg_get_type_name(type));
254         }
255
256         if (IS_ENABLED(CONFIG_SPL_GZIP)) {
257                 fit_image_get_comp(fit, node, &image_comp);
258                 debug("%s ", genimg_get_comp_name(image_comp));
259         }
260
261         if (fit_image_get_load(fit, node, &load_addr))
262                 load_addr = image_info->load_addr;
263
264         if (!fit_image_get_data_position(fit, node, &offset)) {
265                 external_data = true;
266         } else if (!fit_image_get_data_offset(fit, node, &offset)) {
267                 offset += ctx->ext_data_offset;
268                 external_data = true;
269         }
270
271         if (external_data) {
272                 /* External data */
273                 if (fit_image_get_data_size(fit, node, &len))
274                         return -ENOENT;
275
276                 load_ptr = (load_addr + align_len) & ~align_len;
277                 length = len;
278
279                 overhead = get_aligned_image_overhead(info, offset);
280                 nr_sectors = get_aligned_image_size(info, length, offset);
281
282                 if (info->read(info,
283                                sector + get_aligned_image_offset(info, offset),
284                                nr_sectors, (void *)load_ptr) != nr_sectors)
285                         return -EIO;
286
287                 debug("External data: dst=%lx, offset=%x, size=%lx\n",
288                       load_ptr, offset, (unsigned long)length);
289                 src = (void *)load_ptr + overhead;
290         } else {
291                 /* Embedded data */
292                 if (fit_image_get_data(fit, node, &data, &length)) {
293                         puts("Cannot get image data/size\n");
294                         return -ENOENT;
295                 }
296                 debug("Embedded data: dst=%lx, size=%lx\n", load_addr,
297                       (unsigned long)length);
298                 src = (void *)data;
299         }
300
301 #ifdef CONFIG_SPL_FIT_SIGNATURE
302         printf("## Checking hash(es) for Image %s ... ",
303                fit_get_name(fit, node, NULL));
304         if (!fit_image_verify_with_data(fit, node,
305                                          src, length))
306                 return -EPERM;
307         puts("OK\n");
308 #endif
309
310 #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS
311         board_fit_image_post_process(&src, &length);
312 #endif
313
314         if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
315                 size = length;
316                 if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
317                            src, &size)) {
318                         puts("Uncompressing error\n");
319                         return -EIO;
320                 }
321                 length = size;
322         } else {
323                 memcpy((void *)load_addr, src, length);
324         }
325
326         if (image_info) {
327                 ulong entry_point;
328
329                 image_info->load_addr = load_addr;
330                 image_info->size = length;
331
332                 if (!fit_image_get_entry(fit, node, &entry_point))
333                         image_info->entry_point = entry_point;
334                 else
335                         image_info->entry_point = FDT_ERROR;
336         }
337
338         return 0;
339 }
340
341 static int spl_fit_append_fdt(struct spl_image_info *spl_image,
342                               struct spl_load_info *info, ulong sector,
343                               const struct spl_fit_info *ctx)
344 {
345         struct spl_image_info image_info;
346         int node, ret = 0, index = 0;
347
348         /*
349          * Use the address following the image as target address for the
350          * device tree.
351          */
352         image_info.load_addr = spl_image->load_addr + spl_image->size;
353
354         /* Figure out which device tree the board wants to use */
355         node = spl_fit_get_image_node(ctx, FIT_FDT_PROP, index++);
356         if (node < 0) {
357                 debug("%s: cannot find FDT node\n", __func__);
358
359                 /*
360                  * U-Boot did not find a device tree inside the FIT image. Use
361                  * the U-Boot device tree instead.
362                  */
363                 if (gd->fdt_blob)
364                         memcpy((void *)image_info.load_addr, gd->fdt_blob,
365                                fdt_totalsize(gd->fdt_blob));
366                 else
367                         return node;
368         } else {
369                 ret = spl_load_fit_image(info, sector, ctx, node,
370                                          &image_info);
371                 if (ret < 0)
372                         return ret;
373         }
374
375         /* Make the load-address of the FDT available for the SPL framework */
376         spl_image->fdt_addr = (void *)image_info.load_addr;
377 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
378         if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
379                 void *tmpbuffer = NULL;
380
381                 for (; ; index++) {
382                         node = spl_fit_get_image_node(ctx, FIT_FDT_PROP, index);
383                         if (node == -E2BIG) {
384                                 debug("%s: No additional FDT node\n", __func__);
385                                 break;
386                         } else if (node < 0) {
387                                 debug("%s: unable to find FDT node %d\n",
388                                       __func__, index);
389                                 continue;
390                         }
391
392                         if (!tmpbuffer) {
393                                 /*
394                                  * allocate memory to store the DT overlay
395                                  * before it is applied. It may not be used
396                                  * depending on how the overlay is stored, so
397                                  * don't fail yet if the allocation failed.
398                                  */
399                                 tmpbuffer = malloc(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ);
400                                 if (!tmpbuffer)
401                                         debug("%s: unable to allocate space for overlays\n",
402                                               __func__);
403                         }
404                         image_info.load_addr = (ulong)tmpbuffer;
405                         ret = spl_load_fit_image(info, sector, ctx,
406                                                  node, &image_info);
407                         if (ret < 0)
408                                 break;
409
410                         /* Make room in FDT for changes from the overlay */
411                         ret = fdt_increase_size(spl_image->fdt_addr,
412                                                 image_info.size);
413                         if (ret < 0)
414                                 break;
415
416                         ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
417                                                         (void *)image_info.load_addr);
418                         if (ret) {
419                                 pr_err("failed to apply DT overlay %s\n",
420                                        fit_get_name(ctx->fit, node, NULL));
421                                 break;
422                         }
423
424                         debug("%s: DT overlay %s applied\n", __func__,
425                               fit_get_name(ctx->fit, node, NULL));
426                 }
427                 free(tmpbuffer);
428                 if (ret)
429                         return ret;
430         }
431         /* Try to make space, so we can inject details on the loadables */
432         ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
433         if (ret < 0)
434                 return ret;
435 #endif
436
437         return ret;
438 }
439
440 static int spl_fit_record_loadable(const struct spl_fit_info *ctx, int index,
441                                    void *blob, struct spl_image_info *image)
442 {
443         int ret = 0;
444 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
445         const char *name;
446         int node;
447
448         ret = spl_fit_get_image_name(ctx, "loadables", index, &name);
449         if (ret < 0)
450                 return ret;
451
452         node = spl_fit_get_image_node(ctx, "loadables", index);
453
454         ret = fdt_record_loadable(blob, index, name, image->load_addr,
455                                   image->size, image->entry_point,
456                                   fdt_getprop(ctx->fit, node, "type", NULL),
457                                   fdt_getprop(ctx->fit, node, "os", NULL));
458 #endif
459         return ret;
460 }
461
462 static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
463 {
464 #if CONFIG_IS_ENABLED(FIT_IMAGE_TINY) && !defined(CONFIG_SPL_OS_BOOT)
465         const char *name = fdt_getprop(fit, noffset, FIT_OS_PROP, NULL);
466
467         if (!name)
468                 return -ENOENT;
469
470         /*
471          * We don't care what the type of the image actually is,
472          * only whether or not it is U-Boot. This saves some
473          * space by omitting the large table of OS types.
474          */
475         if (!strcmp(name, "u-boot"))
476                 *os = IH_OS_U_BOOT;
477         else
478                 *os = IH_OS_INVALID;
479
480         return 0;
481 #else
482         return fit_image_get_os(fit, noffset, os);
483 #endif
484 }
485
486 /*
487  * The purpose of the FIT load buffer is to provide a memory location that is
488  * independent of the load address of any FIT component.
489  */
490 static void *spl_get_fit_load_buffer(size_t size)
491 {
492         void *buf;
493
494         buf = malloc(size);
495         if (!buf) {
496                 pr_err("Could not get FIT buffer of %lu bytes\n", (ulong)size);
497                 pr_err("\tcheck CONFIG_SYS_SPL_MALLOC_SIZE\n");
498                 buf = spl_get_load_buffer(0, size);
499         }
500         return buf;
501 }
502
503 /*
504  * Weak default function to allow customizing SPL fit loading for load-only
505  * use cases by allowing to skip the parsing/processing of the FIT contents
506  * (so that this can be done separately in a more customized fashion)
507  */
508 __weak bool spl_load_simple_fit_skip_processing(void)
509 {
510         return false;
511 }
512
513 static int spl_simple_fit_read(struct spl_fit_info *ctx,
514                                struct spl_load_info *info, ulong sector,
515                                const void *fit_header)
516 {
517         unsigned long count, size;
518         int sectors;
519         void *buf;
520
521         /*
522          * For FIT with external data, figure out where the external images
523          * start. This is the base for the data-offset properties in each
524          * image.
525          */
526         size = ALIGN(fdt_totalsize(fit_header), 4);
527         size = board_spl_fit_size_align(size);
528         ctx->ext_data_offset = ALIGN(size, 4);
529
530         /*
531          * So far we only have one block of data from the FIT. Read the entire
532          * thing, including that first block.
533          *
534          * For FIT with data embedded, data is loaded as part of FIT image.
535          * For FIT with external data, data is not loaded in this step.
536          */
537         sectors = get_aligned_image_size(info, size, 0);
538         buf = spl_get_fit_load_buffer(sectors * info->bl_len);
539
540         count = info->read(info, sector, sectors, buf);
541         ctx->fit = buf;
542         debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu, size=0x%lx\n",
543               sector, sectors, buf, count, size);
544
545         return (count == 0) ? -EIO : 0;
546 }
547
548 static int spl_simple_fit_parse(struct spl_fit_info *ctx)
549 {
550         /* Find the correct subnode under "/configurations" */
551         ctx->conf_node = fit_find_config_node(ctx->fit);
552         if (ctx->conf_node < 0)
553                 return -EINVAL;
554
555         if (IS_ENABLED(CONFIG_SPL_FIT_SIGNATURE)) {
556                 printf("## Checking hash(es) for config %s ... ",
557                        fit_get_name(ctx->fit, ctx->conf_node, NULL));
558                 if (fit_config_verify(ctx->fit, ctx->conf_node))
559                         return -EPERM;
560                 puts("OK\n");
561         }
562
563         /* find the node holding the images information */
564         ctx->images_node = fdt_path_offset(ctx->fit, FIT_IMAGES_PATH);
565         if (ctx->images_node < 0) {
566                 debug("%s: Cannot find /images node: %d\n", __func__,
567                       ctx->images_node);
568                 return -EINVAL;
569         }
570
571         return 0;
572 }
573
574 int spl_load_simple_fit(struct spl_image_info *spl_image,
575                         struct spl_load_info *info, ulong sector, void *fit)
576 {
577         struct spl_image_info image_info;
578         struct spl_fit_info ctx;
579         int node = -1;
580         int ret;
581         int index = 0;
582         int firmware_node;
583
584         ret = spl_simple_fit_read(&ctx, info, sector, fit);
585         if (ret < 0)
586                 return ret;
587
588         /* skip further processing if requested to enable load-only use cases */
589         if (spl_load_simple_fit_skip_processing())
590                 return 0;
591
592         ret = spl_simple_fit_parse(&ctx);
593         if (ret < 0)
594                 return ret;
595
596 #ifdef CONFIG_SPL_FPGA
597         node = spl_fit_get_image_node(&ctx, "fpga", 0);
598         if (node >= 0) {
599                 /* Load the image and set up the spl_image structure */
600                 ret = spl_load_fit_image(info, sector, &ctx, node, spl_image);
601                 if (ret) {
602                         printf("%s: Cannot load the FPGA: %i\n", __func__, ret);
603                         return ret;
604                 }
605
606                 debug("FPGA bitstream at: %x, size: %x\n",
607                       (u32)spl_image->load_addr, spl_image->size);
608
609                 ret = fpga_load(0, (const void *)spl_image->load_addr,
610                                 spl_image->size, BIT_FULL);
611                 if (ret) {
612                         printf("%s: Cannot load the image to the FPGA\n",
613                                __func__);
614                         return ret;
615                 }
616
617                 puts("FPGA image loaded from FIT\n");
618                 node = -1;
619         }
620 #endif
621
622         /*
623          * Find the U-Boot image using the following search order:
624          *   - start at 'firmware' (e.g. an ARM Trusted Firmware)
625          *   - fall back 'kernel' (e.g. a Falcon-mode OS boot
626          *   - fall back to using the first 'loadables' entry
627          */
628         if (node < 0)
629                 node = spl_fit_get_image_node(&ctx, FIT_FIRMWARE_PROP, 0);
630 #ifdef CONFIG_SPL_OS_BOOT
631         if (node < 0)
632                 node = spl_fit_get_image_node(&ctx, FIT_KERNEL_PROP, 0);
633 #endif
634         if (node < 0) {
635                 debug("could not find firmware image, trying loadables...\n");
636                 node = spl_fit_get_image_node(&ctx, "loadables", 0);
637                 /*
638                  * If we pick the U-Boot image from "loadables", start at
639                  * the second image when later loading additional images.
640                  */
641                 index = 1;
642         }
643         if (node < 0) {
644                 debug("%s: Cannot find u-boot image node: %d\n",
645                       __func__, node);
646                 return -1;
647         }
648
649         /* Load the image and set up the spl_image structure */
650         ret = spl_load_fit_image(info, sector, &ctx, node, spl_image);
651         if (ret)
652                 return ret;
653
654         /*
655          * For backward compatibility, we treat the first node that is
656          * as a U-Boot image, if no OS-type has been declared.
657          */
658         if (!spl_fit_image_get_os(ctx.fit, node, &spl_image->os))
659                 debug("Image OS is %s\n", genimg_get_os_name(spl_image->os));
660 #if !defined(CONFIG_SPL_OS_BOOT)
661         else
662                 spl_image->os = IH_OS_U_BOOT;
663 #endif
664
665         /*
666          * Booting a next-stage U-Boot may require us to append the FDT.
667          * We allow this to fail, as the U-Boot image might embed its FDT.
668          */
669         if (spl_image->os == IH_OS_U_BOOT) {
670                 ret = spl_fit_append_fdt(spl_image, info, sector, &ctx);
671                 if (!IS_ENABLED(CONFIG_OF_EMBED) && ret < 0)
672                         return ret;
673         }
674
675         firmware_node = node;
676         /* Now check if there are more images for us to load */
677         for (; ; index++) {
678                 uint8_t os_type = IH_OS_INVALID;
679
680                 node = spl_fit_get_image_node(&ctx, "loadables", index);
681                 if (node < 0)
682                         break;
683
684                 /*
685                  * if the firmware is also a loadable, skip it because
686                  * it already has been loaded. This is typically the case with
687                  * u-boot.img generated by mkimage.
688                  */
689                 if (firmware_node == node)
690                         continue;
691
692                 ret = spl_load_fit_image(info, sector, &ctx, node, &image_info);
693                 if (ret < 0) {
694                         printf("%s: can't load image loadables index %d (ret = %d)\n",
695                                __func__, index, ret);
696                         return ret;
697                 }
698
699                 if (!spl_fit_image_get_os(ctx.fit, node, &os_type))
700                         debug("Loadable is %s\n", genimg_get_os_name(os_type));
701
702                 if (os_type == IH_OS_U_BOOT) {
703                         spl_fit_append_fdt(&image_info, info, sector, &ctx);
704                         spl_image->fdt_addr = image_info.fdt_addr;
705                 }
706
707                 /*
708                  * If the "firmware" image did not provide an entry point,
709                  * use the first valid entry point from the loadables.
710                  */
711                 if (spl_image->entry_point == FDT_ERROR &&
712                     image_info.entry_point != FDT_ERROR)
713                         spl_image->entry_point = image_info.entry_point;
714
715                 /* Record our loadables into the FDT */
716                 if (spl_image->fdt_addr)
717                         spl_fit_record_loadable(&ctx, index,
718                                                 spl_image->fdt_addr,
719                                                 &image_info);
720         }
721
722         /*
723          * If a platform does not provide CONFIG_SYS_UBOOT_START, U-Boot's
724          * Makefile will set it to 0 and it will end up as the entry point
725          * here. What it actually means is: use the load address.
726          */
727         if (spl_image->entry_point == FDT_ERROR || spl_image->entry_point == 0)
728                 spl_image->entry_point = spl_image->load_addr;
729
730         spl_image->flags |= SPL_FIT_FOUND;
731
732 #ifdef CONFIG_IMX_HAB
733         board_spl_fit_post_load(ctx.fit);
734 #endif
735
736         return 0;
737 }