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(block_dev_desc_t *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(block_dev_desc_t *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 spl_parse_image_header(header);
62 err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
65 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
67 printf("%s: error reading image %s, err - %d\n",
68 __func__, filename, err);
74 #ifdef CONFIG_SPL_OS_BOOT
75 int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition)
78 __maybe_unused char *file;
80 err = spl_register_fat_device(block_dev, partition);
84 #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
85 file = getenv("falcon_args_file");
87 err = file_fat_read(file, (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
89 printf("spl: error reading image %s, err - %d, falling back to default\n",
93 file = getenv("falcon_image_file");
95 err = spl_load_image_fat(block_dev, partition, file);
97 puts("spl: falling back to default\n");
103 puts("spl: falcon_image_file not set in environment, falling back to default\n");
105 puts("spl: falcon_args_file not set in environment, falling back to default\n");
110 err = file_fat_read(CONFIG_SPL_FS_LOAD_ARGS_NAME,
111 (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
113 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
114 printf("%s: error reading image %s, err - %d\n",
115 __func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
120 return spl_load_image_fat(block_dev, partition,
121 CONFIG_SPL_FS_LOAD_KERNEL_NAME);
124 int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition)