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>
18 static int fat_registered;
20 #ifdef CONFIG_SPL_FAT_SUPPORT
21 static int spl_register_fat_device(block_dev_desc_t *block_dev, int partition)
28 err = fat_register_device(block_dev, partition);
30 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
31 printf("%s: fat register err - %d\n", __func__, err);
41 int spl_load_image_fat(block_dev_desc_t *block_dev,
46 struct image_header *header;
48 err = spl_register_fat_device(block_dev, partition);
52 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
53 sizeof(struct image_header));
55 err = file_fat_read(filename, header, sizeof(struct image_header));
59 spl_parse_image_header(header);
61 err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
64 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
66 printf("%s: error reading image %s, err - %d\n",
67 __func__, filename, err);
73 #ifdef CONFIG_SPL_OS_BOOT
74 int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition)
77 __maybe_unused char *file;
79 err = spl_register_fat_device(block_dev, partition);
83 #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
84 file = getenv("falcon_args_file");
86 err = file_fat_read(file, (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
88 printf("spl: error reading image %s, err - %d, falling back to default\n",
92 file = getenv("falcon_image_file");
94 err = spl_load_image_fat(block_dev, partition, file);
96 puts("spl: falling back to default\n");
102 puts("spl: falcon_image_file not set in environment, falling back to default\n");
104 puts("spl: falcon_args_file not set in environment, falling back to default\n");
109 err = file_fat_read(CONFIG_SPL_FAT_LOAD_ARGS_NAME,
110 (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
112 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
113 printf("%s: error reading image %s, err - %d\n",
114 __func__, CONFIG_SPL_FAT_LOAD_ARGS_NAME, err);
119 return spl_load_image_fat(block_dev, partition,
120 CONFIG_SPL_FAT_LOAD_KERNEL_NAME);