3 * Texas Instruments, <www.ti.com>
5 * Dan Murphy <dmurphy@ti.com>
7 * SPDX-License-Identifier: GPL-2.0+
9 * FAT Image Functions copied from spl_mmc.c
14 #include <asm/u-boot.h>
19 static int fat_registered;
21 #ifdef CONFIG_SPL_FAT_SUPPORT
22 static int spl_register_fat_device(struct blk_desc *block_dev, int partition)
29 err = fat_register_device(block_dev, partition);
31 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
32 printf("%s: fat register err - %d\n", __func__, err);
42 int spl_load_image_fat(struct blk_desc *block_dev,
47 struct image_header *header;
49 err = spl_register_fat_device(block_dev, partition);
53 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
54 sizeof(struct image_header));
56 err = file_fat_read(filename, header, sizeof(struct image_header));
60 err = spl_parse_image_header(header);
64 err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
67 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
69 printf("%s: error reading image %s, err - %d\n",
70 __func__, filename, err);
76 #ifdef CONFIG_SPL_OS_BOOT
77 int spl_load_image_fat_os(struct blk_desc *block_dev, int partition)
80 __maybe_unused char *file;
82 err = spl_register_fat_device(block_dev, partition);
86 #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
87 file = getenv("falcon_args_file");
89 err = file_fat_read(file, (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
91 printf("spl: error reading image %s, err - %d, falling back to default\n",
95 file = getenv("falcon_image_file");
97 err = spl_load_image_fat(block_dev, partition, file);
99 puts("spl: falling back to default\n");
105 puts("spl: falcon_image_file not set in environment, falling back to default\n");
107 puts("spl: falcon_args_file not set in environment, falling back to default\n");
112 err = file_fat_read(CONFIG_SPL_FS_LOAD_ARGS_NAME,
113 (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
115 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
116 printf("%s: error reading image %s, err - %d\n",
117 __func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
122 return spl_load_image_fat(block_dev, partition,
123 CONFIG_SPL_FS_LOAD_KERNEL_NAME);
126 int spl_load_image_fat_os(struct blk_desc *block_dev, int partition)