From 49d8c11285b28bddf9cdc7830ce039d4fc734f35 Mon Sep 17 00:00:00 2001 From: "ot_chhao.chang" Date: Mon, 2 Dec 2024 17:30:58 +0800 Subject: [PATCH 1/4] feat(mt8196): enable cirq for MediaTek MT8196 - Add CIRQ related information. Signed-off-by: ot_chhao.chang Change-Id: I758e933f9d53f7bfb16e3d7feb1c7f53516b1da6 --- plat/mediatek/mt8196/include/platform_def.h | 9 +++++++++ plat/mediatek/mt8196/platform.mk | 1 + 2 files changed, 10 insertions(+) diff --git a/plat/mediatek/mt8196/include/platform_def.h b/plat/mediatek/mt8196/include/platform_def.h index 4752e5b96..72d83e64b 100644 --- a/plat/mediatek/mt8196/include/platform_def.h +++ b/plat/mediatek/mt8196/include/platform_def.h @@ -147,6 +147,15 @@ INTR_PROP_DESC(DEV_IRQ_ID, GIC_HIGHEST_SEC_PRIORITY, grp, \ GIC_INTR_CFG_LEVEL) +/******************************************************************************* + * CIRQ related constants + ******************************************************************************/ +#define SYS_CIRQ_BASE (IO_PHYS + 0x1CB000) +#define MD_WDT_IRQ_BIT_ID (397) +#define CIRQ_REG_NUM (26) +#define CIRQ_SPI_START (128) +#define CIRQ_IRQ_NUM (831) + /******************************************************************************* * MM IOMMU & SMI related constants ******************************************************************************/ diff --git a/plat/mediatek/mt8196/platform.mk b/plat/mediatek/mt8196/platform.mk index 09c671515..d321f8f9e 100644 --- a/plat/mediatek/mt8196/platform.mk +++ b/plat/mediatek/mt8196/platform.mk @@ -29,6 +29,7 @@ MODULES-y += $(MTK_PLAT)/common/lpm_v2 MODULES-y += $(MTK_PLAT)/lib/mtk_init MODULES-y += $(MTK_PLAT)/lib/pm MODULES-y += $(MTK_PLAT)/drivers/apusys +MODULES-y += $(MTK_PLAT)/drivers/cirq MODULES-y += $(MTK_PLAT)/drivers/dp MODULES-y += $(MTK_PLAT)/drivers/emi MODULES-y += $(MTK_PLAT)/drivers/gicv3 From 4794746eec6191563a97fec55c06027e42abe9bb Mon Sep 17 00:00:00 2001 From: Yong Wu Date: Tue, 31 Dec 2024 09:58:28 +0800 Subject: [PATCH 2/4] feat(mt8196): add Mediatek MMinfra stub implementation Implement stub functions for the MMinfra (Multimedia Infrastructure) driver to ensure that the build can pass when a prebuilt library is not available. Change-Id: Iadac654950c868d3743b13a1d6f7ab5d1015fb86 Signed-off-by: Yong Wu --- plat/mediatek/drivers/mminfra/mminfra_stub.c | 17 +++++++++++++++++ plat/mediatek/drivers/mminfra/rules.mk | 17 +++++++++++++++++ plat/mediatek/include/drivers/mminfra_public.h | 16 ++++++++++++++++ plat/mediatek/mt8196/platform.mk | 1 + 4 files changed, 51 insertions(+) create mode 100644 plat/mediatek/drivers/mminfra/mminfra_stub.c create mode 100644 plat/mediatek/drivers/mminfra/rules.mk create mode 100644 plat/mediatek/include/drivers/mminfra_public.h diff --git a/plat/mediatek/drivers/mminfra/mminfra_stub.c b/plat/mediatek/drivers/mminfra/mminfra_stub.c new file mode 100644 index 000000000..dc37280d6 --- /dev/null +++ b/plat/mediatek/drivers/mminfra/mminfra_stub.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025, MediaTek Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +int mminfra_get_if_in_use(void) +{ + return 0; +} + +int mminfra_put(void) +{ + return 0; +} diff --git a/plat/mediatek/drivers/mminfra/rules.mk b/plat/mediatek/drivers/mminfra/rules.mk new file mode 100644 index 000000000..f3a68221d --- /dev/null +++ b/plat/mediatek/drivers/mminfra/rules.mk @@ -0,0 +1,17 @@ +# +# Copyright (c) 2025, MediaTek Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +LOCAL_DIR := $(call GET_LOCAL_DIR) + +MODULE := mminfra + +PLAT_INCLUDES += -I${MTK_PLAT}/include/drivers/ + +ifeq ($(MTKLIB_PATH),) +LOCAL_SRCS-y := ${LOCAL_DIR}/mminfra_stub.c +endif + +$(eval $(call MAKE_MODULE,$(MODULE),$(LOCAL_SRCS-y),$(MTK_BL))) diff --git a/plat/mediatek/include/drivers/mminfra_public.h b/plat/mediatek/include/drivers/mminfra_public.h new file mode 100644 index 000000000..14ab361a1 --- /dev/null +++ b/plat/mediatek/include/drivers/mminfra_public.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025, MediaTek Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#ifndef MMINFRA_PUBLIC_H +#define MMINFRA_PUBLIC_H + +#define MMINFRA_RET_ERR (-1) +#define MMINFRA_RET_POWER_OFF 0 +#define MMINFRA_RET_POWER_ON 1 + +int mminfra_get_if_in_use(void); +int mminfra_put(void); + +#endif diff --git a/plat/mediatek/mt8196/platform.mk b/plat/mediatek/mt8196/platform.mk index d321f8f9e..3e1165e3e 100644 --- a/plat/mediatek/mt8196/platform.mk +++ b/plat/mediatek/mt8196/platform.mk @@ -34,6 +34,7 @@ MODULES-y += $(MTK_PLAT)/drivers/dp MODULES-y += $(MTK_PLAT)/drivers/emi MODULES-y += $(MTK_PLAT)/drivers/gicv3 MODULES-y += $(MTK_PLAT)/drivers/mcusys +MODULES-y += $(MTK_PLAT)/drivers/mminfra MODULES-y += $(MTK_PLAT)/drivers/spm MODULES-y += $(MTK_PLAT)/drivers/timer MODULES-y += $(MTK_PLAT)/drivers/vcp From 823a57e11cd98ee6043e9637ff3a4cf58feb60ff Mon Sep 17 00:00:00 2001 From: Karl Li Date: Tue, 3 Dec 2024 17:09:21 +0800 Subject: [PATCH 3/4] feat(mt8196): enable APU spmi operation Enable APU spmi operation after spmi module ready Change-Id: I4bb1a50a635e8798b049295dbbf98967daff5997 Signed-off-by: Karl Li --- plat/mediatek/drivers/apusys/mt8196/apusys_power.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/plat/mediatek/drivers/apusys/mt8196/apusys_power.c b/plat/mediatek/drivers/apusys/mt8196/apusys_power.c index 4262d6324..dcf642309 100644 --- a/plat/mediatek/drivers/apusys/mt8196/apusys_power.c +++ b/plat/mediatek/drivers/apusys/mt8196/apusys_power.c @@ -1,16 +1,12 @@ /* - * Copyright (c) 2024, MediaTek Inc. All rights reserved. + * Copyright (c) 2024-2025, MediaTek Inc. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include -#define SPMI_ENABLE (0) - -#if SPMI_ENABLE #include -#endif #include #include @@ -259,16 +255,13 @@ static int apu_pcu_init(void) uint32_t en_set_offset = BUCK_VAPU_PMIC_REG_EN_SET_ADDR; uint32_t en_clr_offset = BUCK_VAPU_PMIC_REG_EN_CLR_ADDR; uint32_t en_shift = BUCK_VAPU_PMIC_REG_EN_SHIFT; -#if SPMI_ENABLE struct spmi_device *vsram_sdev; -#endif unsigned char vsram = 0; mmio_write_32(APUSYS_PCU + APU_PCUTOP_CTRL_SET, AUTO_BUCK_EN); mmio_write_32((APUSYS_PCU + APU_PCU_BUCK_STEP_SEL), BUCK_STEP_SEL_VAL); -#if SPMI_ENABLE vsram_sdev = get_spmi_device(SPMI_MASTER_1, SPMI_SLAVE_4); if (!vsram_sdev) { ERROR("[APUPW] VSRAM BUCK4 get device fail\n"); @@ -279,7 +272,6 @@ static int apu_pcu_init(void) ERROR("[APUPW] VSRAM BUCK4 read fail\n"); return -1; } -#endif mmio_write_32(APUSYS_PCU + APU_PCU_BUCK_ON_DAT0_L, (BUCK_VAPU_PMIC_REG_VOSEL_ADDR << PMIC_OFF_ADDR_OFF) | vsram); From 5de1ace54a7088828dfaccd275ec2f1938ce7ee4 Mon Sep 17 00:00:00 2001 From: Karl Li Date: Fri, 15 Nov 2024 11:43:19 +0800 Subject: [PATCH 4/4] feat(mt8196): turn on APU smpu protection 1. Turn on APU SMPU protection on MT8196. 2. Remove unused header file. Change-Id: I58637b8dda4bf68253bc2329580963a8bd9cca8b Signed-off-by: Karl Li --- .../drivers/apusys/mt8196/apusys_security_ctrl_plat.c | 5 ++--- plat/mediatek/drivers/apusys/mt8196/rules.mk | 3 +-- plat/mediatek/mt8196/plat_config.mk | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/plat/mediatek/drivers/apusys/mt8196/apusys_security_ctrl_plat.c b/plat/mediatek/drivers/apusys/mt8196/apusys_security_ctrl_plat.c index fbd2aa0ae..a0d21c6a7 100644 --- a/plat/mediatek/drivers/apusys/mt8196/apusys_security_ctrl_plat.c +++ b/plat/mediatek/drivers/apusys/mt8196/apusys_security_ctrl_plat.c @@ -1,14 +1,13 @@ /* - * Copyright (c) 2024, MediaTek Inc. All rights reserved. + * Copyright (c) 2024-2025, MediaTek Inc. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ -#define ENABLE_SMPU_PROTECT (0) +#define ENABLE_SMPU_PROTECT (1) #if ENABLE_SMPU_PROTECT #include "emi.h" -#include "mt_emi.h" #endif #include diff --git a/plat/mediatek/drivers/apusys/mt8196/rules.mk b/plat/mediatek/drivers/apusys/mt8196/rules.mk index 4ffaf7339..aeb6d3d6d 100644 --- a/plat/mediatek/drivers/apusys/mt8196/rules.mk +++ b/plat/mediatek/drivers/apusys/mt8196/rules.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2024, MediaTek Inc. All rights reserved. +# Copyright (c) 2024-2025, MediaTek Inc. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -10,7 +10,6 @@ MODULE := apusys_${MTK_SOC} ifeq (${CONFIG_MTK_APUSYS_EMI_SUPPORT}, y) PLAT_INCLUDES += -I${MTK_PLAT}/drivers/emi/common -PLAT_INCLUDES += -I${MTK_PLAT}/drivers/emi/${MTK_SOC} endif LOCAL_SRCS-y := ${LOCAL_DIR}/apusys_ammu.c diff --git a/plat/mediatek/mt8196/plat_config.mk b/plat/mediatek/mt8196/plat_config.mk index 773407acf..0c87db989 100644 --- a/plat/mediatek/mt8196/plat_config.mk +++ b/plat/mediatek/mt8196/plat_config.mk @@ -27,7 +27,7 @@ CTX_INCLUDE_AARCH32_REGS := 0 CONFIG_ARCH_ARM_V9 := y CONFIG_MTK_APUSYS_CE_SUPPORT := y -CONFIG_MTK_APUSYS_EMI_SUPPORT := n +CONFIG_MTK_APUSYS_EMI_SUPPORT := y CONFIG_MTK_APUSYS_LOGTOP_SUPPORT := y CONFIG_MTK_APUSYS_RV_APUMMU_SUPPORT := y CONFIG_MTK_APUSYS_RV_COREDUMP_WA_SUPPORT := y