X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fspl%2Fspl_ubi.c;h=a7939e90305f1250b5806cdd268e54fb097e77ea;hb=4549e789c1d58a8c48e8a20f1b4bdb83e978c954;hp=f97e1ef680bdb3e4f3cdcf08c95b8f6554d73c05;hpb=4711e7f7af839b41a6d78490257a9e7975494dd3;p=oweals%2Fu-boot.git diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c index f97e1ef680..a7939e9030 100644 --- a/common/spl/spl_ubi.c +++ b/common/spl/spl_ubi.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause /* * Copyright (C) 2016 * Ladislav Michl - * - * SPDX-License-Identifier: GPL 2.0+ BSD-3-Clause */ #include @@ -12,14 +11,15 @@ #include #include -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);