From: Gireesh Hiremath <gireesh.hirem...@in.bosch.com>

- Display splash screen
- Print "U-Boot" on display when bmp fails to load due to any reason

Signed-off-by: Gireesh Hiremath <gireesh.hirem...@in.bosch.com>
---
 board/bosch/guardian/board.c      | 77 ++++++++++++++++++++++++++++++-
 configs/am335x_guardian_defconfig |  5 +-
 include/configs/am335x_guardian.h | 11 +++++
 3 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c
index a34262bd13..394c56d72e 100644
--- a/board/bosch/guardian/board.c
+++ b/board/bosch/guardian/board.c
@@ -29,12 +29,16 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/mem-guardian.h>
-#include <asm/arch/mmc_host_def.h>
 #include <asm/arch/omap.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/emif.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <jffs2/load_kernel.h>
+#include <mtd.h>
+#include <nand.h>
+#include <video.h>
+#include <video_console.h>
 #include "board.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -270,6 +274,74 @@ void lcdbacklight_en(void)
                           brightness != 0 ? 0x0A : 0x02, 0xFF);
 }
 
+#if IS_ENABLED(CONFIG_AM335X_LCD)
+static void splash_screen(void)
+{
+       struct udevice *video_dev;
+       struct udevice *console_dev;
+       struct video_priv *vid_priv;
+       struct mtd_info *mtd;
+       size_t len;
+       int ret;
+
+       struct mtd_device *mtd_dev;
+       struct part_info  *part;
+       u8 pnum;
+
+       ret = uclass_get_device(UCLASS_VIDEO, 0, &video_dev);
+       if (ret != 0) {
+               debug("video device not found\n");
+               goto exit;
+       }
+
+       vid_priv = dev_get_uclass_priv(video_dev);
+       mtdparts_init();
+
+       if (find_dev_and_part(SPLASH_SCREEN_NAND_PART, &mtd_dev, &pnum, &part)) 
{
+               debug("Could not find nand partition\n");
+               goto splash_screen_text;
+       }
+
+       mtd = get_nand_dev_by_index(mtd_dev->id->num);
+       if (!mtd) {
+               debug("MTD partition is not valid\n");
+               goto splash_screen_text;
+       }
+
+       len = SPLASH_SCREEN_BMP_FILE_SIZE;
+       ret = nand_read_skip_bad(mtd, part->offset, &len, NULL,
+                                SPLASH_SCREEN_BMP_FILE_SIZE,
+                                (u_char *)SPLASH_SCREEN_BMP_LOAD_ADDR);
+       if (ret != 0) {
+               debug("Reading NAND partition failed\n");
+               goto splash_screen_text;
+       }
+
+       ret = video_bmp_display(video_dev, SPLASH_SCREEN_BMP_LOAD_ADDR, 0, 0, 
false);
+       if (ret != 0) {
+               debug("No valid bmp image found!!\n");
+               goto splash_screen_text;
+       } else {
+               goto exit;
+       }
+
+splash_screen_text:
+       vid_priv->colour_fg = CONSOLE_COLOR_RED;
+       vid_priv->colour_bg = CONSOLE_COLOR_BLACK;
+
+       if (!uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &console_dev)) {
+               debug("Found console\n");
+               vidconsole_position_cursor(console_dev, 17, 7);
+               vidconsole_put_string(console_dev, SPLASH_SCREEN_TEXT);
+       } else {
+               debug("No console device found\n");
+       }
+
+exit:
+       return;
+}
+#endif /* CONFIG_AM335X_LCD */
+
 int board_late_init(void)
 {
        int ret;
@@ -287,6 +359,9 @@ int board_late_init(void)
        }
 
        lcdbacklight_en();
+#if IS_ENABLED(CONFIG_AM335X_LCD)
+       splash_screen();
+#endif
        return 0;
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
diff --git a/configs/am335x_guardian_defconfig 
b/configs/am335x_guardian_defconfig
index b7170cd79e..48b9bf45a4 100644
--- a/configs/am335x_guardian_defconfig
+++ b/configs/am335x_guardian_defconfig
@@ -1,7 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_OMAP2PLUS=y
-CONFIG_SPL_GPIO_SUPPORT=y
+# CONFIG_SPL_GPIO_SUPPORT is not set
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_ENV_SIZE=0x40000
@@ -50,6 +50,7 @@ CONFIG_CMD_MTD=y
 CONFIG_CMD_NAND=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_BMP=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=nand.0:256k(SPL),256k(SPL.backup1),256k(SPL.backup2),256k(SPL.backup3),1m(u-boot),1m(u-boot.backup1),1m(u-boot-2),1m(u-boot-2.backup1),256k(u-boot-env),256k(u-boot-env.backup1),256k(splash-screen),-(UBI)"
@@ -100,6 +101,8 @@ CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
 CONFIG_USB_ETHER=y
+CONFIG_VIDEO_BPP16=y
+CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_AM335X_LCD=y
 CONFIG_SPL_WDT=y
 # CONFIG_SPL_USE_TINY_PRINTF is not set
diff --git a/include/configs/am335x_guardian.h 
b/include/configs/am335x_guardian.h
index 236be1a093..1a14b4249d 100644
--- a/include/configs/am335x_guardian.h
+++ b/include/configs/am335x_guardian.h
@@ -81,6 +81,17 @@
 
 #endif /* ! CONFIG_SPL_BUILD */
 
+#define CONFIG_BMP_16BPP
+#define SPLASH_SCREEN_NAND_PART "nand0,10"
+#define SPLASH_SCREEN_BMP_FILE_SIZE 0x26000
+#define SPLASH_SCREEN_BMP_LOAD_ADDR 0x82000000
+#define SPLASH_SCREEN_TEXT "U-Boot"
+
+/* BGR 16Bit Color Definitions */
+#define CONSOLE_COLOR_BLACK 0x0000
+#define CONSOLE_COLOR_WHITE 0xFFFF
+#define CONSOLE_COLOR_RED 0x001F
+
 /* NS16550 Configuration */
 #define CONFIG_SYS_NS16550_COM1                0x44e09000      /* UART0 */
 #define CONFIG_SYS_NS16550_COM2                0x48022000      /* UART1 */
-- 
2.20.1

Reply via email to