SPDX: Convert all of our multiple license tags to Linux Kernel style
[oweals/u-boot.git] / common / spl / spl_ubi.c
index f97e1ef680bdb3e4f3cdcf08c95b8f6554d73c05..a7939e90305f1250b5806cdd268e54fb097e77ea 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 /*
  * Copyright (C) 2016
  * Ladislav Michl <ladis@linux-mips.org>
- *
- * SPDX-License-Identifier: GPL 2.0+ BSD-3-Clause
  */
 
 #include <common.h>
 #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 +37,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 +54,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 +68,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);