]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/karo/common/splashimage.c
karo: tx6: add support for TX6-V2 (eMMC)
[karo-tx-uboot.git] / board / karo / common / splashimage.c
1 /*
2  * (C) Copyright 2012 Lothar Waßmann <LW@KARO-electronics.de>
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  */
17
18 #include <common.h>
19 #include <errno.h>
20 #include <lcd.h>
21 #include <nand.h>
22 #include <jffs2/load_kernel.h>
23
24 #include "karo.h"
25
26 DECLARE_GLOBAL_DATA_PTR;
27
28 static ulong calc_fbsize(void)
29 {
30         return panel_info.vl_row * panel_info.vl_col *
31                 NBITS(panel_info.vl_bpix) / 8;
32 }
33
34 int karo_load_splashimage(int mode)
35 {
36         int ret;
37         unsigned long la = gd->fb_base;
38         char *splashimage = getenv("splashimage");
39         ulong fbsize = calc_fbsize();
40         char *end;
41
42         if (!la || !splashimage)
43                 return 0;
44
45         if ((simple_strtoul(splashimage, &end, 16) != 0) &&
46                 *end == '\0') {
47                 if (mode)
48                         return 0;
49                 la = simple_strtoul(splashimage, NULL, 16);
50                 splashimage = "logo.bmp";
51         } else if (!mode) {
52                 return 0;
53         }
54
55         if (tstc())
56                 return -ENODEV;
57
58         ret = karo_load_part(splashimage, (void *)la, fbsize);
59         if (ret) {
60                 printf("Failed to load logo from '%s': %d\n", splashimage, ret);
61                 return ret;
62         }
63         return 0;
64 }