From 78a89d4d70c8b5f41f3cb8f284ed3268aa2a37e9 Mon Sep 17 00:00:00 2001 From: Vince Liu Date: Fri, 6 Jun 2025 16:42:46 +0800 Subject: [PATCH] soc/mediatek/mt8189: Extract code to disable secure mode from DDP driver Extract code for disabling secure mode from mtk_ddp_init and implement it as mtk_display_disable_secure_mode(). This allows disabling display secure mode without using DDP, for example, when FW display is not needed. Unlike previous SoCs, MT8189 is designed so that access to display registers defaults to secure mode, due to specific product requirements. However, Chromebook products do not use this setting and instead require the register permissions to be set for normal mode access, consistent with previous SoC behavior. Also reordered function declarations to group similar types (e.g., display, DDP) together for better readability. BUG=b:422507985 BRANCH=none TEST=utility gbb --set --flash --flags=0x0, and check the DUT screen. Signed-off-by: Xiandong Wang Signed-off-by: Vince Liu Change-Id: Ic378ef62540c408ccd59e482abfe9f9c8ca5a13d Reviewed-on: https://review.coreboot.org/c/coreboot/+/88272 Tested-by: build bot (Jenkins) Reviewed-by: Yidi Lin --- src/soc/mediatek/common/include/soc/display.h | 3 +- src/soc/mediatek/mt8189/ddp.c | 36 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/soc/mediatek/common/include/soc/display.h b/src/soc/mediatek/common/include/soc/display.h index 2881505860..0d06a3cd2c 100644 --- a/src/soc/mediatek/common/include/soc/display.h +++ b/src/soc/mediatek/common/include/soc/display.h @@ -26,8 +26,9 @@ struct panel_description { uint32_t quirks; }; -int mtk_display_init(void); struct panel_description *get_active_panel(void); +void mtk_display_disable_secure_mode(void); +int mtk_display_init(void); void mtk_ddp_init(void); void mtk_ddp_mode_set(const struct edid *edid, enum disp_path_sel path); diff --git a/src/soc/mediatek/mt8189/ddp.c b/src/soc/mediatek/mt8189/ddp.c index 32c3b5b12f..f7bdc7f835 100644 --- a/src/soc/mediatek/mt8189/ddp.c +++ b/src/soc/mediatek/mt8189/ddp.c @@ -86,26 +86,18 @@ static void disp_clock_on(void) __func__, read32(&mmsys_cfg->mmsys_cg_con0), read32(&mmsys_cfg->mmsys_cg_con1)); } -void mtk_ddp_init(void) +void mtk_display_disable_secure_mode(void) { - int i; - disp_clock_on(); - printk(BIOS_DEBUG, "%s: shadow: %#x %#x, secure before: [%#x %#x %#x] larb: %x\n", + printk(BIOS_DEBUG, "%s: shadow: %#x %#x, secure before: [%#x %#x %#x]\n", __func__, read32(&mmsys_cfg->disp_bypass_mux_shadow), read32(&mmsys_cfg->disp_crossbar_con), read32(&mmsys_cfg->mmsys_security_disable), read32(&mmsys_cfg->mmsys_security_disable1), - read32(&mmsys_cfg->mmsys_security_disable2), - read32(&smi_larb0->port_l0_ovl_rdma[0])); + read32(&mmsys_cfg->mmsys_security_disable2)); - /* Turn off M4U port */ - for (i = 0; i < RDMA_PORT_NR; i++) { - write32(&smi_larb0->port_l0_ovl_rdma[i], 0); - write32(&smi_larb1->port_l0_ovl_rdma[i], 0); - } /* disable shadow */ write32(&mmsys_cfg->disp_bypass_mux_shadow, 0x1); write32(&mmsys_cfg->disp_crossbar_con, 0x00FF0000); @@ -113,14 +105,30 @@ void mtk_ddp_init(void) write32(&mmsys_cfg->mmsys_security_disable, 0xFFFFFFFF); write32(&mmsys_cfg->mmsys_security_disable1, 0xFFFFFFFF); write32(&mmsys_cfg->mmsys_security_disable2, 0xFFFFFFFF); - printk(BIOS_DEBUG, "%s: shadow: %#x %#x, secure: [%#x %#x %#x] larb: %#x\n", + + printk(BIOS_DEBUG, "%s: shadow: %#x %#x, secure: [%#x %#x %#x]n", __func__, read32(&mmsys_cfg->disp_bypass_mux_shadow), read32(&mmsys_cfg->disp_crossbar_con), read32(&mmsys_cfg->mmsys_security_disable), read32(&mmsys_cfg->mmsys_security_disable1), - read32(&mmsys_cfg->mmsys_security_disable2), - read32(&smi_larb0->port_l0_ovl_rdma[0])); + read32(&mmsys_cfg->mmsys_security_disable2)); +} + +void mtk_ddp_init(void) +{ + int i; + + mtk_display_disable_secure_mode(); + + /* Turn off M4U port */ + for (i = 0; i < RDMA_PORT_NR; i++) { + write32(&smi_larb0->port_l0_ovl_rdma[i], 0); + write32(&smi_larb1->port_l0_ovl_rdma[i], 0); + } + + printk(BIOS_DEBUG, "%s: larb: %#x\n", + __func__, read32(&smi_larb0->port_l0_ovl_rdma[0])); } void mtk_ddp_mode_set(const struct edid *edid, enum disp_path_sel path)