Skip to contentSkip to conversation

Enable SPL splash screen on AM62x

PATCH In review Nikhil M Jain 2 participants 12 messages May 9, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover Enable SPL splash screen on AM62x

This patch series aims at eanbling SPL splash screen on AM62x.

Changes in V3:
- Update stackpointer after relocation.
- Return a pointer after page table setup.
- Enable dcache at SPL.
- Add method to reserve video using blob.
- Pass video buffer info from SPL to U-boot.
- Add config to remove video.
- Add bloblist address in memory map.

Nikhil M Jain (10):
common: spl: spl: Update stack pointer address
arch: arm: mach-k3: common: Return a pointer after setting page table
arch: arm: mach-k3: am625_init: Enable Dcache in SPL
board: ti: am62x: evm: Add necessary functions to call splash screen
include: video: Reserve video using blob
common: board_f: Pass frame buffer info from SPL to u-boot
drivers: video: Kconfig: Add config remove video
common: spl: spl: Remove video driver before u-boot proper
configs: am62x_evm_a53_defconfig: Changes in memory to support SPL
splash screen
board: ti: am62x: am62x: Update splashimage as per new memory map

 arch/arm/mach-k3/am625_init.c   |  1 +
 arch/arm/mach-k3/common.c       |  2 ++
 board/ti/am62x/am62x.env        |  2 +-
 board/ti/am62x/evm.c            | 30 ++++++++++++++++++++++++++++++
 common/board_f.c                | 13 ++++++++++++-
 common/spl/spl.c                | 16 ++++++++++++++++
 configs/am62x_evm_a53_defconfig | 12 ++++++++----
 drivers/video/Kconfig           | 12 ++++++++++++
 drivers/video/video-uclass.c    | 24 ++++++++++++++++++++++++
 include/video.h                 |  9 +++++++++
 10 files changed, 115 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 1/10 common: spl: spl: Update stack pointer address

At SPL stage when stack is relocated, the stack pointer needs to be updated, the stack pointer may point to stack in on chip memory even though stack is relocated.

---
V3 (patch introduced):
- Update stackpointer after relocation.

 common/spl/spl.c | 1 +
 1 file changed, 1 insertion(+)
common/spl/spl.c +1 -0
index a630e79866..21a62521a9 100644
@@ -977,6 +977,7 @@ ulong spl_relocate_stack_gd(void)
 #endif
 	/* Get stack position: use 8-byte alignment for ABI compliance */
 	ptr = CONFIG_SPL_STACK_R_ADDR - roundup(sizeof(gd_t),16);
+	gd->start_addr_sp = ptr;
 	new_gd = (gd_t *)ptr;
 	memcpy(new_gd, (void *)gd, sizeof(gd_t));
 #if CONFIG_IS_ENABLED(DM)
Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 2/10 arch: arm: mach-k3: common: Return a pointer after setting page table

In reply to Nikhil M Jain

In spl_dcache_enable after setting up page table, set gd->relocaddr pointer with 64KB alignment, to get address to reserve video.

---
V3 (patch introduced):
- return a pointer after page table setup.

 arch/arm/mach-k3/common.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-k3/common.c +2 -0
index a2adb791f6..a805a5640a 100644
@@ -576,6 +576,8 @@ void spl_enable_dcache(void)
 	gd->arch.tlb_addr = ram_top - gd->arch.tlb_size;
 	debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr,
 	      gd->arch.tlb_addr + gd->arch.tlb_size);
+	gd->relocaddr = gd->arch.tlb_addr;
+	gd->relocaddr &= ~(0x10000 - 1);
 
 	dcache_enable();
 #endif
Signature · 1 line
2.34.1
#3 lore raw

PATCH v3 3/10 arch: arm: mach-k3: am625_init: Enable Dcache in SPL

In reply to Nikhil M Jain

Add support for enabling dcache already in SPL.

---
V3 (patch introduced):
- Enable dcache at SPL.

 arch/arm/mach-k3/am625_init.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-k3/am625_init.c +1 -0
index a91c15ca4e..10956399e9 100644
@@ -168,6 +168,7 @@ void board_init_f(ulong dummy)
 	if (ret)
 		panic("DRAM init failed: %d\n", ret);
 #endif
+	spl_enable_dcache();
 }
 
 u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
Signature · 1 line
2.34.1
#4 lore raw

PATCH v3 4/10 board: ti: am62x: evm: Add necessary functions to call splash screen

In reply to Nikhil M Jain

To enable splash screen at SPL, call methods to reserve memory for video and enable cache, and splash_display to display bmp image.

---
V3:
- Remove function call for dram setup and set pagetable.
- Call splash display only if SPLASH_SCREEN is defined.

V2:
- No change.

 board/ti/am62x/evm.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/ti/am62x/evm.c +30 -0
index 1b7b439cf5..22967bb1bc 100644
@@ -9,6 +9,7 @@
 
 #include <env.h>
 #include <spl.h>
+#include <init.h>
 #include <video.h>
 #include <splash.h>
 #include <k3-ddrss.h>
@@ -59,6 +60,35 @@ int dram_init_banksize(void)
 }
 
 #if defined(CONFIG_SPL_BUILD)
+
+static int video_setup(void)
+{
+	if (CONFIG_IS_ENABLED(VIDEO)) {
+		ulong addr;
+		int ret;
+
+		addr = gd->relocaddr;
+		ret = video_reserve(&addr);
+		if (ret)
+			return ret;
+		debug("Reserving %luk for video at: %08lx\n",
+		      ((unsigned long)gd->relocaddr - addr) >> 10, addr);
+		gd->relocaddr = addr;
+	}
+
+	return 0;
+}
+
+void spl_board_init(void)
+{
+	if (CONFIG_IS_ENABLED(VIDEO)) {
+		video_setup();
+		enable_caches();
+		if (CONFIG_IS_ENABLED(SPLASH_SCREEN))
+			splash_display();
+	}
+}
+
 #if defined(CONFIG_K3_AM64_DDRSS)
 static void fixup_ddr_driver_for_ecc(struct spl_image_info *spl_image)
 {
Signature · 1 line
2.34.1
#5 lore raw

PATCH v3 5/10 include: video: Reserve video using blob

In reply to Nikhil M Jain

Add method to reserve video using blob.

---
V3 (patch introduced):
- Add method to reserve video using blob.

This patch depends on a patch sent by Simon Glass
https://lore.kernel.org/u-boot/20230504165823.v3.25.Ieb0824a81d8ad4109fa501c9497b01b8749f913a@changeid/

 drivers/video/video-uclass.c | 12 ++++++++++++
 include/video.h              |  9 +++++++++
 2 files changed, 21 insertions(+)
drivers/video/video-uclass.c +12 -0
index 8396bdfb11..1264ad1101 100644
@@ -142,6 +142,18 @@ int video_reserve(ulong *addrp)
 	return 0;
 }
 
+int video_reserve_from_blob(struct video_handoff *ho)
+{
+#if CONFIG_IS_ENABLED(VIDEO)
+	gd->video_bottom = ho->fb;
+	gd->fb_base = ho->fb;
+	gd->video_top = ho->fb + ho->size;
+	debug("Reserving %luk for video using blob at: %08x\n",
+	      ((unsigned long)ho->size) >> 10, (u32)ho->fb);
+#endif
+	return 0;
+}
+
 int video_fill(struct udevice *dev, u32 colour)
 {
 	struct video_priv *priv = dev_get_uclass_priv(dev);
include/video.h +9 -0
index 18ed159b8d..13460adc45 100644
@@ -389,4 +389,13 @@ int bmp_display(ulong addr, int x, int y);
  */
 int bmp_info(ulong addr);
 
+/*
+ * video_reserve_from_blob()- Reserve frame-buffer memory for video devices
+ * using blobs.
+ *
+ * @ho: video information passed from SPL
+ * Returns: 0 (always)
+ */
+int video_reserve_from_blob(struct video_handoff *ho);
+
 #endif
Signature · 1 line
2.34.1
#6 lore raw

PATCH v3 6/10 common: board_f: Pass frame buffer info from SPL to u-boot

In reply to Nikhil M Jain

When video is set up in SPL, U-Boot proper needs to use the correct frame buffer address to reserve particular location in memory, to avoid displaying artifacts on the screen.

Put the framebuffer address and size in a bloblist to make them available at u-boot proper, if in u-boot proper CONFIG_VIDEO is defined.

---
V3 (patch introduced):
- Pass video buffer info from SPL to U-boot.

This patch depends on a patch sent by Simon Glass
https://lore.kernel.org/u-boot/20230504165823.v3.25.Ieb0824a81d8ad4109fa501c9497b01b8749f913a@changeid/

 common/board_f.c             | 13 ++++++++++++-
 drivers/video/video-uclass.c | 12 ++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
common/board_f.c +12 -1
index f3c1ab53b1..432195f79e 100644
@@ -411,7 +411,17 @@ __weak int arch_reserve_mmu(void)
 
 static int reserve_video(void)
 {
-	if (IS_ENABLED(CONFIG_VIDEO)) {
+#if (IS_ENABLED(CONFIG_VIDEO))
+	if (IS_ENABLED(CONFIG_SPL_VIDEO) && spl_phase() > PHASE_SPL &&
+	    CONFIG_IS_ENABLED(BLOBLIST)) {
+		struct video_handoff *ho;
+
+		ho = bloblist_find(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho));
+		if (!ho)
+			return log_msg_ret("blf", -ENOENT);
+		video_reserve_from_blob(ho);
+		gd->relocaddr = ho->fb;
+	} else {
 		ulong addr;
 		int ret;
 
@@ -423,6 +433,7 @@ static int reserve_video(void)
 		      ((unsigned long)gd->relocaddr - addr) >> 10, addr);
 		gd->relocaddr = addr;
 	}
+#endif
 
 	return 0;
 }
drivers/video/video-uclass.c +12 -0
index 1264ad1101..324216b0f5 100644
@@ -6,12 +6,14 @@
 #define LOG_CATEGORY UCLASS_VIDEO
 
 #include <common.h>
+#include <bloblist.h>
 #include <console.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <log.h>
 #include <malloc.h>
 #include <mapmem.h>
+#include <spl.h>
 #include <stdio_dev.h>
 #include <video.h>
 #include <video_console.h>
@@ -139,6 +141,16 @@ int video_reserve(ulong *addrp)
 	debug("Video frame buffers from %lx to %lx\n", gd->video_bottom,
 	      gd->video_top);
 
+	if (spl_phase() == PHASE_SPL && CONFIG_IS_ENABLED(BLOBLIST)) {
+		struct video_handoff *ho;
+
+		ho = bloblist_add(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho), 0);
+		if (!ho)
+			return log_msg_ret("blf", -ENOENT);
+		ho->fb = *addrp;
+		ho->size = size;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
#7 lore raw

PATCH v3 7/10 drivers: video: Kconfig: Add config remove video

In reply to Nikhil M Jain

Add VIDEO_REMOVE configs to allow user to control removing of video driver, in between stages.

---
V3 (patch introduced):
- Add config to remove video.

 drivers/video/Kconfig | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/video/Kconfig +12 -0
index 05eaaa767a..eeb10ebd10 100644
@@ -809,6 +809,12 @@ config IHS_VIDEO_OUT
 	  out On-screen Display (OSD) used on gdsys FPGAs to control dynamic
 	  textual overlays of the display outputs.
 
+config VIDEO_REMOVE
+	bool "Remove video driver"
+	help
+		Use this option to specify if you want to remove video driver before
+		loading OS.
+
 config SPLASH_SCREEN
 	bool "Show a splash-screen image"
 	help
@@ -1032,6 +1038,12 @@ config SPL_SYS_WHITE_ON_BLACK
 	 This can be better in low-light situations or to reduce eye strain in
 	 some cases.
 
+config SPL_VIDEO_REMOVE
+	bool "Remove video driver after SPL stage"
+	help
+	 if this  option is enabled video driver will be removed at the end of
+	 SPL stage, beforeloading the next stage.
+
 if SPL_SPLASH_SCREEN
 
 config SPL_SPLASH_SCREEN_ALIGN
Signature · 1 line
2.34.1
#8 lore raw

PATCH v3 8/10 common: spl: spl: Remove video driver before u-boot proper

In reply to Nikhil M Jain

Add method to remove video driver before loading u-boot proper, when there is no bloblist passed to next stage, to avoid displaying of artifacts in the next stage, if video is not defined in that stage.

---
V3 (patch introduced):
- Remove video only if SPL_VIDEO_REMOVE is defined.

V2:
- No change.

 common/spl/spl.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
common/spl/spl.c +15 -0
index 21a62521a9..8b67a37a26 100644
@@ -35,6 +35,8 @@
 #include <mapmem.h>
 #include <dm/root.h>
 #include <dm/util.h>
+#include <dm/device-internal.h>
+#include <dm/uclass-internal.h>
 #include <linux/compiler.h>
 #include <fdt_support.h>
 #include <bootcount.h>
@@ -889,6 +891,19 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		debug("Failed to stash bootstage: err=%d\n", ret);
 #endif
 
+#if IS_ENABLED(CONFIG_SPL_VIDEO_REMOVE)
+	struct udevice *dev;
+	int rc;
+
+	rc = uclass_find_first_device(UCLASS_VIDEO, &dev);
+	if (!rc && dev) {
+		rc = device_remove(dev, DM_REMOVE_NORMAL);
+		if (rc)
+			printf("Cannot remove video device '%s' (err=%d)\n",
+			       dev->name, rc);
+	}
+#endif
+
 	spl_board_prepare_for_boot();
 	jump_to_image_no_args(&spl_image);
 }
Signature · 1 line
2.34.1
#9 lore raw

PATCH v3 9/10 configs: am62x_evm_a53_defconfig: Changes in memory to support SPL splash screen

In reply to Nikhil M Jain

To enable splash at A53 SPL, need to do memory map changes which involves locate stack above malloc and have enough space to load bmp image above stack. To load a 1920X1200 image a minimum of 8.8MB space is needed, to support it move malloc down to 0x80b80000 from 0x80480000 and bss to 0x80c80000 to have 1MB buffer between malloc and BSS.

Observed SPL size 195KB, CONFIG_SPL_SIZE_LIMIT set to 256KB. Observed stack size 1904 Bytes, CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK set to 2KB.
CONFIG_SPL_SYS_REPORT_STACK_F_USAGE config sets stack above the malloc and reports for stack overflow.

Assign 0x80D00000 for bloblist which is allocated a size of 1KB.

Memory map at A53 SPL before splash screen
0x80000000+---------------------+

          |    Empty 512 KB     |
          |                     |
0x80080000+---------------------+
          |     Text Base       |
          |       352 KB        |
          |                     |
0x800D8000+---------------------+
          |                     |
          |                     |
          |    Empty 3.6MB      |
          |                     |
          |                     |

0x80477660+---------------------+
| Stack 2 KB |
0x80477e60+---------------------+
| GD 416 Bytes |
0x80478000+---------------------+

          |    Malloc 352 KB    |
          |                     |
0x80480000+---------------------+
          |                     |
          |                     |
          |                     |
          |                     |
          |   Empty 5.5 MB      |
          |                     |
          |                     |
          |                     |
          |                     |
0x80a00000+---------------------+
          |                     |
          |      BSS 512 KB     |
          |                     |
0x80a80000+---------------------+
          |                     |
          |                     |
          |                     |
          |                     |
          |   Empty 5.5 MB      |
          |                     |
          |                     |
          |                     |
          |                     |

0x81000000+---------------------+FIT Image load address

New memory map with splash screen at SPL
0x80000000+---------------------+

          |    Empty 512 KB     |
          |                     |
0x80080000+---------------------+
          |     Text Base       |
          |       352 KB        |
          |                     |
0x800D8000+---------------------+
          |    Empty 1.1MB      |
          |                     |
0x80200000+---------------------+
          |                     |
          |                     |
          |                     |
          |   BMP Image Load    |
          |                     |
          |       9.4 MB        |
          |                     |
          |                     |
          |                     |
          |                     |
          |                     |
          |                     |

0x80B77660+---------------------+
| Stack 2KB |
0x80B77e60+---------------------+
| GD 416 Bytes |
0x80B78000+---------------------+

          |                     |
          |    Malloc 352KB     |
0x80B80000+---------------------+
          |                     |
          |     Empty 1 MB      |
          |                     |
0x80C80000+---------------------+
          |     BSS 512 KB      |
          |                     |
0x80D00000+---------------------+
          |     Blobs 1KB       |
0x80D00400+---------------------+
          |                     |
          |   Empty 2.999MB     |
          |                     |
          |                     |

0x81000000+---------------------+FIT Image load address

---
V3:
- Add bloblist address

V2:
- No change.

 configs/am62x_evm_a53_defconfig | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
configs/am62x_evm_a53_defconfig +8 -4
index cc9c8eab3e..5bd5ef882e 100644
@@ -8,14 +8,18 @@ CONFIG_SOC_K3_AM625=y
 CONFIG_K3_ATF_LOAD_ADDR=0x9e780000
 CONFIG_TARGET_AM625_A53_EVM=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80480000
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80b80000
+CONFIG_SF_DEFAULT_SPEED=25000000
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am625-sk"
 CONFIG_SPL_TEXT_BASE=0x80080000
+CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_STACK_R_ADDR=0x82000000
+CONFIG_SPL_SIZE_LIMIT=0x40000
+CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x800
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
@@ -27,8 +31,9 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern; setenv fdtfile ti/${name_fdt}; run distro_bootcmd"
 CONFIG_SPL_MAX_SIZE=0x58000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x80a00000
+CONFIG_SPL_BSS_START_ADDR=0x80c80000
 CONFIG_SPL_BSS_MAX_SIZE=0x80000
+CONFIG_SPL_SYS_REPORT_STACK_F_USAGE=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
@@ -68,7 +73,6 @@ CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_AM654=y
 CONFIG_DM_SPI_FLASH=y
-CONFIG_SF_DEFAULT_SPEED=25000000
 CONFIG_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPI_FLASH_SOFT_RESET=y
 CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
@@ -97,4 +101,4 @@ CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_TI_SCI=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
-CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_BLOBLIST_ADDR=0x80D00000
Signature · 1 line
2.34.1
#10 lore raw

PATCH v3 10/10 board: ti: am62x: am62x: Update splashimage as per new memory map

In reply to Nikhil M Jain

Update splashimage address, to load splash image at a lower address than stack.

---
V3:
- Keep splashsource as mmc.

V2:
- No change.

 board/ti/am62x/am62x.env | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/ti/am62x/am62x.env +1 -1
index e4e64fa637..8f7f9f8dbc 100644
@@ -33,6 +33,6 @@ get_fit_mmc=load mmc ${bootpart} ${addr_fit}
 partitions=name=rootfs,start=0,size=-,uuid=${uuid_gpt_rootfs}
 
 splashfile=ti.gz
-splashimage=0x82000000
+splashimage=0x80200000
 splashpos=m,m
 splashsource=mmc
Signature · 1 line
2.34.1
#11 lore raw
In reply to Nikhil M Jain
Quoted 11 lines · Nikhil M Jain

This patch series aims at eanbling SPL splash screen on AM62x.

Changes in V3:
- Update stackpointer after relocation.
- Return a pointer after page table setup.
- Enable dcache at SPL.
- Add method to reserve video using blob.
- Pass video buffer info from SPL to U-boot.
- Add config to remove video.
- Add bloblist address in memory map.

Quoted 12 lines

Nikhil M Jain (10):
common: spl: spl: Update stack pointer address
arch: arm: mach-k3: common: Return a pointer after setting page table
arch: arm: mach-k3: am625_init: Enable Dcache in SPL
board: ti: am62x: evm: Add necessary functions to call splash screen
include: video: Reserve video using blob
common: board_f: Pass frame buffer info from SPL to u-boot
drivers: video: Kconfig: Add config remove video
common: spl: spl: Remove video driver before u-boot proper
configs: am62x_evm_a53_defconfig: Changes in memory to support SPL
splash screen
board: ti: am62x: am62x: Update splashimage as per new memory map

As I applied v2 yesterday, please re-base this on top of master if these are important fixes, or next if they are cleanup that can wait. Thanks.

Signature · 1 line
Tom