2 * (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
4 * Authors: Igor Grinberg <grinberg@compulab.co.il>
6 * SPDX-License-Identifier: GPL-2.0+
12 #include <bmp_layout.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 #ifdef CONFIG_CMD_NAND
18 static int splash_nand_read(u32 bmp_load_addr, int offset, size_t read_size)
20 return nand_read_skip_bad(&nand_info[nand_curr_device], offset,
22 nand_info[nand_curr_device].size,
23 (u_char *)bmp_load_addr);
26 static int splash_nand_read(u32 bmp_load_addr, int offset, size_t read_size)
28 debug("%s: nand support not available\n", __func__);
33 static int splash_storage_read(u32 bmp_load_addr, int offset, size_t read_size)
35 return splash_nand_read(bmp_load_addr, offset, read_size);
38 static int splash_load_raw(u32 bmp_load_addr, int offset)
40 struct bmp_header *bmp_hdr;
42 size_t bmp_size, bmp_header_size = sizeof(struct bmp_header);
44 if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp)
45 goto splash_address_too_high;
47 res = splash_storage_read(bmp_load_addr, offset, bmp_header_size);
51 bmp_hdr = (struct bmp_header *)bmp_load_addr;
52 bmp_size = le32_to_cpu(bmp_hdr->file_size);
54 if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
55 goto splash_address_too_high;
57 return splash_storage_read(bmp_load_addr, offset, bmp_size);
59 splash_address_too_high:
60 printf("Error: splashimage address too high. Data overwrites U-Boot "
61 "and/or placed beyond DRAM boundaries.\n");
66 int cl_splash_screen_prepare(int offset)
68 char *env_splashimage_value;
71 env_splashimage_value = getenv("splashimage");
72 if (env_splashimage_value == NULL)
75 bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16);
76 if (bmp_load_addr == 0) {
77 printf("Error: bad splashimage address specified\n");
81 return splash_load_raw(bmp_load_addr, offset);