Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010 |
| 3 | * Texas Instruments, <www.ti.com> |
| 4 | * |
| 5 | * Aneesh V <aneesh@ti.com> |
| 6 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 8 | */ |
| 9 | #include <common.h> |
Simon Glass | f22851a | 2015-06-23 15:38:51 -0600 | [diff] [blame] | 10 | #include <dm.h> |
Tom Rini | 28591df | 2012-08-13 12:03:19 -0700 | [diff] [blame] | 11 | #include <spl.h> |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 12 | #include <linux/compiler.h> |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 13 | #include <errno.h> |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 14 | #include <asm/u-boot.h> |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 15 | #include <errno.h> |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 16 | #include <mmc.h> |
Tom Rini | 1530e8a | 2013-06-28 14:43:01 -0400 | [diff] [blame] | 17 | #include <image.h> |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 21 | static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector) |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 22 | { |
Paul Kocialkowski | 2d69f25 | 2015-05-22 12:45:35 +0200 | [diff] [blame] | 23 | unsigned long count; |
Peter Korsgaard | f247129 | 2013-03-21 04:55:17 +0000 | [diff] [blame] | 24 | u32 image_size_sectors; |
| 25 | struct image_header *header; |
Eric Nelson | d09e59f | 2015-12-05 12:32:28 -0700 | [diff] [blame] | 26 | int dev_num = mmc->block_dev.dev; |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 27 | |
| 28 | header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 29 | sizeof(struct image_header)); |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 30 | |
| 31 | /* read image header to find the image size & load address */ |
Eric Nelson | d09e59f | 2015-12-05 12:32:28 -0700 | [diff] [blame] | 32 | count = mmc->block_dev.block_read(dev_num, sector, 1, header); |
Simon Glass | 5614db8 | 2015-06-23 15:38:47 -0600 | [diff] [blame] | 33 | debug("read sector %lx, count=%lu\n", sector, count); |
Paul Kocialkowski | 2d69f25 | 2015-05-22 12:45:35 +0200 | [diff] [blame] | 34 | if (count == 0) |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 35 | goto end; |
| 36 | |
Simon Glass | 5614db8 | 2015-06-23 15:38:47 -0600 | [diff] [blame] | 37 | if (image_get_magic(header) != IH_MAGIC) { |
| 38 | puts("bad magic\n"); |
Tom Rini | 1530e8a | 2013-06-28 14:43:01 -0400 | [diff] [blame] | 39 | return -1; |
Simon Glass | 5614db8 | 2015-06-23 15:38:47 -0600 | [diff] [blame] | 40 | } |
Tom Rini | 1530e8a | 2013-06-28 14:43:01 -0400 | [diff] [blame] | 41 | |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 42 | spl_parse_image_header(header); |
| 43 | |
| 44 | /* convert size to sectors - round up */ |
Tom Rini | a0b9fa5 | 2012-08-14 10:25:15 -0700 | [diff] [blame] | 45 | image_size_sectors = (spl_image.size + mmc->read_bl_len - 1) / |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 46 | mmc->read_bl_len; |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 47 | |
| 48 | /* Read the header too to avoid extra memcpy */ |
Eric Nelson | d09e59f | 2015-12-05 12:32:28 -0700 | [diff] [blame] | 49 | count = mmc->block_dev.block_read(dev_num, sector, image_size_sectors, |
Gong Qianyu | 2ae4589 | 2015-07-30 14:07:12 +0800 | [diff] [blame] | 50 | (void *)(ulong)spl_image.load_addr); |
Simon Glass | 5614db8 | 2015-06-23 15:38:47 -0600 | [diff] [blame] | 51 | debug("read %x sectors to %x\n", image_size_sectors, |
| 52 | spl_image.load_addr); |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 53 | |
| 54 | end: |
Paul Kocialkowski | 01c723f | 2015-06-03 18:48:51 +0200 | [diff] [blame] | 55 | if (count == 0) { |
Paul Burton | a8015fd | 2013-09-04 16:12:24 +0100 | [diff] [blame] | 56 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
Paul Kocialkowski | 01c723f | 2015-06-03 18:48:51 +0200 | [diff] [blame] | 57 | puts("spl: mmc block read error\n"); |
Paul Burton | a8015fd | 2013-09-04 16:12:24 +0100 | [diff] [blame] | 58 | #endif |
Paul Kocialkowski | 2d69f25 | 2015-05-22 12:45:35 +0200 | [diff] [blame] | 59 | return -1; |
Paul Kocialkowski | 01c723f | 2015-06-03 18:48:51 +0200 | [diff] [blame] | 60 | } |
Paul Kocialkowski | 2d69f25 | 2015-05-22 12:45:35 +0200 | [diff] [blame] | 61 | |
| 62 | return 0; |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 63 | } |
| 64 | |
Nikita Kiryanov | e63b2dd | 2015-11-08 17:11:54 +0200 | [diff] [blame] | 65 | int spl_mmc_get_device_index(u32 boot_device) |
| 66 | { |
| 67 | switch (boot_device) { |
| 68 | case BOOT_DEVICE_MMC1: |
| 69 | return 0; |
| 70 | case BOOT_DEVICE_MMC2: |
| 71 | case BOOT_DEVICE_MMC2_2: |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
| 76 | printf("spl: unsupported mmc boot device.\n"); |
| 77 | #endif |
| 78 | |
| 79 | return -ENODEV; |
| 80 | } |
| 81 | |
Simon Glass | 4faf63b | 2015-12-02 10:59:12 -0700 | [diff] [blame] | 82 | static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device) |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 83 | { |
Simon Glass | 51ace32 | 2015-12-02 10:59:13 -0700 | [diff] [blame] | 84 | #ifdef CONFIG_DM_MMC |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 85 | struct udevice *dev; |
Simon Glass | 51ace32 | 2015-12-02 10:59:13 -0700 | [diff] [blame] | 86 | #endif |
Nikita Kiryanov | e63b2dd | 2015-11-08 17:11:54 +0200 | [diff] [blame] | 87 | int err, mmc_dev; |
| 88 | |
| 89 | mmc_dev = spl_mmc_get_device_index(boot_device); |
| 90 | if (mmc_dev < 0) |
| 91 | return mmc_dev; |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 92 | |
| 93 | err = mmc_initialize(NULL); |
| 94 | if (err) { |
| 95 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
| 96 | printf("spl: could not initialize mmc. error: %d\n", err); |
| 97 | #endif |
| 98 | return err; |
| 99 | } |
| 100 | |
Simon Glass | 51ace32 | 2015-12-02 10:59:13 -0700 | [diff] [blame] | 101 | #ifdef CONFIG_DM_MMC |
Nikita Kiryanov | e63b2dd | 2015-11-08 17:11:54 +0200 | [diff] [blame] | 102 | err = uclass_get_device(UCLASS_MMC, mmc_dev, &dev); |
Simon Glass | 51ace32 | 2015-12-02 10:59:13 -0700 | [diff] [blame] | 103 | if (!err) |
| 104 | *mmcp = mmc_get_mmc_dev(dev); |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 105 | #else |
Simon Glass | 51ace32 | 2015-12-02 10:59:13 -0700 | [diff] [blame] | 106 | *mmcp = find_mmc_device(mmc_dev); |
| 107 | err = *mmcp ? 0 : -ENODEV; |
| 108 | #endif |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 109 | if (err) { |
| 110 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
Simon Glass | 51ace32 | 2015-12-02 10:59:13 -0700 | [diff] [blame] | 111 | printf("spl: could not find mmc device. error: %d\n", err); |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 112 | #endif |
| 113 | return err; |
| 114 | } |
| 115 | |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 116 | return 0; |
| 117 | } |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 118 | |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 119 | #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION |
| 120 | static int mmc_load_image_raw_partition(struct mmc *mmc, int partition) |
| 121 | { |
| 122 | disk_partition_t info; |
Paul Kocialkowski | 2d69f25 | 2015-05-22 12:45:35 +0200 | [diff] [blame] | 123 | int err; |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 124 | |
Paul Kocialkowski | 2d69f25 | 2015-05-22 12:45:35 +0200 | [diff] [blame] | 125 | err = get_partition_info(&mmc->block_dev, partition, &info); |
| 126 | if (err) { |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 127 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
Paul Kocialkowski | 01c723f | 2015-06-03 18:48:51 +0200 | [diff] [blame] | 128 | puts("spl: partition error\n"); |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 129 | #endif |
| 130 | return -1; |
| 131 | } |
| 132 | |
Stefan Roese | d0503cd | 2015-07-20 11:20:39 +0200 | [diff] [blame] | 133 | #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR |
| 134 | return mmc_load_image_raw_sector(mmc, info.start + |
| 135 | CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); |
| 136 | #else |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 137 | return mmc_load_image_raw_sector(mmc, info.start); |
Stefan Roese | d0503cd | 2015-07-20 11:20:39 +0200 | [diff] [blame] | 138 | #endif |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 139 | } |
Nikita Kiryanov | 011cd8f | 2015-11-08 17:11:46 +0200 | [diff] [blame] | 140 | #else |
| 141 | #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION -1 |
| 142 | static int mmc_load_image_raw_partition(struct mmc *mmc, int partition) |
| 143 | { |
| 144 | return -ENOSYS; |
| 145 | } |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 146 | #endif |
| 147 | |
Peter Korsgaard | 01b542f | 2013-05-13 08:36:29 +0000 | [diff] [blame] | 148 | #ifdef CONFIG_SPL_OS_BOOT |
| 149 | static int mmc_load_image_raw_os(struct mmc *mmc) |
| 150 | { |
Paul Kocialkowski | 2d69f25 | 2015-05-22 12:45:35 +0200 | [diff] [blame] | 151 | unsigned long count; |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 152 | |
Eric Nelson | d09e59f | 2015-12-05 12:32:28 -0700 | [diff] [blame] | 153 | count = mmc->block_dev.block_read( |
| 154 | mmc->block_dev.dev, |
Paul Kocialkowski | 2d69f25 | 2015-05-22 12:45:35 +0200 | [diff] [blame] | 155 | CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR, |
| 156 | CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS, |
| 157 | (void *) CONFIG_SYS_SPL_ARGS_ADDR); |
| 158 | if (count == 0) { |
Paul Burton | a8015fd | 2013-09-04 16:12:24 +0100 | [diff] [blame] | 159 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
Paul Kocialkowski | 01c723f | 2015-06-03 18:48:51 +0200 | [diff] [blame] | 160 | puts("spl: mmc block read error\n"); |
Paul Burton | a8015fd | 2013-09-04 16:12:24 +0100 | [diff] [blame] | 161 | #endif |
Peter Korsgaard | 01b542f | 2013-05-13 08:36:29 +0000 | [diff] [blame] | 162 | return -1; |
| 163 | } |
| 164 | |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 165 | return mmc_load_image_raw_sector(mmc, |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 166 | CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR); |
Peter Korsgaard | 01b542f | 2013-05-13 08:36:29 +0000 | [diff] [blame] | 167 | } |
Nikita Kiryanov | cc49f55 | 2015-11-08 17:11:45 +0200 | [diff] [blame] | 168 | #else |
| 169 | int spl_start_uboot(void) |
| 170 | { |
| 171 | return 1; |
| 172 | } |
| 173 | static int mmc_load_image_raw_os(struct mmc *mmc) |
| 174 | { |
| 175 | return -ENOSYS; |
| 176 | } |
Peter Korsgaard | 01b542f | 2013-05-13 08:36:29 +0000 | [diff] [blame] | 177 | #endif |
| 178 | |
Nikita Kiryanov | 642648c | 2015-11-08 17:11:47 +0200 | [diff] [blame] | 179 | #ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION |
| 180 | int spl_mmc_do_fs_boot(struct mmc *mmc) |
| 181 | { |
| 182 | int err = -ENOSYS; |
| 183 | |
| 184 | #ifdef CONFIG_SPL_FAT_SUPPORT |
| 185 | if (!spl_start_uboot()) { |
| 186 | err = spl_load_image_fat_os(&mmc->block_dev, |
| 187 | CONFIG_SYS_MMCSD_FS_BOOT_PARTITION); |
| 188 | if (!err) |
| 189 | return err; |
| 190 | } |
| 191 | #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME |
| 192 | err = spl_load_image_fat(&mmc->block_dev, |
| 193 | CONFIG_SYS_MMCSD_FS_BOOT_PARTITION, |
| 194 | CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); |
| 195 | if (!err) |
| 196 | return err; |
| 197 | #endif |
| 198 | #endif |
| 199 | #ifdef CONFIG_SPL_EXT_SUPPORT |
| 200 | if (!spl_start_uboot()) { |
| 201 | err = spl_load_image_ext_os(&mmc->block_dev, |
| 202 | CONFIG_SYS_MMCSD_FS_BOOT_PARTITION); |
| 203 | if (!err) |
| 204 | return err; |
| 205 | } |
| 206 | #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME |
| 207 | err = spl_load_image_ext(&mmc->block_dev, |
| 208 | CONFIG_SYS_MMCSD_FS_BOOT_PARTITION, |
| 209 | CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); |
| 210 | if (!err) |
| 211 | return err; |
| 212 | #endif |
| 213 | #endif |
| 214 | |
| 215 | #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT) |
| 216 | err = -ENOENT; |
| 217 | #endif |
| 218 | |
| 219 | return err; |
| 220 | } |
| 221 | #else |
| 222 | int spl_mmc_do_fs_boot(struct mmc *mmc) |
| 223 | { |
| 224 | return -ENOSYS; |
| 225 | } |
| 226 | #endif |
| 227 | |
Nikita Kiryanov | e63b2dd | 2015-11-08 17:11:54 +0200 | [diff] [blame] | 228 | int spl_mmc_load_image(u32 boot_device) |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 229 | { |
Simon Glass | a2b771c | 2015-12-02 10:59:11 -0700 | [diff] [blame] | 230 | struct mmc *mmc = NULL; |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 231 | u32 boot_mode; |
Simon Glass | f22851a | 2015-06-23 15:38:51 -0600 | [diff] [blame] | 232 | int err = 0; |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 233 | __maybe_unused int part; |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 234 | |
Nikita Kiryanov | e63b2dd | 2015-11-08 17:11:54 +0200 | [diff] [blame] | 235 | err = spl_mmc_find_device(&mmc, boot_device); |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 236 | if (err) |
| 237 | return err; |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 238 | |
Nikita Kiryanov | 022ddb8 | 2015-11-08 17:11:44 +0200 | [diff] [blame] | 239 | err = mmc_init(mmc); |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 240 | if (err) { |
Paul Burton | a8015fd | 2013-09-04 16:12:24 +0100 | [diff] [blame] | 241 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 242 | printf("spl: mmc init failed with error: %d\n", err); |
Paul Burton | a8015fd | 2013-09-04 16:12:24 +0100 | [diff] [blame] | 243 | #endif |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 244 | return err; |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 245 | } |
Peter Korsgaard | 5e5483d | 2013-05-13 08:36:25 +0000 | [diff] [blame] | 246 | |
Tom Rini | a76ff95 | 2012-08-14 09:19:44 -0700 | [diff] [blame] | 247 | boot_mode = spl_boot_mode(); |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 248 | err = -EINVAL; |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 249 | switch (boot_mode) { |
Nikita Kiryanov | 2b3ae5f | 2015-11-08 17:11:48 +0200 | [diff] [blame] | 250 | case MMCSD_MODE_EMMCBOOT: |
| 251 | /* |
| 252 | * We need to check what the partition is configured to. |
| 253 | * 1 and 2 match up to boot0 / boot1 and 7 is user data |
| 254 | * which is the first physical partition (0). |
| 255 | */ |
| 256 | part = (mmc->part_config >> 3) & PART_ACCESS_MASK; |
| 257 | |
| 258 | if (part == 7) |
| 259 | part = 0; |
| 260 | |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 261 | err = mmc_switch_part(0, part); |
| 262 | if (err) { |
Nikita Kiryanov | 2b3ae5f | 2015-11-08 17:11:48 +0200 | [diff] [blame] | 263 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
| 264 | puts("spl: mmc partition switch failed\n"); |
| 265 | #endif |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 266 | return err; |
Nikita Kiryanov | 2b3ae5f | 2015-11-08 17:11:48 +0200 | [diff] [blame] | 267 | } |
| 268 | /* Fall through */ |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 269 | case MMCSD_MODE_RAW: |
| 270 | debug("spl: mmc boot mode: raw\n"); |
| 271 | |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 272 | if (!spl_start_uboot()) { |
| 273 | err = mmc_load_image_raw_os(mmc); |
| 274 | if (!err) |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 275 | return err; |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 276 | } |
Nikita Kiryanov | 011cd8f | 2015-11-08 17:11:46 +0200 | [diff] [blame] | 277 | |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 278 | err = mmc_load_image_raw_partition(mmc, |
| 279 | CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION); |
Paul Kocialkowski | 4bd66e7 | 2015-06-08 23:05:09 +0200 | [diff] [blame] | 280 | if (!err) |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 281 | return err; |
Nikita Kiryanov | 011cd8f | 2015-11-08 17:11:46 +0200 | [diff] [blame] | 282 | #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR) |
Paul Kocialkowski | 17675c8 | 2014-11-08 23:14:56 +0100 | [diff] [blame] | 283 | err = mmc_load_image_raw_sector(mmc, |
Dan Murphy | b7b5b0c | 2014-01-16 11:23:29 -0600 | [diff] [blame] | 284 | CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 285 | if (!err) |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 286 | return err; |
Paul Kocialkowski | 4bd66e7 | 2015-06-08 23:05:09 +0200 | [diff] [blame] | 287 | #endif |
Nikita Kiryanov | ed52f4d | 2015-11-08 17:11:43 +0200 | [diff] [blame] | 288 | break; |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 289 | case MMCSD_MODE_FS: |
| 290 | debug("spl: mmc boot mode: fs\n"); |
| 291 | |
Nikita Kiryanov | 642648c | 2015-11-08 17:11:47 +0200 | [diff] [blame] | 292 | err = spl_mmc_do_fs_boot(mmc); |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 293 | if (!err) |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 294 | return err; |
Nikita Kiryanov | 642648c | 2015-11-08 17:11:47 +0200 | [diff] [blame] | 295 | |
Nikita Kiryanov | ed52f4d | 2015-11-08 17:11:43 +0200 | [diff] [blame] | 296 | break; |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 297 | case MMCSD_MODE_UNDEFINED: |
Paul Burton | a8015fd | 2013-09-04 16:12:24 +0100 | [diff] [blame] | 298 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
Nikita Kiryanov | ed52f4d | 2015-11-08 17:11:43 +0200 | [diff] [blame] | 299 | default: |
| 300 | puts("spl: mmc: wrong boot mode\n"); |
Paul Burton | a8015fd | 2013-09-04 16:12:24 +0100 | [diff] [blame] | 301 | #endif |
Paul Kocialkowski | 0d13972 | 2015-04-27 10:20:22 +0200 | [diff] [blame] | 302 | } |
Nikita Kiryanov | ed52f4d | 2015-11-08 17:11:43 +0200 | [diff] [blame] | 303 | |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 304 | return err; |
Simon Schwarz | e21d2d8 | 2011-09-14 15:33:34 -0400 | [diff] [blame] | 305 | } |