2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2011-09-14 19:33:34 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2010
|
|
|
|
* Texas Instruments, <www.ti.com>
|
|
|
|
*
|
|
|
|
* Aneesh V <aneesh@ti.com>
|
|
|
|
*/
|
|
|
|
#include <common.h>
|
2015-06-23 21:38:51 +00:00
|
|
|
#include <dm.h>
|
2012-08-13 19:03:19 +00:00
|
|
|
#include <spl.h>
|
2015-04-27 08:20:22 +00:00
|
|
|
#include <linux/compiler.h>
|
2015-11-08 15:11:49 +00:00
|
|
|
#include <errno.h>
|
2011-09-14 19:33:34 +00:00
|
|
|
#include <asm/u-boot.h>
|
2015-11-08 15:11:44 +00:00
|
|
|
#include <errno.h>
|
2011-09-14 19:33:34 +00:00
|
|
|
#include <mmc.h>
|
2013-06-28 18:43:01 +00:00
|
|
|
#include <image.h>
|
2011-09-14 19:33:34 +00:00
|
|
|
|
2016-09-25 00:20:13 +00:00
|
|
|
static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
|
|
|
|
ulong sector, struct image_header *header)
|
2016-02-23 05:55:58 +00:00
|
|
|
{
|
|
|
|
u32 image_size_sectors;
|
|
|
|
unsigned long count;
|
2016-04-28 22:44:54 +00:00
|
|
|
int ret;
|
|
|
|
|
2016-09-25 00:20:13 +00:00
|
|
|
ret = spl_parse_image_header(spl_image, header);
|
2016-04-28 22:44:54 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2016-02-23 05:55:58 +00:00
|
|
|
|
|
|
|
/* convert size to sectors - round up */
|
2016-09-25 00:20:13 +00:00
|
|
|
image_size_sectors = (spl_image->size + mmc->read_bl_len - 1) /
|
2016-02-23 05:55:58 +00:00
|
|
|
mmc->read_bl_len;
|
|
|
|
|
|
|
|
/* Read the header too to avoid extra memcpy */
|
2016-05-14 20:03:06 +00:00
|
|
|
count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors,
|
2016-09-25 00:20:13 +00:00
|
|
|
(void *)(ulong)spl_image->load_addr);
|
2017-01-02 11:48:31 +00:00
|
|
|
debug("read %x sectors to %lx\n", image_size_sectors,
|
2016-09-25 00:20:13 +00:00
|
|
|
spl_image->load_addr);
|
2016-02-23 05:55:58 +00:00
|
|
|
if (count != image_size_sectors)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
|
|
|
|
ulong count, void *buf)
|
|
|
|
{
|
|
|
|
struct mmc *mmc = load->dev;
|
|
|
|
|
2016-05-14 20:03:06 +00:00
|
|
|
return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
|
2016-02-23 05:55:58 +00:00
|
|
|
}
|
|
|
|
|
2017-09-19 04:29:45 +00:00
|
|
|
static __maybe_unused
|
|
|
|
int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
|
|
|
|
struct mmc *mmc, unsigned long sector)
|
2011-09-14 19:33:34 +00:00
|
|
|
{
|
2015-05-22 10:45:35 +00:00
|
|
|
unsigned long count;
|
2013-03-21 04:55:17 +00:00
|
|
|
struct image_header *header;
|
2016-02-23 05:55:58 +00:00
|
|
|
int ret = 0;
|
2011-09-14 19:33:34 +00:00
|
|
|
|
|
|
|
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
|
2015-04-27 08:20:22 +00:00
|
|
|
sizeof(struct image_header));
|
2011-09-14 19:33:34 +00:00
|
|
|
|
|
|
|
/* read image header to find the image size & load address */
|
2016-05-14 20:03:06 +00:00
|
|
|
count = blk_dread(mmc_get_blk_desc(mmc), sector, 1, header);
|
2016-02-23 05:55:58 +00:00
|
|
|
debug("hdr read sector %lx, count=%lu\n", sector, count);
|
|
|
|
if (count == 0) {
|
|
|
|
ret = -EIO;
|
2011-09-14 19:33:34 +00:00
|
|
|
goto end;
|
2016-02-23 05:55:58 +00:00
|
|
|
}
|
2011-09-14 19:33:34 +00:00
|
|
|
|
2016-03-16 03:10:00 +00:00
|
|
|
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
|
|
|
|
image_get_magic(header) == FDT_MAGIC) {
|
2016-02-23 05:55:58 +00:00
|
|
|
struct spl_load_info load;
|
|
|
|
|
|
|
|
debug("Found FIT\n");
|
|
|
|
load.dev = mmc;
|
|
|
|
load.priv = NULL;
|
2016-05-24 05:04:38 +00:00
|
|
|
load.filename = NULL;
|
2016-02-23 05:55:58 +00:00
|
|
|
load.bl_len = mmc->read_bl_len;
|
|
|
|
load.read = h_spl_load_read;
|
2016-09-25 00:20:16 +00:00
|
|
|
ret = spl_load_simple_fit(spl_image, &load, sector, header);
|
2016-03-16 03:10:00 +00:00
|
|
|
} else {
|
2016-09-25 00:20:13 +00:00
|
|
|
ret = mmc_load_legacy(spl_image, mmc, sector, header);
|
2015-06-23 21:38:47 +00:00
|
|
|
}
|
2013-06-28 18:43:01 +00:00
|
|
|
|
2011-09-14 19:33:34 +00:00
|
|
|
end:
|
2016-02-23 05:55:58 +00:00
|
|
|
if (ret) {
|
2013-09-04 15:12:24 +00:00
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
2016-04-21 02:12:04 +00:00
|
|
|
puts("mmc_load_image_raw_sector: mmc block read error\n");
|
2013-09-04 15:12:24 +00:00
|
|
|
#endif
|
2015-05-22 10:45:35 +00:00
|
|
|
return -1;
|
2015-06-03 16:48:51 +00:00
|
|
|
}
|
2015-05-22 10:45:35 +00:00
|
|
|
|
|
|
|
return 0;
|
2011-09-14 19:33:34 +00:00
|
|
|
}
|
|
|
|
|
2017-06-22 07:52:36 +00:00
|
|
|
static int spl_mmc_get_device_index(u32 boot_device)
|
2015-11-08 15:11:54 +00:00
|
|
|
{
|
|
|
|
switch (boot_device) {
|
|
|
|
case BOOT_DEVICE_MMC1:
|
|
|
|
return 0;
|
|
|
|
case BOOT_DEVICE_MMC2:
|
|
|
|
case BOOT_DEVICE_MMC2_2:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
|
|
|
printf("spl: unsupported mmc boot device.\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:59:12 +00:00
|
|
|
static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device)
|
2015-11-08 15:11:44 +00:00
|
|
|
{
|
2017-07-04 19:31:19 +00:00
|
|
|
#if CONFIG_IS_ENABLED(DM_MMC)
|
2015-11-08 15:11:44 +00:00
|
|
|
struct udevice *dev;
|
2015-12-02 17:59:13 +00:00
|
|
|
#endif
|
2015-11-08 15:11:54 +00:00
|
|
|
int err, mmc_dev;
|
|
|
|
|
|
|
|
mmc_dev = spl_mmc_get_device_index(boot_device);
|
|
|
|
if (mmc_dev < 0)
|
|
|
|
return mmc_dev;
|
2015-11-08 15:11:44 +00:00
|
|
|
|
|
|
|
err = mmc_initialize(NULL);
|
|
|
|
if (err) {
|
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
|
|
|
printf("spl: could not initialize mmc. error: %d\n", err);
|
|
|
|
#endif
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2017-07-04 19:31:19 +00:00
|
|
|
#if CONFIG_IS_ENABLED(DM_MMC)
|
2015-11-08 15:11:54 +00:00
|
|
|
err = uclass_get_device(UCLASS_MMC, mmc_dev, &dev);
|
2015-12-02 17:59:13 +00:00
|
|
|
if (!err)
|
|
|
|
*mmcp = mmc_get_mmc_dev(dev);
|
2015-11-08 15:11:44 +00:00
|
|
|
#else
|
2015-12-02 17:59:13 +00:00
|
|
|
*mmcp = find_mmc_device(mmc_dev);
|
|
|
|
err = *mmcp ? 0 : -ENODEV;
|
|
|
|
#endif
|
2015-11-08 15:11:44 +00:00
|
|
|
if (err) {
|
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
2015-12-02 17:59:13 +00:00
|
|
|
printf("spl: could not find mmc device. error: %d\n", err);
|
2015-11-08 15:11:44 +00:00
|
|
|
#endif
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-11 01:15:35 +00:00
|
|
|
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
|
2016-09-25 00:20:13 +00:00
|
|
|
static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
|
|
|
|
struct mmc *mmc, int partition)
|
2014-11-08 22:14:56 +00:00
|
|
|
{
|
|
|
|
disk_partition_t info;
|
2015-05-22 10:45:35 +00:00
|
|
|
int err;
|
2014-11-08 22:14:56 +00:00
|
|
|
|
2017-02-11 01:15:34 +00:00
|
|
|
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
|
|
|
|
int type_part;
|
|
|
|
/* Only support MBR so DOS_ENTRY_NUMBERS */
|
|
|
|
for (type_part = 1; type_part <= DOS_ENTRY_NUMBERS; type_part++) {
|
|
|
|
err = part_get_info(mmc_get_blk_desc(mmc), type_part, &info);
|
|
|
|
if (err)
|
|
|
|
continue;
|
|
|
|
if (info.sys_ind ==
|
|
|
|
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE) {
|
|
|
|
partition = type_part;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-07-05 23:10:18 +00:00
|
|
|
err = part_get_info(mmc_get_blk_desc(mmc), partition, &info);
|
2015-05-22 10:45:35 +00:00
|
|
|
if (err) {
|
2014-11-08 22:14:56 +00:00
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
2015-06-03 16:48:51 +00:00
|
|
|
puts("spl: partition error\n");
|
2014-11-08 22:14:56 +00:00
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-11-16 17:19:05 +00:00
|
|
|
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
|
2016-09-25 00:20:13 +00:00
|
|
|
return mmc_load_image_raw_sector(spl_image, mmc,
|
|
|
|
info.start + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
|
2015-07-20 09:20:39 +00:00
|
|
|
#else
|
2016-09-25 00:20:13 +00:00
|
|
|
return mmc_load_image_raw_sector(spl_image, mmc, info.start);
|
2015-07-20 09:20:39 +00:00
|
|
|
#endif
|
2014-11-08 22:14:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-05-13 08:36:29 +00:00
|
|
|
#ifdef CONFIG_SPL_OS_BOOT
|
2016-09-25 00:20:13 +00:00
|
|
|
static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
|
|
|
|
struct mmc *mmc)
|
2013-05-13 08:36:29 +00:00
|
|
|
{
|
2015-05-22 10:45:35 +00:00
|
|
|
unsigned long count;
|
2016-04-11 09:54:50 +00:00
|
|
|
int ret;
|
2015-04-27 08:20:22 +00:00
|
|
|
|
2016-06-13 05:30:32 +00:00
|
|
|
count = blk_dread(mmc_get_blk_desc(mmc),
|
2015-05-22 10:45:35 +00:00
|
|
|
CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
|
|
|
|
CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
|
|
|
|
(void *) CONFIG_SYS_SPL_ARGS_ADDR);
|
2017-08-15 01:01:30 +00:00
|
|
|
if (count != CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS) {
|
2013-09-04 15:12:24 +00:00
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
2016-04-21 02:12:04 +00:00
|
|
|
puts("mmc_load_image_raw_os: mmc block read error\n");
|
2013-09-04 15:12:24 +00:00
|
|
|
#endif
|
2013-05-13 08:36:29 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-09-25 00:20:13 +00:00
|
|
|
ret = mmc_load_image_raw_sector(spl_image, mmc,
|
2015-04-27 08:20:22 +00:00
|
|
|
CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
|
2016-04-11 09:54:50 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2016-09-25 00:20:13 +00:00
|
|
|
if (spl_image->os != IH_OS_LINUX) {
|
2016-04-11 09:54:50 +00:00
|
|
|
puts("Expected Linux image is not found. Trying to start U-boot\n");
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2013-05-13 08:36:29 +00:00
|
|
|
}
|
2015-11-08 15:11:45 +00:00
|
|
|
#else
|
|
|
|
int spl_start_uboot(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2016-09-25 00:20:13 +00:00
|
|
|
static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
|
|
|
|
struct mmc *mmc)
|
2015-11-08 15:11:45 +00:00
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
2013-05-13 08:36:29 +00:00
|
|
|
#endif
|
|
|
|
|
2015-11-08 15:11:47 +00:00
|
|
|
#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
|
2016-09-25 00:20:13 +00:00
|
|
|
static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
|
2015-11-08 15:11:47 +00:00
|
|
|
{
|
|
|
|
int err = -ENOSYS;
|
|
|
|
|
|
|
|
#ifdef CONFIG_SPL_FAT_SUPPORT
|
|
|
|
if (!spl_start_uboot()) {
|
2016-09-25 00:20:15 +00:00
|
|
|
err = spl_load_image_fat_os(spl_image, mmc_get_blk_desc(mmc),
|
2015-11-08 15:11:47 +00:00
|
|
|
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
|
|
|
|
if (!err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
|
2016-09-25 00:20:15 +00:00
|
|
|
err = spl_load_image_fat(spl_image, mmc_get_blk_desc(mmc),
|
2015-11-08 15:11:47 +00:00
|
|
|
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
|
|
|
|
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
|
|
|
|
if (!err)
|
|
|
|
return err;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_SPL_EXT_SUPPORT
|
|
|
|
if (!spl_start_uboot()) {
|
2016-12-01 10:09:01 +00:00
|
|
|
err = spl_load_image_ext_os(spl_image, mmc_get_blk_desc(mmc),
|
2015-11-08 15:11:47 +00:00
|
|
|
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
|
|
|
|
if (!err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
|
2016-12-01 10:09:01 +00:00
|
|
|
err = spl_load_image_ext(spl_image, mmc_get_blk_desc(mmc),
|
2015-11-08 15:11:47 +00:00
|
|
|
CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
|
|
|
|
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
|
|
|
|
if (!err)
|
|
|
|
return err;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
|
|
|
|
err = -ENOENT;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
#else
|
2016-09-25 00:20:13 +00:00
|
|
|
static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
|
2015-11-08 15:11:47 +00:00
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-02-03 07:29:52 +00:00
|
|
|
u32 __weak spl_boot_mode(const u32 boot_device)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
|
|
|
|
return MMCSD_MODE_FS;
|
|
|
|
#elif defined(CONFIG_SUPPORT_EMMC_BOOT)
|
|
|
|
return MMCSD_MODE_EMMCBOOT;
|
|
|
|
#else
|
|
|
|
return MMCSD_MODE_RAW;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-03-20 09:54:51 +00:00
|
|
|
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
|
|
|
|
__weak
|
|
|
|
int spl_boot_partition(const u32 boot_device)
|
|
|
|
{
|
|
|
|
return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-12-01 01:06:35 +00:00
|
|
|
int spl_mmc_load_image(struct spl_image_info *spl_image,
|
|
|
|
struct spl_boot_device *bootdev)
|
2011-09-14 19:33:34 +00:00
|
|
|
{
|
2015-12-02 17:59:11 +00:00
|
|
|
struct mmc *mmc = NULL;
|
2011-09-14 19:33:34 +00:00
|
|
|
u32 boot_mode;
|
2015-06-23 21:38:51 +00:00
|
|
|
int err = 0;
|
2015-04-27 08:20:22 +00:00
|
|
|
__maybe_unused int part;
|
2011-09-14 19:33:34 +00:00
|
|
|
|
2016-09-25 00:19:57 +00:00
|
|
|
err = spl_mmc_find_device(&mmc, bootdev->boot_device);
|
2015-11-08 15:11:49 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
2011-09-14 19:33:34 +00:00
|
|
|
|
2015-11-08 15:11:44 +00:00
|
|
|
err = mmc_init(mmc);
|
2011-09-14 19:33:34 +00:00
|
|
|
if (err) {
|
2013-09-04 15:12:24 +00:00
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
2015-04-27 08:20:22 +00:00
|
|
|
printf("spl: mmc init failed with error: %d\n", err);
|
2013-09-04 15:12:24 +00:00
|
|
|
#endif
|
2015-11-08 15:11:49 +00:00
|
|
|
return err;
|
2011-09-14 19:33:34 +00:00
|
|
|
}
|
2013-05-13 08:36:25 +00:00
|
|
|
|
2016-09-25 00:19:57 +00:00
|
|
|
boot_mode = spl_boot_mode(bootdev->boot_device);
|
2015-11-08 15:11:49 +00:00
|
|
|
err = -EINVAL;
|
2015-04-27 08:20:22 +00:00
|
|
|
switch (boot_mode) {
|
2015-11-08 15:11:48 +00:00
|
|
|
case MMCSD_MODE_EMMCBOOT:
|
|
|
|
/*
|
|
|
|
* We need to check what the partition is configured to.
|
|
|
|
* 1 and 2 match up to boot0 / boot1 and 7 is user data
|
|
|
|
* which is the first physical partition (0).
|
|
|
|
*/
|
|
|
|
part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
|
|
|
|
|
|
|
|
if (part == 7)
|
|
|
|
part = 0;
|
|
|
|
|
2016-12-01 01:06:33 +00:00
|
|
|
if (CONFIG_IS_ENABLED(MMC_TINY))
|
|
|
|
err = mmc_switch_part(mmc, part);
|
|
|
|
else
|
|
|
|
err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part);
|
|
|
|
|
2015-11-08 15:11:49 +00:00
|
|
|
if (err) {
|
2015-11-08 15:11:48 +00:00
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
|
|
|
puts("spl: mmc partition switch failed\n");
|
|
|
|
#endif
|
2015-11-08 15:11:49 +00:00
|
|
|
return err;
|
2015-11-08 15:11:48 +00:00
|
|
|
}
|
|
|
|
/* Fall through */
|
2015-04-27 08:20:22 +00:00
|
|
|
case MMCSD_MODE_RAW:
|
|
|
|
debug("spl: mmc boot mode: raw\n");
|
|
|
|
|
|
|
|
if (!spl_start_uboot()) {
|
2016-09-25 00:20:13 +00:00
|
|
|
err = mmc_load_image_raw_os(spl_image, mmc);
|
2015-04-27 08:20:22 +00:00
|
|
|
if (!err)
|
2015-11-08 15:11:49 +00:00
|
|
|
return err;
|
2015-04-27 08:20:22 +00:00
|
|
|
}
|
2017-02-11 01:15:35 +00:00
|
|
|
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
|
2018-03-20 09:54:51 +00:00
|
|
|
err = spl_boot_partition(bootdev->boot_device);
|
|
|
|
if (!err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = mmc_load_image_raw_partition(spl_image, mmc, err);
|
2015-06-08 21:05:09 +00:00
|
|
|
if (!err)
|
2015-11-08 15:11:49 +00:00
|
|
|
return err;
|
2017-02-11 01:15:35 +00:00
|
|
|
#endif
|
2016-11-16 17:19:05 +00:00
|
|
|
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
|
2016-09-25 00:20:13 +00:00
|
|
|
err = mmc_load_image_raw_sector(spl_image, mmc,
|
2014-01-16 17:23:29 +00:00
|
|
|
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
|
2015-04-27 08:20:22 +00:00
|
|
|
if (!err)
|
2015-11-08 15:11:49 +00:00
|
|
|
return err;
|
2015-06-08 21:05:09 +00:00
|
|
|
#endif
|
2016-02-18 17:17:36 +00:00
|
|
|
/* If RAW mode fails, try FS mode. */
|
2015-04-27 08:20:22 +00:00
|
|
|
case MMCSD_MODE_FS:
|
|
|
|
debug("spl: mmc boot mode: fs\n");
|
|
|
|
|
2016-09-25 00:20:13 +00:00
|
|
|
err = spl_mmc_do_fs_boot(spl_image, mmc);
|
2015-04-27 08:20:22 +00:00
|
|
|
if (!err)
|
2015-11-08 15:11:49 +00:00
|
|
|
return err;
|
2015-11-08 15:11:47 +00:00
|
|
|
|
2015-11-08 15:11:43 +00:00
|
|
|
break;
|
2013-09-04 15:12:24 +00:00
|
|
|
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
|
2015-11-08 15:11:43 +00:00
|
|
|
default:
|
|
|
|
puts("spl: mmc: wrong boot mode\n");
|
2013-09-04 15:12:24 +00:00
|
|
|
#endif
|
2015-04-27 08:20:22 +00:00
|
|
|
}
|
2015-11-08 15:11:43 +00:00
|
|
|
|
2015-11-08 15:11:49 +00:00
|
|
|
return err;
|
2011-09-14 19:33:34 +00:00
|
|
|
}
|
2016-09-25 00:20:00 +00:00
|
|
|
|
2016-11-30 22:30:50 +00:00
|
|
|
SPL_LOAD_IMAGE_METHOD("MMC1", 0, BOOT_DEVICE_MMC1, spl_mmc_load_image);
|
|
|
|
SPL_LOAD_IMAGE_METHOD("MMC2", 0, BOOT_DEVICE_MMC2, spl_mmc_load_image);
|
|
|
|
SPL_LOAD_IMAGE_METHOD("MMC2_2", 0, BOOT_DEVICE_MMC2_2, spl_mmc_load_image);
|