am335x, guardian: Enable panel driver Himax HX8238D
- Enable lcd controller
- Display splash screen
Signed-off-by: Gireesh Hiremath <Gireesh.Hiremath@in.bosch.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Link: https://lore.kernel.org/r/20210611161350.2141-16-Gireesh.Hiremath@in.bosch.com
diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c
index 4388ef7..179511a 100644
--- a/board/bosch/guardian/board.c
+++ b/board/bosch/guardian/board.c
@@ -26,12 +26,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;
@@ -250,13 +254,94 @@
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;
+ struct udevice *cdev;
+
#ifdef CONFIG_LED_GPIO
led_default_state();
#endif
set_bootmode_env();
+
+ ret = uclass_get_device(UCLASS_PANEL, 0, &cdev);
+ if (ret) {
+ debug("video panel not found: %d\n", ret);
+ return ret;
+ }
+
lcdbacklight_en();
+ if (IS_ENABLED(CONFIG_AM335X_LCD))
+ splash_screen();
+
return 0;
}
#endif /* CONFIG_BOARD_LATE_INIT */