Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il> |
| 3 | * |
| 4 | * Authors: Igor Grinberg <grinberg@compulab.co.il> |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
tomas.melin@vaisala.com | 0a7c732 | 2017-01-13 13:20:13 +0200 | [diff] [blame] | 10 | #include <bmp_layout.h> |
Nikita Kiryanov | f58c509 | 2015-01-14 10:42:49 +0200 | [diff] [blame] | 11 | #include <errno.h> |
tomas.melin@vaisala.com | 0a7c732 | 2017-01-13 13:20:13 +0200 | [diff] [blame] | 12 | #include <fs.h> |
tomas.melin@vaisala.com | 45ee790 | 2017-01-13 13:20:14 +0200 | [diff] [blame] | 13 | #include <fdt_support.h> |
tomas.melin@vaisala.com | 0a7c732 | 2017-01-13 13:20:13 +0200 | [diff] [blame] | 14 | #include <image.h> |
| 15 | #include <nand.h> |
| 16 | #include <sata.h> |
Nikita Kiryanov | 1ab4c76 | 2015-01-14 10:42:52 +0200 | [diff] [blame] | 17 | #include <spi.h> |
tomas.melin@vaisala.com | 0a7c732 | 2017-01-13 13:20:13 +0200 | [diff] [blame] | 18 | #include <spi_flash.h> |
| 19 | #include <splash.h> |
Nikita Kiryanov | bf5c3cc | 2015-10-29 11:54:42 +0200 | [diff] [blame] | 20 | #include <usb.h> |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
Nikita Kiryanov | 1ab4c76 | 2015-01-14 10:42:52 +0200 | [diff] [blame] | 24 | #ifdef CONFIG_SPI_FLASH |
| 25 | static struct spi_flash *sf; |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 26 | static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size) |
Nikita Kiryanov | 1ab4c76 | 2015-01-14 10:42:52 +0200 | [diff] [blame] | 27 | { |
| 28 | if (!sf) { |
| 29 | sf = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, |
| 30 | CONFIG_SF_DEFAULT_CS, |
| 31 | CONFIG_SF_DEFAULT_SPEED, |
| 32 | CONFIG_SF_DEFAULT_MODE); |
| 33 | if (!sf) |
| 34 | return -ENODEV; |
| 35 | } |
| 36 | |
| 37 | return spi_flash_read(sf, offset, read_size, (void *)bmp_load_addr); |
| 38 | } |
| 39 | #else |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 40 | static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size) |
Nikita Kiryanov | 1ab4c76 | 2015-01-14 10:42:52 +0200 | [diff] [blame] | 41 | { |
| 42 | debug("%s: sf support not available\n", __func__); |
| 43 | return -ENOSYS; |
| 44 | } |
| 45 | #endif |
| 46 | |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 47 | #ifdef CONFIG_CMD_NAND |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 48 | static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size) |
Nikita Kiryanov | 4b4bfd6 | 2015-01-14 10:42:50 +0200 | [diff] [blame] | 49 | { |
Scott Wood | 2c1b7e1 | 2016-05-30 13:57:55 -0500 | [diff] [blame] | 50 | return nand_read_skip_bad(nand_info[nand_curr_device], offset, |
Nikita Kiryanov | 4b4bfd6 | 2015-01-14 10:42:50 +0200 | [diff] [blame] | 51 | &read_size, NULL, |
Scott Wood | 2c1b7e1 | 2016-05-30 13:57:55 -0500 | [diff] [blame] | 52 | nand_info[nand_curr_device]->size, |
Nikita Kiryanov | 4b4bfd6 | 2015-01-14 10:42:50 +0200 | [diff] [blame] | 53 | (u_char *)bmp_load_addr); |
| 54 | } |
| 55 | #else |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 56 | static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size) |
Nikita Kiryanov | 4b4bfd6 | 2015-01-14 10:42:50 +0200 | [diff] [blame] | 57 | { |
| 58 | debug("%s: nand support not available\n", __func__); |
| 59 | return -ENOSYS; |
| 60 | } |
| 61 | #endif |
| 62 | |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 63 | static int splash_storage_read_raw(struct splash_location *location, |
Nikita Kiryanov | c2a07e3 | 2015-01-14 10:42:51 +0200 | [diff] [blame] | 64 | u32 bmp_load_addr, size_t read_size) |
Nikita Kiryanov | 4b4bfd6 | 2015-01-14 10:42:50 +0200 | [diff] [blame] | 65 | { |
Nikita Kiryanov | c2a07e3 | 2015-01-14 10:42:51 +0200 | [diff] [blame] | 66 | u32 offset; |
| 67 | |
| 68 | if (!location) |
| 69 | return -EINVAL; |
| 70 | |
| 71 | offset = location->offset; |
| 72 | switch (location->storage) { |
| 73 | case SPLASH_STORAGE_NAND: |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 74 | return splash_nand_read_raw(bmp_load_addr, offset, read_size); |
Nikita Kiryanov | 1ab4c76 | 2015-01-14 10:42:52 +0200 | [diff] [blame] | 75 | case SPLASH_STORAGE_SF: |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 76 | return splash_sf_read_raw(bmp_load_addr, offset, read_size); |
Nikita Kiryanov | c2a07e3 | 2015-01-14 10:42:51 +0200 | [diff] [blame] | 77 | default: |
| 78 | printf("Unknown splash location\n"); |
| 79 | } |
| 80 | |
| 81 | return -EINVAL; |
Nikita Kiryanov | 4b4bfd6 | 2015-01-14 10:42:50 +0200 | [diff] [blame] | 82 | } |
| 83 | |
Nikita Kiryanov | c2a07e3 | 2015-01-14 10:42:51 +0200 | [diff] [blame] | 84 | static int splash_load_raw(struct splash_location *location, u32 bmp_load_addr) |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 85 | { |
| 86 | struct bmp_header *bmp_hdr; |
| 87 | int res; |
| 88 | size_t bmp_size, bmp_header_size = sizeof(struct bmp_header); |
| 89 | |
| 90 | if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp) |
| 91 | goto splash_address_too_high; |
| 92 | |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 93 | res = splash_storage_read_raw(location, bmp_load_addr, bmp_header_size); |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 94 | if (res < 0) |
| 95 | return res; |
| 96 | |
| 97 | bmp_hdr = (struct bmp_header *)bmp_load_addr; |
| 98 | bmp_size = le32_to_cpu(bmp_hdr->file_size); |
| 99 | |
| 100 | if (bmp_load_addr + bmp_size >= gd->start_addr_sp) |
| 101 | goto splash_address_too_high; |
| 102 | |
Nikita Kiryanov | b8183de | 2015-10-29 11:54:40 +0200 | [diff] [blame] | 103 | return splash_storage_read_raw(location, bmp_load_addr, bmp_size); |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 104 | |
| 105 | splash_address_too_high: |
Nikita Kiryanov | 7f9ceea | 2015-01-14 10:42:54 +0200 | [diff] [blame] | 106 | printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n"); |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 107 | |
Nikita Kiryanov | f58c509 | 2015-01-14 10:42:49 +0200 | [diff] [blame] | 108 | return -EFAULT; |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 109 | } |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 110 | |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 111 | static int splash_select_fs_dev(struct splash_location *location) |
| 112 | { |
| 113 | int res; |
| 114 | |
| 115 | switch (location->storage) { |
| 116 | case SPLASH_STORAGE_MMC: |
| 117 | res = fs_set_blk_dev("mmc", location->devpart, FS_TYPE_ANY); |
| 118 | break; |
Nikita Kiryanov | bf5c3cc | 2015-10-29 11:54:42 +0200 | [diff] [blame] | 119 | case SPLASH_STORAGE_USB: |
| 120 | res = fs_set_blk_dev("usb", location->devpart, FS_TYPE_ANY); |
| 121 | break; |
Nikita Kiryanov | 80ca30d | 2015-10-29 11:54:43 +0200 | [diff] [blame] | 122 | case SPLASH_STORAGE_SATA: |
| 123 | res = fs_set_blk_dev("sata", location->devpart, FS_TYPE_ANY); |
| 124 | break; |
Eran Matityahu | 07a04a1 | 2016-06-07 10:38:37 +0300 | [diff] [blame] | 125 | case SPLASH_STORAGE_NAND: |
| 126 | if (location->ubivol != NULL) |
| 127 | res = fs_set_blk_dev("ubi", NULL, FS_TYPE_UBIFS); |
| 128 | else |
| 129 | res = -ENODEV; |
| 130 | break; |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 131 | default: |
| 132 | printf("Error: unsupported location storage.\n"); |
| 133 | return -ENODEV; |
| 134 | } |
| 135 | |
| 136 | if (res) |
| 137 | printf("Error: could not access storage.\n"); |
| 138 | |
| 139 | return res; |
| 140 | } |
Nikita Kiryanov | bf5c3cc | 2015-10-29 11:54:42 +0200 | [diff] [blame] | 141 | |
| 142 | #ifdef CONFIG_USB_STORAGE |
| 143 | static int splash_init_usb(void) |
| 144 | { |
| 145 | int err; |
| 146 | |
| 147 | err = usb_init(); |
| 148 | if (err) |
| 149 | return err; |
| 150 | |
Alexey Brodkin | bfcdf3f | 2016-07-01 22:47:36 +0300 | [diff] [blame] | 151 | #ifndef CONFIG_DM_USB |
| 152 | err = usb_stor_scan(1) < 0 ? -ENODEV : 0; |
| 153 | #endif |
| 154 | |
| 155 | return err; |
Nikita Kiryanov | bf5c3cc | 2015-10-29 11:54:42 +0200 | [diff] [blame] | 156 | } |
| 157 | #else |
| 158 | static inline int splash_init_usb(void) |
| 159 | { |
| 160 | printf("Cannot load splash image: no USB support\n"); |
| 161 | return -ENOSYS; |
| 162 | } |
| 163 | #endif |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 164 | |
Nikita Kiryanov | 80ca30d | 2015-10-29 11:54:43 +0200 | [diff] [blame] | 165 | #ifdef CONFIG_CMD_SATA |
| 166 | static int splash_init_sata(void) |
| 167 | { |
| 168 | return sata_initialize(); |
| 169 | } |
| 170 | #else |
| 171 | static inline int splash_init_sata(void) |
| 172 | { |
| 173 | printf("Cannot load splash image: no SATA support\n"); |
| 174 | return -ENOSYS; |
| 175 | } |
| 176 | #endif |
| 177 | |
Eran Matityahu | 07a04a1 | 2016-06-07 10:38:37 +0300 | [diff] [blame] | 178 | #ifdef CONFIG_CMD_UBIFS |
| 179 | static int splash_mount_ubifs(struct splash_location *location) |
| 180 | { |
| 181 | int res; |
| 182 | char cmd[32]; |
| 183 | |
| 184 | sprintf(cmd, "ubi part %s", location->mtdpart); |
| 185 | res = run_command(cmd, 0); |
| 186 | if (res) |
| 187 | return res; |
| 188 | |
| 189 | sprintf(cmd, "ubifsmount %s", location->ubivol); |
| 190 | res = run_command(cmd, 0); |
| 191 | |
| 192 | return res; |
| 193 | } |
| 194 | |
| 195 | static inline int splash_umount_ubifs(void) |
| 196 | { |
| 197 | return run_command("ubifsumount", 0); |
| 198 | } |
| 199 | #else |
| 200 | static inline int splash_mount_ubifs(struct splash_location *location) |
| 201 | { |
| 202 | printf("Cannot load splash image: no UBIFS support\n"); |
| 203 | return -ENOSYS; |
| 204 | } |
| 205 | |
| 206 | static inline int splash_umount_ubifs(void) |
| 207 | { |
| 208 | printf("Cannot unmount UBIFS: no UBIFS support\n"); |
| 209 | return -ENOSYS; |
| 210 | } |
| 211 | #endif |
| 212 | |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 213 | #define SPLASH_SOURCE_DEFAULT_FILE_NAME "splash.bmp" |
| 214 | |
| 215 | static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr) |
| 216 | { |
Nikita Kiryanov | bf5c3cc | 2015-10-29 11:54:42 +0200 | [diff] [blame] | 217 | int res = 0; |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 218 | loff_t bmp_size; |
| 219 | char *splash_file; |
| 220 | |
| 221 | splash_file = getenv("splashfile"); |
| 222 | if (!splash_file) |
| 223 | splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME; |
| 224 | |
Nikita Kiryanov | bf5c3cc | 2015-10-29 11:54:42 +0200 | [diff] [blame] | 225 | if (location->storage == SPLASH_STORAGE_USB) |
| 226 | res = splash_init_usb(); |
| 227 | |
Nikita Kiryanov | 80ca30d | 2015-10-29 11:54:43 +0200 | [diff] [blame] | 228 | if (location->storage == SPLASH_STORAGE_SATA) |
| 229 | res = splash_init_sata(); |
| 230 | |
Eran Matityahu | 07a04a1 | 2016-06-07 10:38:37 +0300 | [diff] [blame] | 231 | if (location->ubivol != NULL) |
| 232 | res = splash_mount_ubifs(location); |
| 233 | |
Nikita Kiryanov | bf5c3cc | 2015-10-29 11:54:42 +0200 | [diff] [blame] | 234 | if (res) |
| 235 | return res; |
| 236 | |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 237 | res = splash_select_fs_dev(location); |
| 238 | if (res) |
Eran Matityahu | 07a04a1 | 2016-06-07 10:38:37 +0300 | [diff] [blame] | 239 | goto out; |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 240 | |
| 241 | res = fs_size(splash_file, &bmp_size); |
| 242 | if (res) { |
| 243 | printf("Error (%d): cannot determine file size\n", res); |
Eran Matityahu | 07a04a1 | 2016-06-07 10:38:37 +0300 | [diff] [blame] | 244 | goto out; |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | if (bmp_load_addr + bmp_size >= gd->start_addr_sp) { |
| 248 | printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n"); |
Eran Matityahu | 07a04a1 | 2016-06-07 10:38:37 +0300 | [diff] [blame] | 249 | res = -EFAULT; |
| 250 | goto out; |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | splash_select_fs_dev(location); |
Eran Matityahu | 07a04a1 | 2016-06-07 10:38:37 +0300 | [diff] [blame] | 254 | res = fs_read(splash_file, bmp_load_addr, 0, 0, NULL); |
| 255 | |
| 256 | out: |
| 257 | if (location->ubivol != NULL) |
| 258 | splash_umount_ubifs(); |
| 259 | |
| 260 | return res; |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 261 | } |
| 262 | |
Nikita Kiryanov | c2a07e3 | 2015-01-14 10:42:51 +0200 | [diff] [blame] | 263 | /** |
| 264 | * select_splash_location - return the splash location based on board support |
| 265 | * and env variable "splashsource". |
| 266 | * |
| 267 | * @locations: An array of supported splash locations. |
| 268 | * @size: Size of splash_locations array. |
| 269 | * |
| 270 | * @return: If a null set of splash locations is given, or |
| 271 | * splashsource env variable is set to unsupported value |
| 272 | * return NULL. |
| 273 | * If splashsource env variable is not defined |
| 274 | * return the first entry in splash_locations as default. |
| 275 | * If splashsource env variable contains a supported value |
| 276 | * return the location selected by splashsource. |
| 277 | */ |
| 278 | static struct splash_location *select_splash_location( |
| 279 | struct splash_location *locations, uint size) |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 280 | { |
Nikita Kiryanov | c2a07e3 | 2015-01-14 10:42:51 +0200 | [diff] [blame] | 281 | int i; |
| 282 | char *env_splashsource; |
| 283 | |
| 284 | if (!locations || size == 0) |
| 285 | return NULL; |
| 286 | |
| 287 | env_splashsource = getenv("splashsource"); |
| 288 | if (env_splashsource == NULL) |
| 289 | return &locations[0]; |
| 290 | |
| 291 | for (i = 0; i < size; i++) { |
| 292 | if (!strcmp(locations[i].name, env_splashsource)) |
| 293 | return &locations[i]; |
| 294 | } |
| 295 | |
| 296 | printf("splashsource env variable set to unsupported value\n"); |
| 297 | return NULL; |
| 298 | } |
| 299 | |
tomas.melin@vaisala.com | 45ee790 | 2017-01-13 13:20:14 +0200 | [diff] [blame] | 300 | #ifdef CONFIG_FIT |
| 301 | static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr) |
| 302 | { |
| 303 | int res; |
| 304 | int node_offset; |
| 305 | int splash_offset; |
| 306 | int splash_size; |
| 307 | struct image_header *img_header; |
| 308 | const u32 *fit_header; |
| 309 | u32 fit_size; |
| 310 | const size_t header_size = sizeof(struct image_header); |
| 311 | |
| 312 | /* Read in image header */ |
| 313 | res = splash_storage_read_raw(location, bmp_load_addr, header_size); |
| 314 | if (res < 0) |
| 315 | return res; |
| 316 | |
| 317 | img_header = (struct image_header *)bmp_load_addr; |
| 318 | fit_size = fdt_totalsize(img_header); |
| 319 | |
| 320 | /* Read in entire FIT */ |
| 321 | fit_header = (const u32 *)(bmp_load_addr + header_size); |
| 322 | res = splash_storage_read_raw(location, (u32)fit_header, fit_size); |
| 323 | if (res < 0) |
| 324 | return res; |
| 325 | |
| 326 | res = fit_check_format(fit_header); |
| 327 | if (!res) { |
| 328 | debug("Could not find valid FIT image\n"); |
| 329 | return -EINVAL; |
| 330 | } |
| 331 | |
| 332 | node_offset = fit_image_get_node(fit_header, location->name); |
| 333 | if (node_offset < 0) { |
| 334 | debug("Could not find splash image '%s' in FIT\n", |
| 335 | location->name); |
| 336 | return -ENOENT; |
| 337 | } |
| 338 | |
| 339 | res = fit_image_get_data_offset(fit_header, node_offset, |
| 340 | &splash_offset); |
| 341 | if (res < 0) { |
| 342 | printf("Failed to load splash image (err=%d)\n", res); |
| 343 | return res; |
| 344 | } |
| 345 | |
| 346 | res = fit_image_get_data_size(fit_header, node_offset, &splash_size); |
| 347 | if (res < 0) { |
| 348 | printf("Failed to load splash image (err=%d)\n", res); |
| 349 | return res; |
| 350 | } |
| 351 | |
| 352 | /* Align data offset to 4-byte boundrary */ |
| 353 | fit_size = fdt_totalsize(fit_header); |
| 354 | fit_size = (fit_size + 3) & ~3; |
| 355 | |
| 356 | /* Read in the splash data */ |
| 357 | location->offset = (location->offset + fit_size + splash_offset); |
| 358 | res = splash_storage_read_raw(location, bmp_load_addr , splash_size); |
| 359 | if (res < 0) |
| 360 | return res; |
| 361 | |
| 362 | return 0; |
| 363 | } |
| 364 | #endif /* CONFIG_FIT */ |
| 365 | |
Nikita Kiryanov | 7f9ceea | 2015-01-14 10:42:54 +0200 | [diff] [blame] | 366 | /** |
| 367 | * splash_source_load - load splash image from a supported location. |
| 368 | * |
| 369 | * Select a splash image location based on the value of splashsource environment |
| 370 | * variable and the board supported splash source locations, and load a |
| 371 | * splashimage to the address pointed to by splashimage environment variable. |
| 372 | * |
| 373 | * @locations: An array of supported splash locations. |
| 374 | * @size: Size of splash_locations array. |
| 375 | * |
| 376 | * @return: 0 on success, negative value on failure. |
| 377 | */ |
| 378 | int splash_source_load(struct splash_location *locations, uint size) |
Nikita Kiryanov | c2a07e3 | 2015-01-14 10:42:51 +0200 | [diff] [blame] | 379 | { |
| 380 | struct splash_location *splash_location; |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 381 | char *env_splashimage_value; |
| 382 | u32 bmp_load_addr; |
| 383 | |
| 384 | env_splashimage_value = getenv("splashimage"); |
| 385 | if (env_splashimage_value == NULL) |
Nikita Kiryanov | f58c509 | 2015-01-14 10:42:49 +0200 | [diff] [blame] | 386 | return -ENOENT; |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 387 | |
| 388 | bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16); |
| 389 | if (bmp_load_addr == 0) { |
| 390 | printf("Error: bad splashimage address specified\n"); |
Nikita Kiryanov | f58c509 | 2015-01-14 10:42:49 +0200 | [diff] [blame] | 391 | return -EFAULT; |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 392 | } |
| 393 | |
Nikita Kiryanov | c2a07e3 | 2015-01-14 10:42:51 +0200 | [diff] [blame] | 394 | splash_location = select_splash_location(locations, size); |
| 395 | if (!splash_location) |
| 396 | return -EINVAL; |
| 397 | |
tomas.melin@vaisala.com | f4650ea | 2016-11-16 13:02:32 +0200 | [diff] [blame] | 398 | if (splash_location->flags == SPLASH_STORAGE_RAW) |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 399 | return splash_load_raw(splash_location, bmp_load_addr); |
tomas.melin@vaisala.com | f4650ea | 2016-11-16 13:02:32 +0200 | [diff] [blame] | 400 | else if (splash_location->flags == SPLASH_STORAGE_FS) |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 401 | return splash_load_fs(splash_location, bmp_load_addr); |
tomas.melin@vaisala.com | 45ee790 | 2017-01-13 13:20:14 +0200 | [diff] [blame] | 402 | #ifdef CONFIG_FIT |
| 403 | else if (splash_location->flags == SPLASH_STORAGE_FIT) |
| 404 | return splash_load_fit(splash_location, bmp_load_addr); |
| 405 | #endif |
Nikita Kiryanov | 7428271 | 2015-10-29 11:54:41 +0200 | [diff] [blame] | 406 | return -EINVAL; |
Igor Grinberg | 86ec16b | 2014-11-03 11:32:20 +0200 | [diff] [blame] | 407 | } |