arm64: zynqmp: Add SMMU support for SATA IP
[oweals/u-boot.git] / common / spl / spl_ubi.c
index f97e1ef680bdb3e4f3cdcf08c95b8f6554d73c05..83089335a7887714cdb572d26bd2dac5ed98d445 100644 (file)
 #include <ubispl.h>
 #include <spl.h>
 
-int spl_ubi_load_image(u32 boot_device)
+int spl_ubi_load_image(struct spl_image_info *spl_image,
+                      struct spl_boot_device *bootdev)
 {
        struct image_header *header;
        struct ubispl_info info;
        struct ubispl_load volumes[2];
        int ret = 1;
 
-       switch (boot_device) {
+       switch (bootdev->boot_device) {
 #ifdef CONFIG_SPL_NAND_SUPPORT
        case BOOT_DEVICE_NAND:
                nand_init();
@@ -37,7 +38,7 @@ int spl_ubi_load_image(u32 boot_device)
                goto out;
        }
        info.ubi = (struct ubi_scan_info *)CONFIG_SPL_UBI_INFO_ADDR;
-       info.fastmap = 1;
+       info.fastmap = IS_ENABLED(CONFIG_MTD_UBI_FASTMAP);
 
        info.peb_offset = CONFIG_SPL_UBI_PEB_OFFSET;
        info.vid_offset = CONFIG_SPL_UBI_VID_OFFSET;
@@ -54,7 +55,7 @@ int spl_ubi_load_image(u32 boot_device)
                ret = ubispl_load_volumes(&info, volumes, 2);
                if (!ret) {
                        header = (struct image_header *)volumes[0].load_addr;
-                       spl_parse_image_header(header);
+                       spl_parse_image_header(spl_image, header);
                        puts("Linux loaded.\n");
                        goto out;
                }
@@ -68,11 +69,14 @@ int spl_ubi_load_image(u32 boot_device)
 
        ret = ubispl_load_volumes(&info, volumes, 1);
        if (!ret)
-               spl_parse_image_header(header);
+               spl_parse_image_header(spl_image, header);
 out:
 #ifdef CONFIG_SPL_NAND_SUPPORT
-       if (boot_device == BOOT_DEVICE_NAND)
+       if (bootdev->boot_device == BOOT_DEVICE_NAND)
                nand_deselect();
 #endif
        return ret;
 }
+/* Use priorty 0 so that Ubi will override NAND and ONENAND methods */
+SPL_LOAD_IMAGE_METHOD("NAND", 0, BOOT_DEVICE_NAND, spl_ubi_load_image);
+SPL_LOAD_IMAGE_METHOD("OneNAND", 0, BOOT_DEVICE_ONENAND, spl_ubi_load_image);