From 0ff213d711f7bfb2b329a2fd7c291931e5c26f67 Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Thu, 9 Oct 2025 00:38:12 +0800 Subject: [PATCH] soc/mediatek/common: Conditionally set up framebuffer To save memory, only allocate and configure the framebuffer when display output is required during boot. This is achieved by: 1. Making the `framebuffer` memory region optional. 2. Guarding the framebuffer's uncached MMU configuration with a `display_init_required()` check. This ensures the framebuffer is prepared only when needed, saving memory on boot paths that do not require display. BUG=b:319511268 BRANCH=none TEST=emerge-rauru coreboot Change-Id: I3808031160e421de7c21f585f4b79d42bfddccc4 Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/89541 Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) --- src/include/symbols.h | 2 +- src/soc/mediatek/common/display.c | 7 ++++++- src/soc/mediatek/common/mmu_operations.c | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/include/symbols.h b/src/include/symbols.h index 48ff832afd..ad8231c089 100644 --- a/src/include/symbols.h +++ b/src/include/symbols.h @@ -75,7 +75,7 @@ DECLARE_REGION(ttb) DECLARE_OPTIONAL_REGION(ttb_subtables) DECLARE_REGION(dma_coherent) DECLARE_REGION(soc_registers) -DECLARE_REGION(framebuffer) +DECLARE_OPTIONAL_REGION(framebuffer) DECLARE_REGION(pdpt) DECLARE_OPTIONAL_REGION(opensbi) DECLARE_OPTIONAL_REGION(bl31) diff --git a/src/soc/mediatek/common/display.c b/src/soc/mediatek/common/display.c index 84981f059e..163b900769 100644 --- a/src/soc/mediatek/common/display.c +++ b/src/soc/mediatek/common/display.c @@ -11,6 +11,7 @@ #include #include #include +#include static struct panel_serializable_data *get_mipi_cmd_from_cbfs(struct panel_description *desc) { @@ -70,6 +71,7 @@ int mtk_display_init(void) struct fb_info *info; const char *name; struct panel_description *panel = get_active_panel(); + uintptr_t fb_addr; if (!panel || panel->disp_path == DISP_PATH_NONE) { printk(BIOS_ERR, "%s: Failed to get the active panel\n", __func__); @@ -143,7 +145,10 @@ int mtk_display_init(void) } } - info = fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)0); + fb_addr = (REGION_SIZE(framebuffer)) ? (uintptr_t)_framebuffer : 0; + + info = fb_new_framebuffer_info_from_edid(&edid, fb_addr); + if (info) fb_set_orientation(info, panel->orientation); diff --git a/src/soc/mediatek/common/mmu_operations.c b/src/soc/mediatek/common/mmu_operations.c index 1bbe4dc319..68ac77d515 100644 --- a/src/soc/mediatek/common/mmu_operations.c +++ b/src/soc/mediatek/common/mmu_operations.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -51,6 +52,10 @@ void mtk_mmu_after_dram(void) mmu_config_range(_dram_dma, REGION_SIZE(dram_dma), NONSECURE_UNCACHED_MEM); + if (display_init_required()) + mmu_config_range(_framebuffer, REGION_SIZE(framebuffer), + NONSECURE_UNCACHED_MEM); + mtk_soc_after_dram(); }