blob: 5b27116044954fb3b7de7184ceb3bca966aae4c1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Igor Grinberg86ec16b2014-11-03 11:32:20 +02002/*
3 * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
4 *
5 * Authors: Igor Grinberg <grinberg@compulab.co.il>
Igor Grinberg86ec16b2014-11-03 11:32:20 +02006 */
7
tomas.melin@vaisala.com0a7c7322017-01-13 13:20:13 +02008#include <bmp_layout.h>
Simon Glassadaaa482019-11-14 12:57:43 -07009#include <command.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -060010#include <env.h>
Nikita Kiryanovf58c5092015-01-14 10:42:49 +020011#include <errno.h>
tomas.melin@vaisala.com0a7c7322017-01-13 13:20:13 +020012#include <fs.h>
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +020013#include <fdt_support.h>
tomas.melin@vaisala.com0a7c7322017-01-13 13:20:13 +020014#include <image.h>
Simon Glass0f2af882020-05-10 11:40:05 -060015#include <log.h>
tomas.melin@vaisala.com0a7c7322017-01-13 13:20:13 +020016#include <nand.h>
17#include <sata.h>
Nikita Kiryanov1ab4c762015-01-14 10:42:52 +020018#include <spi.h>
tomas.melin@vaisala.com0a7c7322017-01-13 13:20:13 +020019#include <spi_flash.h>
20#include <splash.h>
Nikita Kiryanovbf5c3cc2015-10-29 11:54:42 +020021#include <usb.h>
Simon Glass61f09582021-11-19 13:24:05 -070022#include <virtio.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060023#include <asm/global_data.h>
Igor Grinberg86ec16b2014-11-03 11:32:20 +020024
25DECLARE_GLOBAL_DATA_PTR;
26
Nikita Kiryanov1ab4c762015-01-14 10:42:52 +020027#ifdef CONFIG_SPI_FLASH
28static struct spi_flash *sf;
Nikita Kiryanovb8183de2015-10-29 11:54:40 +020029static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
Nikita Kiryanov1ab4c762015-01-14 10:42:52 +020030{
31 if (!sf) {
32 sf = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
33 CONFIG_SF_DEFAULT_CS,
34 CONFIG_SF_DEFAULT_SPEED,
35 CONFIG_SF_DEFAULT_MODE);
36 if (!sf)
37 return -ENODEV;
38 }
39
Jaehoon Chung6c0a6322020-12-07 17:18:51 +090040 return spi_flash_read(sf, offset, read_size, (void *)(uintptr_t)bmp_load_addr);
Nikita Kiryanov1ab4c762015-01-14 10:42:52 +020041}
42#else
Nikita Kiryanovb8183de2015-10-29 11:54:40 +020043static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
Nikita Kiryanov1ab4c762015-01-14 10:42:52 +020044{
45 debug("%s: sf support not available\n", __func__);
46 return -ENOSYS;
47}
48#endif
49
Igor Grinberg86ec16b2014-11-03 11:32:20 +020050#ifdef CONFIG_CMD_NAND
Nikita Kiryanovb8183de2015-10-29 11:54:40 +020051static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
Nikita Kiryanov4b4bfd62015-01-14 10:42:50 +020052{
Grygorii Strashko5f33b822017-06-26 19:12:56 -050053 struct mtd_info *mtd = get_nand_dev_by_index(nand_curr_device);
54 return nand_read_skip_bad(mtd, offset,
Nikita Kiryanov4b4bfd62015-01-14 10:42:50 +020055 &read_size, NULL,
Grygorii Strashko5f33b822017-06-26 19:12:56 -050056 mtd->size,
Nikita Kiryanov4b4bfd62015-01-14 10:42:50 +020057 (u_char *)bmp_load_addr);
58}
59#else
Nikita Kiryanovb8183de2015-10-29 11:54:40 +020060static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
Nikita Kiryanov4b4bfd62015-01-14 10:42:50 +020061{
62 debug("%s: nand support not available\n", __func__);
63 return -ENOSYS;
64}
65#endif
66
Julien Massonc7b67d92022-10-17 10:33:21 +020067static int splash_mmc_read_raw(u32 bmp_load_addr, struct splash_location *location,
68 size_t read_size)
69{
70 struct disk_partition partition;
71 struct blk_desc *desc;
72 lbaint_t blkcnt;
73 int ret, n;
74
75 if (!IS_ENABLED(CONFIG_CMD_MMC)) {
76 debug("%s: mmc support not available\n", __func__);
77 return -ENOSYS;
78 }
79
80 ret = part_get_info_by_dev_and_name_or_num("mmc", location->devpart, &desc,
81 &partition, 1);
82 if (ret < 0)
83 return ret;
84
85 blkcnt = DIV_ROUND_UP(read_size, partition.blksz);
86 n = blk_dread(desc, partition.start, blkcnt, (void *)(uintptr_t)bmp_load_addr);
87
88 return (n == blkcnt) ? 0 : -EIO;
89}
90
Nikita Kiryanovb8183de2015-10-29 11:54:40 +020091static int splash_storage_read_raw(struct splash_location *location,
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +020092 u32 bmp_load_addr, size_t read_size)
Nikita Kiryanov4b4bfd62015-01-14 10:42:50 +020093{
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +020094 u32 offset;
95
96 if (!location)
97 return -EINVAL;
98
99 offset = location->offset;
100 switch (location->storage) {
Julien Massonc7b67d92022-10-17 10:33:21 +0200101 case SPLASH_STORAGE_MMC:
102 return splash_mmc_read_raw(bmp_load_addr, location, read_size);
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +0200103 case SPLASH_STORAGE_NAND:
Nikita Kiryanovb8183de2015-10-29 11:54:40 +0200104 return splash_nand_read_raw(bmp_load_addr, offset, read_size);
Nikita Kiryanov1ab4c762015-01-14 10:42:52 +0200105 case SPLASH_STORAGE_SF:
Nikita Kiryanovb8183de2015-10-29 11:54:40 +0200106 return splash_sf_read_raw(bmp_load_addr, offset, read_size);
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +0200107 default:
108 printf("Unknown splash location\n");
109 }
110
111 return -EINVAL;
Nikita Kiryanov4b4bfd62015-01-14 10:42:50 +0200112}
113
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +0200114static int splash_load_raw(struct splash_location *location, u32 bmp_load_addr)
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200115{
116 struct bmp_header *bmp_hdr;
117 int res;
118 size_t bmp_size, bmp_header_size = sizeof(struct bmp_header);
119
120 if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp)
121 goto splash_address_too_high;
122
Nikita Kiryanovb8183de2015-10-29 11:54:40 +0200123 res = splash_storage_read_raw(location, bmp_load_addr, bmp_header_size);
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200124 if (res < 0)
125 return res;
126
Jaehoon Chung6c0a6322020-12-07 17:18:51 +0900127 bmp_hdr = (struct bmp_header *)(uintptr_t)bmp_load_addr;
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200128 bmp_size = le32_to_cpu(bmp_hdr->file_size);
129
130 if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
131 goto splash_address_too_high;
132
Nikita Kiryanovb8183de2015-10-29 11:54:40 +0200133 return splash_storage_read_raw(location, bmp_load_addr, bmp_size);
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200134
135splash_address_too_high:
Nikita Kiryanov7f9ceea2015-01-14 10:42:54 +0200136 printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n");
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200137
Nikita Kiryanovf58c5092015-01-14 10:42:49 +0200138 return -EFAULT;
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200139}
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200140
Nikita Kiryanov74282712015-10-29 11:54:41 +0200141static int splash_select_fs_dev(struct splash_location *location)
142{
143 int res;
144
145 switch (location->storage) {
146 case SPLASH_STORAGE_MMC:
147 res = fs_set_blk_dev("mmc", location->devpart, FS_TYPE_ANY);
148 break;
Nikita Kiryanovbf5c3cc2015-10-29 11:54:42 +0200149 case SPLASH_STORAGE_USB:
150 res = fs_set_blk_dev("usb", location->devpart, FS_TYPE_ANY);
151 break;
Nikita Kiryanov80ca30d2015-10-29 11:54:43 +0200152 case SPLASH_STORAGE_SATA:
153 res = fs_set_blk_dev("sata", location->devpart, FS_TYPE_ANY);
154 break;
Eran Matityahu07a04a12016-06-07 10:38:37 +0300155 case SPLASH_STORAGE_NAND:
156 if (location->ubivol != NULL)
157 res = fs_set_blk_dev("ubi", NULL, FS_TYPE_UBIFS);
158 else
159 res = -ENODEV;
160 break;
Nikita Kiryanov74282712015-10-29 11:54:41 +0200161 default:
162 printf("Error: unsupported location storage.\n");
163 return -ENODEV;
164 }
165
166 if (res)
167 printf("Error: could not access storage.\n");
168
169 return res;
170}
Nikita Kiryanovbf5c3cc2015-10-29 11:54:42 +0200171
172#ifdef CONFIG_USB_STORAGE
173static int splash_init_usb(void)
174{
175 int err;
176
177 err = usb_init();
178 if (err)
179 return err;
180
Alexey Brodkinbfcdf3f2016-07-01 22:47:36 +0300181#ifndef CONFIG_DM_USB
182 err = usb_stor_scan(1) < 0 ? -ENODEV : 0;
183#endif
184
185 return err;
Nikita Kiryanovbf5c3cc2015-10-29 11:54:42 +0200186}
187#else
188static inline int splash_init_usb(void)
189{
190 printf("Cannot load splash image: no USB support\n");
191 return -ENOSYS;
192}
193#endif
Nikita Kiryanov74282712015-10-29 11:54:41 +0200194
Simon Glassab3055a2017-06-14 21:28:25 -0600195#ifdef CONFIG_SATA
Nikita Kiryanov80ca30d2015-10-29 11:54:43 +0200196static int splash_init_sata(void)
197{
Simon Glass6c857ad2017-07-29 11:35:13 -0600198 return sata_probe(0);
Nikita Kiryanov80ca30d2015-10-29 11:54:43 +0200199}
200#else
201static inline int splash_init_sata(void)
202{
203 printf("Cannot load splash image: no SATA support\n");
204 return -ENOSYS;
205}
206#endif
207
Simon Glass61f09582021-11-19 13:24:05 -0700208static int splash_init_virtio(void)
209{
210 if (!IS_ENABLED(CONFIG_VIRTIO)) {
211 printf("Cannot load splash image: no virtio support\n");
212 return -ENOSYS;
213 } else {
214 return virtio_init();
215 }
216}
217
Devarsh Thakkar699afcb2024-01-24 14:35:09 +0530218#if defined(CONFIG_CMD_UBIFS) && !defined(CONFIG_SPL_BUILD)
Eran Matityahu07a04a12016-06-07 10:38:37 +0300219static int splash_mount_ubifs(struct splash_location *location)
220{
221 int res;
222 char cmd[32];
223
224 sprintf(cmd, "ubi part %s", location->mtdpart);
225 res = run_command(cmd, 0);
226 if (res)
227 return res;
228
229 sprintf(cmd, "ubifsmount %s", location->ubivol);
230 res = run_command(cmd, 0);
231
232 return res;
233}
234
235static inline int splash_umount_ubifs(void)
236{
237 return run_command("ubifsumount", 0);
238}
239#else
240static inline int splash_mount_ubifs(struct splash_location *location)
241{
242 printf("Cannot load splash image: no UBIFS support\n");
243 return -ENOSYS;
244}
245
246static inline int splash_umount_ubifs(void)
247{
248 printf("Cannot unmount UBIFS: no UBIFS support\n");
249 return -ENOSYS;
250}
251#endif
252
Nikita Kiryanov74282712015-10-29 11:54:41 +0200253#define SPLASH_SOURCE_DEFAULT_FILE_NAME "splash.bmp"
254
255static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr)
256{
Nikita Kiryanovbf5c3cc2015-10-29 11:54:42 +0200257 int res = 0;
Nikita Kiryanov74282712015-10-29 11:54:41 +0200258 loff_t bmp_size;
Jonathan Golder26b61312017-02-24 17:46:10 +0100259 loff_t actread;
Nikita Kiryanov74282712015-10-29 11:54:41 +0200260 char *splash_file;
261
Simon Glass64b723f2017-08-03 12:22:12 -0600262 splash_file = env_get("splashfile");
Nikita Kiryanov74282712015-10-29 11:54:41 +0200263 if (!splash_file)
264 splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
265
Nikita Kiryanovbf5c3cc2015-10-29 11:54:42 +0200266 if (location->storage == SPLASH_STORAGE_USB)
267 res = splash_init_usb();
268
Nikita Kiryanov80ca30d2015-10-29 11:54:43 +0200269 if (location->storage == SPLASH_STORAGE_SATA)
270 res = splash_init_sata();
271
Simon Glass61f09582021-11-19 13:24:05 -0700272 if (location->storage == SPLASH_STORAGE_VIRTIO)
273 res = splash_init_virtio();
274
Eran Matityahu07a04a12016-06-07 10:38:37 +0300275 if (location->ubivol != NULL)
276 res = splash_mount_ubifs(location);
277
Nikita Kiryanovbf5c3cc2015-10-29 11:54:42 +0200278 if (res)
279 return res;
280
Nikita Kiryanov74282712015-10-29 11:54:41 +0200281 res = splash_select_fs_dev(location);
282 if (res)
Eran Matityahu07a04a12016-06-07 10:38:37 +0300283 goto out;
Nikita Kiryanov74282712015-10-29 11:54:41 +0200284
285 res = fs_size(splash_file, &bmp_size);
286 if (res) {
287 printf("Error (%d): cannot determine file size\n", res);
Eran Matityahu07a04a12016-06-07 10:38:37 +0300288 goto out;
Nikita Kiryanov74282712015-10-29 11:54:41 +0200289 }
290
291 if (bmp_load_addr + bmp_size >= gd->start_addr_sp) {
292 printf("Error: splashimage address too high. Data overwrites U-Boot and/or placed beyond DRAM boundaries.\n");
Eran Matityahu07a04a12016-06-07 10:38:37 +0300293 res = -EFAULT;
294 goto out;
Nikita Kiryanov74282712015-10-29 11:54:41 +0200295 }
296
297 splash_select_fs_dev(location);
Jonathan Golder26b61312017-02-24 17:46:10 +0100298 res = fs_read(splash_file, bmp_load_addr, 0, 0, &actread);
Eran Matityahu07a04a12016-06-07 10:38:37 +0300299
300out:
301 if (location->ubivol != NULL)
302 splash_umount_ubifs();
303
304 return res;
Nikita Kiryanov74282712015-10-29 11:54:41 +0200305}
306
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +0200307/**
308 * select_splash_location - return the splash location based on board support
309 * and env variable "splashsource".
310 *
311 * @locations: An array of supported splash locations.
312 * @size: Size of splash_locations array.
313 *
314 * @return: If a null set of splash locations is given, or
315 * splashsource env variable is set to unsupported value
316 * return NULL.
317 * If splashsource env variable is not defined
318 * return the first entry in splash_locations as default.
319 * If splashsource env variable contains a supported value
320 * return the location selected by splashsource.
321 */
322static struct splash_location *select_splash_location(
323 struct splash_location *locations, uint size)
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200324{
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +0200325 int i;
326 char *env_splashsource;
327
328 if (!locations || size == 0)
329 return NULL;
330
Simon Glass64b723f2017-08-03 12:22:12 -0600331 env_splashsource = env_get("splashsource");
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +0200332 if (env_splashsource == NULL)
333 return &locations[0];
334
335 for (i = 0; i < size; i++) {
336 if (!strcmp(locations[i].name, env_splashsource))
337 return &locations[i];
338 }
339
340 printf("splashsource env variable set to unsupported value\n");
341 return NULL;
342}
343
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200344#ifdef CONFIG_FIT
345static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)
346{
347 int res;
348 int node_offset;
Leo Ruane9b74d92019-02-08 10:51:35 +0100349 const char *splash_file;
Leo Ruanefc20c62019-02-08 10:51:36 +0100350 const void *internal_splash_data;
351 size_t internal_splash_size;
352 int external_splash_addr;
353 int external_splash_size;
354 bool is_splash_external = false;
Simon Glassbb7d3bb2022-09-06 20:26:52 -0600355 struct legacy_img_hdr *img_header;
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200356 const u32 *fit_header;
357 u32 fit_size;
Simon Glassbb7d3bb2022-09-06 20:26:52 -0600358 const size_t header_size = sizeof(struct legacy_img_hdr);
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200359
360 /* Read in image header */
361 res = splash_storage_read_raw(location, bmp_load_addr, header_size);
362 if (res < 0)
363 return res;
364
Nikhil M Jain92981322023-06-21 16:29:53 +0530365 img_header = (struct legacy_img_hdr *)(uintptr_t)bmp_load_addr;
Niko Mauno7e9e0b52017-08-03 09:53:24 +0300366 if (image_get_magic(img_header) != FDT_MAGIC) {
367 printf("Could not find FDT magic\n");
368 return -EINVAL;
369 }
370
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200371 fit_size = fdt_totalsize(img_header);
372
373 /* Read in entire FIT */
374 fit_header = (const u32 *)(bmp_load_addr + header_size);
Nikhil M Jain92981322023-06-21 16:29:53 +0530375 res = splash_storage_read_raw(location, (uintptr_t)fit_header, fit_size);
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200376 if (res < 0)
377 return res;
378
Simon Glassd563c252021-02-15 17:08:09 -0700379 res = fit_check_format(fit_header, IMAGE_SIZE_INVAL);
380 if (res) {
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200381 debug("Could not find valid FIT image\n");
Simon Glassd563c252021-02-15 17:08:09 -0700382 return res;
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200383 }
384
Leo Ruane9b74d92019-02-08 10:51:35 +0100385 /* Get the splash image node */
386 splash_file = env_get("splashfile");
387 if (!splash_file)
388 splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
389
390 node_offset = fit_image_get_node(fit_header, splash_file);
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200391 if (node_offset < 0) {
392 debug("Could not find splash image '%s' in FIT\n",
Leo Ruane9b74d92019-02-08 10:51:35 +0100393 splash_file);
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200394 return -ENOENT;
395 }
396
Leo Ruanefc20c62019-02-08 10:51:36 +0100397 /* Extract the splash data from FIT */
398 /* 1. Test if splash is in FIT internal data. */
399 if (!fit_image_get_data(fit_header, node_offset, &internal_splash_data, &internal_splash_size))
Nikhil M Jain92981322023-06-21 16:29:53 +0530400 memmove((void *)(uintptr_t)bmp_load_addr, internal_splash_data, internal_splash_size);
Leo Ruanefc20c62019-02-08 10:51:36 +0100401 /* 2. Test if splash is in FIT external data with fixed position. */
402 else if (!fit_image_get_data_position(fit_header, node_offset, &external_splash_addr))
403 is_splash_external = true;
404 /* 3. Test if splash is in FIT external data with offset. */
405 else if (!fit_image_get_data_offset(fit_header, node_offset, &external_splash_addr)) {
406 /* Align data offset to 4-byte boundary */
407 fit_size = ALIGN(fdt_totalsize(fit_header), 4);
408 /* External splash offset means the offset by end of FIT header */
409 external_splash_addr += location->offset + fit_size;
410 is_splash_external = true;
411 } else {
412 printf("Failed to get splash image from FIT\n");
413 return -ENODATA;
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200414 }
415
Leo Ruanefc20c62019-02-08 10:51:36 +0100416 if (is_splash_external) {
417 res = fit_image_get_data_size(fit_header, node_offset, &external_splash_size);
418 if (res < 0) {
419 printf("Failed to get size of splash image (err=%d)\n", res);
420 return res;
421 }
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200422
Leo Ruanefc20c62019-02-08 10:51:36 +0100423 /* Read in the splash data */
424 location->offset = external_splash_addr;
425 res = splash_storage_read_raw(location, bmp_load_addr, external_splash_size);
426 if (res < 0)
427 return res;
428 }
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200429
430 return 0;
431}
432#endif /* CONFIG_FIT */
433
Nikita Kiryanov7f9ceea2015-01-14 10:42:54 +0200434/**
435 * splash_source_load - load splash image from a supported location.
436 *
437 * Select a splash image location based on the value of splashsource environment
438 * variable and the board supported splash source locations, and load a
439 * splashimage to the address pointed to by splashimage environment variable.
440 *
441 * @locations: An array of supported splash locations.
442 * @size: Size of splash_locations array.
443 *
444 * @return: 0 on success, negative value on failure.
445 */
446int splash_source_load(struct splash_location *locations, uint size)
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +0200447{
448 struct splash_location *splash_location;
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200449 char *env_splashimage_value;
Julien Masson0cdb0aa2022-10-17 10:33:22 +0200450 char *devpart;
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200451 u32 bmp_load_addr;
452
Simon Glass64b723f2017-08-03 12:22:12 -0600453 env_splashimage_value = env_get("splashimage");
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200454 if (env_splashimage_value == NULL)
Nikita Kiryanovf58c5092015-01-14 10:42:49 +0200455 return -ENOENT;
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200456
Simon Glass3ff49ec2021-07-24 09:03:29 -0600457 bmp_load_addr = hextoul(env_splashimage_value, 0);
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200458 if (bmp_load_addr == 0) {
459 printf("Error: bad splashimage address specified\n");
Nikita Kiryanovf58c5092015-01-14 10:42:49 +0200460 return -EFAULT;
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200461 }
462
Nikita Kiryanovc2a07e32015-01-14 10:42:51 +0200463 splash_location = select_splash_location(locations, size);
464 if (!splash_location)
465 return -EINVAL;
466
Julien Masson0cdb0aa2022-10-17 10:33:22 +0200467 devpart = env_get("splashdevpart");
468 if (devpart)
469 splash_location->devpart = devpart;
470
tomas.melin@vaisala.comf4650ea2016-11-16 13:02:32 +0200471 if (splash_location->flags == SPLASH_STORAGE_RAW)
Nikita Kiryanov74282712015-10-29 11:54:41 +0200472 return splash_load_raw(splash_location, bmp_load_addr);
tomas.melin@vaisala.comf4650ea2016-11-16 13:02:32 +0200473 else if (splash_location->flags == SPLASH_STORAGE_FS)
Nikita Kiryanov74282712015-10-29 11:54:41 +0200474 return splash_load_fs(splash_location, bmp_load_addr);
tomas.melin@vaisala.com45ee7902017-01-13 13:20:14 +0200475#ifdef CONFIG_FIT
476 else if (splash_location->flags == SPLASH_STORAGE_FIT)
477 return splash_load_fit(splash_location, bmp_load_addr);
478#endif
Nikita Kiryanov74282712015-10-29 11:54:41 +0200479 return -EINVAL;
Igor Grinberg86ec16b2014-11-03 11:32:20 +0200480}