blob: 75c41598e6bc22d223e1cda65c7272b6a7246fb4 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -04002/*
3 * (C) Copyright 2010
4 * Texas Instruments, <www.ti.com>
5 *
6 * Aneesh V <aneesh@ti.com>
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -04007 */
8#include <common.h>
Simon Glassdc3dedf2015-06-23 15:38:51 -06009#include <dm.h>
Tom Rini47f7bca2012-08-13 12:03:19 -070010#include <spl.h>
Paul Kocialkowski91199f42015-04-27 10:20:22 +020011#include <linux/compiler.h>
Nikita Kiryanov36afd452015-11-08 17:11:49 +020012#include <errno.h>
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -040013#include <asm/u-boot.h>
Nikita Kiryanov4188ba32015-11-08 17:11:44 +020014#include <errno.h>
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -040015#include <mmc.h>
Tom Rinie4c444b2013-06-28 14:43:01 -040016#include <image.h>
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -040017
Simon Glass2a2ee2a2016-09-24 18:20:13 -060018static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
19 ulong sector, struct image_header *header)
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -040020{
Peter Korsgaard2e222102013-03-21 04:55:17 +000021 u32 image_size_sectors;
Simon Glass96debd12016-02-22 22:55:58 -070022 unsigned long count;
Marek Vasut7e0f2262016-04-29 00:44:54 +020023 int ret;
Tom Rinie4c444b2013-06-28 14:43:01 -040024
Simon Glass2a2ee2a2016-09-24 18:20:13 -060025 ret = spl_parse_image_header(spl_image, header);
Marek Vasut7e0f2262016-04-29 00:44:54 +020026 if (ret)
27 return ret;
28
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -040029 /* convert size to sectors - round up */
Simon Glass2a2ee2a2016-09-24 18:20:13 -060030 image_size_sectors = (spl_image->size + mmc->read_bl_len - 1) /
Paul Kocialkowski91199f42015-04-27 10:20:22 +020031 mmc->read_bl_len;
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -040032
33 /* Read the header too to avoid extra memcpy */
Simon Glassef5609c2016-05-14 14:03:06 -060034 count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors,
Simon Glass2a2ee2a2016-09-24 18:20:13 -060035 (void *)(ulong)spl_image->load_addr);
Andre Przywara11e14792017-01-02 11:48:31 +000036 debug("read %x sectors to %lx\n", image_size_sectors,
Simon Glass2a2ee2a2016-09-24 18:20:13 -060037 spl_image->load_addr);
Simon Glass96debd12016-02-22 22:55:58 -070038 if (count != image_size_sectors)
39 return -EIO;
40
41 return 0;
42}
43
Simon Glass96debd12016-02-22 22:55:58 -070044static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
45 ulong count, void *buf)
46{
47 struct mmc *mmc = load->dev;
48
Simon Glassef5609c2016-05-14 14:03:06 -060049 return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
Simon Glass96debd12016-02-22 22:55:58 -070050}
Simon Glass96debd12016-02-22 22:55:58 -070051
Seung-Woo Kimb016b582017-09-19 13:29:45 +090052static __maybe_unused
53int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
54 struct mmc *mmc, unsigned long sector)
Simon Glass96debd12016-02-22 22:55:58 -070055{
56 unsigned long count;
57 struct image_header *header;
Marek Vasut04ce5422018-08-14 11:27:02 +020058 struct blk_desc *bd = mmc_get_blk_desc(mmc);
Simon Glass96debd12016-02-22 22:55:58 -070059 int ret = 0;
60
Marek Vasut04ce5422018-08-14 11:27:02 +020061 header = spl_get_load_buffer(-sizeof(*header), bd->blksz);
Simon Glass96debd12016-02-22 22:55:58 -070062
63 /* read image header to find the image size & load address */
Marek Vasut04ce5422018-08-14 11:27:02 +020064 count = blk_dread(bd, sector, 1, header);
Simon Glass96debd12016-02-22 22:55:58 -070065 debug("hdr read sector %lx, count=%lu\n", sector, count);
66 if (count == 0) {
67 ret = -EIO;
68 goto end;
69 }
70
Masahiro Yamada4976f482016-03-16 12:10:00 +090071 if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
72 image_get_magic(header) == FDT_MAGIC) {
Simon Glass96debd12016-02-22 22:55:58 -070073 struct spl_load_info load;
74
75 debug("Found FIT\n");
76 load.dev = mmc;
77 load.priv = NULL;
Lokesh Vutlaeafd5412016-05-24 10:34:38 +053078 load.filename = NULL;
Simon Glass96debd12016-02-22 22:55:58 -070079 load.bl_len = mmc->read_bl_len;
80 load.read = h_spl_load_read;
Simon Glassf4d7d852016-09-24 18:20:16 -060081 ret = spl_load_simple_fit(spl_image, &load, sector, header);
Masahiro Yamada4976f482016-03-16 12:10:00 +090082 } else {
Simon Glass2a2ee2a2016-09-24 18:20:13 -060083 ret = mmc_load_legacy(spl_image, mmc, sector, header);
Simon Glass96debd12016-02-22 22:55:58 -070084 }
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -040085
86end:
Simon Glass96debd12016-02-22 22:55:58 -070087 if (ret) {
Paul Burton8112f5f2013-09-04 16:12:24 +010088#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
Fabio Estevam5bbf4092016-04-20 23:12:04 -030089 puts("mmc_load_image_raw_sector: mmc block read error\n");
Paul Burton8112f5f2013-09-04 16:12:24 +010090#endif
Paul Kocialkowski3bc37b62015-05-22 12:45:35 +020091 return -1;
Paul Kocialkowski1ec26462015-06-03 18:48:51 +020092 }
Paul Kocialkowski3bc37b62015-05-22 12:45:35 +020093
94 return 0;
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -040095}
96
Masahiro Yamada207d8b32017-06-22 16:52:36 +090097static int spl_mmc_get_device_index(u32 boot_device)
Nikita Kiryanova1e56cf2015-11-08 17:11:54 +020098{
99 switch (boot_device) {
100 case BOOT_DEVICE_MMC1:
101 return 0;
102 case BOOT_DEVICE_MMC2:
103 case BOOT_DEVICE_MMC2_2:
104 return 1;
105 }
106
107#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
108 printf("spl: unsupported mmc boot device.\n");
109#endif
110
111 return -ENODEV;
112}
113
Simon Glass99c7a512015-12-02 10:59:12 -0700114static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device)
Nikita Kiryanov4188ba32015-11-08 17:11:44 +0200115{
Simon Glassc4d660d2017-07-04 13:31:19 -0600116#if CONFIG_IS_ENABLED(DM_MMC)
Nikita Kiryanov4188ba32015-11-08 17:11:44 +0200117 struct udevice *dev;
Simon Glassb4857aa2015-12-02 10:59:13 -0700118#endif
Nikita Kiryanova1e56cf2015-11-08 17:11:54 +0200119 int err, mmc_dev;
120
121 mmc_dev = spl_mmc_get_device_index(boot_device);
122 if (mmc_dev < 0)
123 return mmc_dev;
Nikita Kiryanov4188ba32015-11-08 17:11:44 +0200124
125 err = mmc_initialize(NULL);
126 if (err) {
127#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
128 printf("spl: could not initialize mmc. error: %d\n", err);
129#endif
130 return err;
131 }
132
Simon Glassc4d660d2017-07-04 13:31:19 -0600133#if CONFIG_IS_ENABLED(DM_MMC)
Nikita Kiryanova1e56cf2015-11-08 17:11:54 +0200134 err = uclass_get_device(UCLASS_MMC, mmc_dev, &dev);
Simon Glassb4857aa2015-12-02 10:59:13 -0700135 if (!err)
136 *mmcp = mmc_get_mmc_dev(dev);
137#else
138 *mmcp = find_mmc_device(mmc_dev);
139 err = *mmcp ? 0 : -ENODEV;
140#endif
Nikita Kiryanov4188ba32015-11-08 17:11:44 +0200141 if (err) {
142#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
143 printf("spl: could not find mmc device. error: %d\n", err);
144#endif
145 return err;
146 }
147
Nikita Kiryanov4188ba32015-11-08 17:11:44 +0200148 return 0;
149}
Nikita Kiryanov4188ba32015-11-08 17:11:44 +0200150
Dalon Westergreen949123e2017-02-10 17:15:35 -0800151#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600152static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
153 struct mmc *mmc, int partition)
Paul Kocialkowskib97300b2014-11-08 23:14:56 +0100154{
155 disk_partition_t info;
Paul Kocialkowski3bc37b62015-05-22 12:45:35 +0200156 int err;
Paul Kocialkowskib97300b2014-11-08 23:14:56 +0100157
Dalon Westergreenf0fb4fa2017-02-10 17:15:34 -0800158#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
159 int type_part;
160 /* Only support MBR so DOS_ENTRY_NUMBERS */
161 for (type_part = 1; type_part <= DOS_ENTRY_NUMBERS; type_part++) {
162 err = part_get_info(mmc_get_blk_desc(mmc), type_part, &info);
163 if (err)
164 continue;
165 if (info.sys_ind ==
166 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE) {
167 partition = type_part;
168 break;
169 }
170 }
171#endif
172
Simon Glass1e2b3ef2016-07-05 17:10:18 -0600173 err = part_get_info(mmc_get_blk_desc(mmc), partition, &info);
Paul Kocialkowski3bc37b62015-05-22 12:45:35 +0200174 if (err) {
Paul Kocialkowskib97300b2014-11-08 23:14:56 +0100175#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
Paul Kocialkowski1ec26462015-06-03 18:48:51 +0200176 puts("spl: partition error\n");
Paul Kocialkowskib97300b2014-11-08 23:14:56 +0100177#endif
178 return -1;
179 }
180
Semen Protsenko38fed8a2016-11-16 19:19:05 +0200181#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600182 return mmc_load_image_raw_sector(spl_image, mmc,
183 info.start + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
Stefan Roese4bfcc542015-07-20 11:20:39 +0200184#else
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600185 return mmc_load_image_raw_sector(spl_image, mmc, info.start);
Stefan Roese4bfcc542015-07-20 11:20:39 +0200186#endif
Paul Kocialkowskib97300b2014-11-08 23:14:56 +0100187}
188#endif
189
Peter Korsgaard2b75b0a2013-05-13 08:36:29 +0000190#ifdef CONFIG_SPL_OS_BOOT
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600191static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
192 struct mmc *mmc)
Peter Korsgaard2b75b0a2013-05-13 08:36:29 +0000193{
Lokesh Vutla811906a2016-04-11 15:24:50 +0530194 int ret;
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200195
York Sun7267fbf2018-06-26 09:44:39 -0700196#if defined(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)
197 unsigned long count;
198
Simon Glass87bce4e2016-06-12 23:30:32 -0600199 count = blk_dread(mmc_get_blk_desc(mmc),
Paul Kocialkowski3bc37b62015-05-22 12:45:35 +0200200 CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
201 CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
202 (void *) CONFIG_SYS_SPL_ARGS_ADDR);
Tom Rini9585dd32017-08-14 21:01:30 -0400203 if (count != CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS) {
Paul Burton8112f5f2013-09-04 16:12:24 +0100204#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
Fabio Estevam5bbf4092016-04-20 23:12:04 -0300205 puts("mmc_load_image_raw_os: mmc block read error\n");
Paul Burton8112f5f2013-09-04 16:12:24 +0100206#endif
Peter Korsgaard2b75b0a2013-05-13 08:36:29 +0000207 return -1;
208 }
York Sun7267fbf2018-06-26 09:44:39 -0700209#endif /* CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR */
Peter Korsgaard2b75b0a2013-05-13 08:36:29 +0000210
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600211 ret = mmc_load_image_raw_sector(spl_image, mmc,
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200212 CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
Lokesh Vutla811906a2016-04-11 15:24:50 +0530213 if (ret)
214 return ret;
215
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600216 if (spl_image->os != IH_OS_LINUX) {
Lokesh Vutla811906a2016-04-11 15:24:50 +0530217 puts("Expected Linux image is not found. Trying to start U-boot\n");
218 return -ENOENT;
219 }
220
221 return 0;
Peter Korsgaard2b75b0a2013-05-13 08:36:29 +0000222}
Nikita Kiryanov339245b2015-11-08 17:11:45 +0200223#else
224int spl_start_uboot(void)
225{
226 return 1;
227}
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600228static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
229 struct mmc *mmc)
Nikita Kiryanov339245b2015-11-08 17:11:45 +0200230{
231 return -ENOSYS;
232}
Peter Korsgaard2b75b0a2013-05-13 08:36:29 +0000233#endif
234
Nikita Kiryanovf52b7292015-11-08 17:11:47 +0200235#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600236static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
Nikita Kiryanovf52b7292015-11-08 17:11:47 +0200237{
238 int err = -ENOSYS;
239
240#ifdef CONFIG_SPL_FAT_SUPPORT
241 if (!spl_start_uboot()) {
Simon Glass710e9ca2016-09-24 18:20:15 -0600242 err = spl_load_image_fat_os(spl_image, mmc_get_blk_desc(mmc),
Nikita Kiryanovf52b7292015-11-08 17:11:47 +0200243 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
244 if (!err)
245 return err;
246 }
247#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
Simon Glass710e9ca2016-09-24 18:20:15 -0600248 err = spl_load_image_fat(spl_image, mmc_get_blk_desc(mmc),
Nikita Kiryanovf52b7292015-11-08 17:11:47 +0200249 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
250 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
251 if (!err)
252 return err;
253#endif
254#endif
255#ifdef CONFIG_SPL_EXT_SUPPORT
256 if (!spl_start_uboot()) {
Michal Simek1a925412016-12-01 11:09:01 +0100257 err = spl_load_image_ext_os(spl_image, mmc_get_blk_desc(mmc),
Nikita Kiryanovf52b7292015-11-08 17:11:47 +0200258 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
259 if (!err)
260 return err;
261 }
262#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
Michal Simek1a925412016-12-01 11:09:01 +0100263 err = spl_load_image_ext(spl_image, mmc_get_blk_desc(mmc),
Nikita Kiryanovf52b7292015-11-08 17:11:47 +0200264 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
265 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
266 if (!err)
267 return err;
268#endif
269#endif
270
271#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
272 err = -ENOENT;
273#endif
274
275 return err;
276}
277#else
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600278static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
Nikita Kiryanovf52b7292015-11-08 17:11:47 +0200279{
280 return -ENOSYS;
281}
282#endif
283
Lukasz Majewskid695d662018-02-03 08:29:52 +0100284u32 __weak spl_boot_mode(const u32 boot_device)
285{
286#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
287 return MMCSD_MODE_FS;
288#elif defined(CONFIG_SUPPORT_EMMC_BOOT)
289 return MMCSD_MODE_EMMCBOOT;
290#else
291 return MMCSD_MODE_RAW;
292#endif
293}
294
Patrick Delaunay35a66962018-03-20 10:54:51 +0100295#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
296__weak
297int spl_boot_partition(const u32 boot_device)
298{
299 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
300}
301#endif
302
Marek Vasut09410c62016-12-01 02:06:35 +0100303int spl_mmc_load_image(struct spl_image_info *spl_image,
304 struct spl_boot_device *bootdev)
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -0400305{
Simon Glassd773a002015-12-02 10:59:11 -0700306 struct mmc *mmc = NULL;
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -0400307 u32 boot_mode;
Simon Glassdc3dedf2015-06-23 15:38:51 -0600308 int err = 0;
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200309 __maybe_unused int part;
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -0400310
Simon Glassecdfd692016-09-24 18:19:57 -0600311 err = spl_mmc_find_device(&mmc, bootdev->boot_device);
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200312 if (err)
313 return err;
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -0400314
Nikita Kiryanov4188ba32015-11-08 17:11:44 +0200315 err = mmc_init(mmc);
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -0400316 if (err) {
Paul Burton8112f5f2013-09-04 16:12:24 +0100317#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200318 printf("spl: mmc init failed with error: %d\n", err);
Paul Burton8112f5f2013-09-04 16:12:24 +0100319#endif
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200320 return err;
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -0400321 }
Peter Korsgaard79adb7a2013-05-13 08:36:25 +0000322
Simon Glassecdfd692016-09-24 18:19:57 -0600323 boot_mode = spl_boot_mode(bootdev->boot_device);
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200324 err = -EINVAL;
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200325 switch (boot_mode) {
Nikita Kiryanov83cdf6f2015-11-08 17:11:48 +0200326 case MMCSD_MODE_EMMCBOOT:
327 /*
328 * We need to check what the partition is configured to.
329 * 1 and 2 match up to boot0 / boot1 and 7 is user data
330 * which is the first physical partition (0).
331 */
332 part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
333
334 if (part == 7)
335 part = 0;
336
Marek Vasutb5b838f2016-12-01 02:06:33 +0100337 if (CONFIG_IS_ENABLED(MMC_TINY))
338 err = mmc_switch_part(mmc, part);
339 else
340 err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part);
341
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200342 if (err) {
Nikita Kiryanov83cdf6f2015-11-08 17:11:48 +0200343#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
344 puts("spl: mmc partition switch failed\n");
345#endif
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200346 return err;
Nikita Kiryanov83cdf6f2015-11-08 17:11:48 +0200347 }
348 /* Fall through */
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200349 case MMCSD_MODE_RAW:
350 debug("spl: mmc boot mode: raw\n");
351
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200352 if (!spl_start_uboot()) {
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600353 err = mmc_load_image_raw_os(spl_image, mmc);
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200354 if (!err)
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200355 return err;
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200356 }
Dalon Westergreen949123e2017-02-10 17:15:35 -0800357#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
Patrick Delaunay35a66962018-03-20 10:54:51 +0100358 err = spl_boot_partition(bootdev->boot_device);
359 if (!err)
360 return err;
361
362 err = mmc_load_image_raw_partition(spl_image, mmc, err);
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200363 if (!err)
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200364 return err;
Dalon Westergreen949123e2017-02-10 17:15:35 -0800365#endif
Semen Protsenko38fed8a2016-11-16 19:19:05 +0200366#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600367 err = mmc_load_image_raw_sector(spl_image, mmc,
Paul Kocialkowski3ae8f4c2015-06-08 23:05:09 +0200368 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
369 if (!err)
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200370 return err;
Paul Kocialkowski3ae8f4c2015-06-08 23:05:09 +0200371#endif
Guillaume GARDET86a0df72016-02-18 18:17:36 +0100372 /* If RAW mode fails, try FS mode. */
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200373 case MMCSD_MODE_FS:
374 debug("spl: mmc boot mode: fs\n");
375
Simon Glass2a2ee2a2016-09-24 18:20:13 -0600376 err = spl_mmc_do_fs_boot(spl_image, mmc);
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200377 if (!err)
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200378 return err;
Nikita Kiryanovf52b7292015-11-08 17:11:47 +0200379
Nikita Kiryanovfd61d392015-11-08 17:11:43 +0200380 break;
Guillaume GARDET2c84c9a2014-12-16 12:00:44 +0100381#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
Nikita Kiryanovfd61d392015-11-08 17:11:43 +0200382 default:
383 puts("spl: mmc: wrong boot mode\n");
Guillaume GARDET2c84c9a2014-12-16 12:00:44 +0100384#endif
Paul Kocialkowski91199f42015-04-27 10:20:22 +0200385 }
Nikita Kiryanovfd61d392015-11-08 17:11:43 +0200386
Nikita Kiryanov36afd452015-11-08 17:11:49 +0200387 return err;
Simon Schwarz9ea5c6e2011-09-14 15:33:34 -0400388}
Simon Glass0fed9c72016-09-24 18:20:00 -0600389
Simon Glassebc4ef62016-11-30 15:30:50 -0700390SPL_LOAD_IMAGE_METHOD("MMC1", 0, BOOT_DEVICE_MMC1, spl_mmc_load_image);
391SPL_LOAD_IMAGE_METHOD("MMC2", 0, BOOT_DEVICE_MMC2, spl_mmc_load_image);
392SPL_LOAD_IMAGE_METHOD("MMC2_2", 0, BOOT_DEVICE_MMC2_2, spl_mmc_load_image);