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+
11 #include <bmp_layout.h>
13 DECLARE_GLOBAL_DATA_PTR;
15 #ifdef CONFIG_CMD_NAND
16 static int splash_load_from_nand(u32 bmp_load_addr, int nand_offset)
18 struct bmp_header *bmp_hdr;
20 size_t bmp_size, bmp_header_size = sizeof(struct bmp_header);
22 if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp)
23 goto splash_address_too_high;
25 res = nand_read_skip_bad(&nand_info[nand_curr_device],
26 nand_offset, &bmp_header_size,
27 NULL, nand_info[nand_curr_device].size,
28 (u_char *)bmp_load_addr);
32 bmp_hdr = (struct bmp_header *)bmp_load_addr;
33 bmp_size = le32_to_cpu(bmp_hdr->file_size);
35 if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
36 goto splash_address_too_high;
38 return nand_read_skip_bad(&nand_info[nand_curr_device],
39 nand_offset, &bmp_size,
40 NULL, nand_info[nand_curr_device].size,
41 (u_char *)bmp_load_addr);
43 splash_address_too_high:
44 printf("Error: splashimage address too high. Data overwrites U-Boot "
45 "and/or placed beyond DRAM boundaries.\n");
50 static inline int splash_load_from_nand(u32 bmp_load_addr, int nand_offset)
54 #endif /* CONFIG_CMD_NAND */
56 int cl_splash_screen_prepare(int nand_offset)
58 char *env_splashimage_value;
61 env_splashimage_value = getenv("splashimage");
62 if (env_splashimage_value == NULL)
65 bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16);
66 if (bmp_load_addr == 0) {
67 printf("Error: bad splashimage address specified\n");
71 return splash_load_from_nand(bmp_load_addr, nand_offset);