diff --git a/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_cpu_pm.c b/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_cpu_pm.c index f105b882b..606a7b7b7 100644 --- a/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_cpu_pm.c +++ b/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_cpu_pm.c @@ -14,7 +14,7 @@ #include #include -#include +#include #include "mt_cpu_pm.h" #include "mt_cpu_pm_cpc.h" #include "mt_cpu_pm_mbox.h" @@ -773,11 +773,13 @@ static int cpupm_pwr_state_valid(unsigned int afflv, unsigned int state) static int cpupm_invoke(unsigned int func_id, void *priv) { int ret = MTK_CPUPM_E_OK; +#ifdef CPU_PM_SUSPEND_NOTIFY int i, reverse = 0; struct cpupm_invoke_data *save_status = (struct cpupm_invoke_data *) priv; + unsigned int cpu_status; +#endif struct cpupm_pwr_req *req = (struct cpupm_pwr_req *)priv; unsigned int pwr_req = req->req; - unsigned int cpu_status; switch (func_id) { #ifdef CPU_PM_SUSPEND_NOTIFY diff --git a/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_cpu_pm_smc.h b/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_cpu_pm_smc.h index 8b643b066..5cd2f5c6d 100644 --- a/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_cpu_pm_smc.h +++ b/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_cpu_pm_smc.h @@ -7,9 +7,9 @@ #ifndef MT_CPU_PM_SMC_H #define MT_CPU_PM_SMC_H -#include -#include -#include +#include +#include +#include void cpupm_smc_init(void); diff --git a/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_lp_irqremain.c b/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_lp_irqremain.c index ded1a60fe..563e6b565 100644 --- a/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_lp_irqremain.c +++ b/plat/mediatek/drivers/cpu_pm/cpcv5_4/mt_lp_irqremain.c @@ -12,7 +12,7 @@ #include #include -#include +#include #include "mt_cpu_pm.h" #include "mt_lp_irqremain.h" diff --git a/plat/mediatek/drivers/cpu_pm/cpcv5_4/rules.mk b/plat/mediatek/drivers/cpu_pm/cpcv5_4/rules.mk index 9819d0e56..c6937e107 100644 --- a/plat/mediatek/drivers/cpu_pm/cpcv5_4/rules.mk +++ b/plat/mediatek/drivers/cpu_pm/cpcv5_4/rules.mk @@ -29,8 +29,6 @@ $(eval $(call add_defined_option,CPU_PM_DOMAIN_CORE_ONLY)) $(eval $(call add_defined_option,CPU_PM_CORE_ARCH64_ONLY)) $(eval $(call add_defined_option,CPU_PM_TINYSYS_SUPPORT)) -$(eval $(call add_defined_option,CPU_PM_SUSPEND_NOTIFY)) - $(eval $(call add_defined_option,CPU_PM_PWR_REQ)) $(eval $(call add_defined_option,CPU_PM_PWR_REQ_DEBUG)) diff --git a/plat/mediatek/lib/pm/armv9_0/pwr_ctrl.c b/plat/mediatek/lib/pm/armv9_0/pwr_ctrl.c index 73b1f6855..ace27003e 100644 --- a/plat/mediatek/lib/pm/armv9_0/pwr_ctrl.c +++ b/plat/mediatek/lib/pm/armv9_0/pwr_ctrl.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -108,6 +109,9 @@ static inline unsigned int get_pwr_afflv(const psci_power_state_t *state) static void mcusys_pwr_on_common(const struct mtk_cpupm_pwrstate *state) { + mt_gic_distif_restore(); + mt_gic_rdistif_restore(); + if (IS_CPUIDLE_FN_ENABLE(MTK_CPUPM_FN_RESUME_MCUSYS)) imtk_cpu_pwr.ops->mcusys_resume(state); } @@ -121,6 +125,9 @@ static void mcusys_pwr_dwn_common(const struct mtk_cpupm_pwrstate *state) if (IS_CPUIDLE_FN_ENABLE(MTK_CPUPM_FN_SUSPEND_MCUSYS)) imtk_cpu_pwr.ops->mcusys_suspend(state); + mt_gic_rdistif_save(); + /* save gic context after cirq enable */ + mt_gic_distif_save(); } static void cluster_pwr_on_common(const struct mtk_cpupm_pwrstate *state) @@ -140,8 +147,7 @@ static void cpu_pwr_on_common(const struct mtk_cpupm_pwrstate *state, { coordinate_cluster_pwron(); - gicv3_rdistif_init(plat_my_core_pos()); - gicv3_cpuif_enable(plat_my_core_pos()); + mt_gic_cpuif_enable(); } static void cpu_pwr_dwn_common(const struct mtk_cpupm_pwrstate *state, @@ -149,6 +155,8 @@ static void cpu_pwr_dwn_common(const struct mtk_cpupm_pwrstate *state, { if (pstate & MT_CPUPM_PWR_DOMAIN_PERCORE_DSU) coordinate_cluster_pwroff(); + + mt_gic_cpuif_disable(); } static void cpu_pwr_resume(const struct mtk_cpupm_pwrstate *state, @@ -217,6 +225,8 @@ static void power_domain_on_finish(const psci_power_state_t *state) }, }; + mt_gic_pcpu_init(); + cpu_pwr_on(&pm_state, pstate); nb.cpuid = pm_state.info.cpuid; @@ -243,7 +253,7 @@ static void power_domain_off(const psci_power_state_t *state) cpu_pwr_off(&pm_state, pstate); - gicv3_rdistif_off(plat_my_core_pos()); + mt_gic_redistif_off(); nb.cpuid = pm_state.info.cpuid; nb.pwr_domain = pstate; @@ -278,8 +288,6 @@ static void power_domain_suspend(const psci_power_state_t *state) if (pstate & MT_CPUPM_PWR_DOMAIN_MCUSYS) mcusys_pwr_dwn_common(&pm_state); - gicv3_rdistif_off(plat_my_core_pos()); - nb.cpuid = pm_state.info.cpuid; nb.pwr_domain = pstate; MT_CPUPM_EVENT_PWR_OFF(&nb); diff --git a/plat/mediatek/lib/system_reset/reset_cros.c b/plat/mediatek/lib/system_reset/reset_cros.c index 40e68ba9f..5f976501a 100644 --- a/plat/mediatek/lib/system_reset/reset_cros.c +++ b/plat/mediatek/lib/system_reset/reset_cros.c @@ -1,18 +1,25 @@ /* - * Copyright (c) 2022, MediaTek Inc. All rights reserved. + * Copyright (c) 2022-2025, MediaTek Inc. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include + #include #include +#include #include +#if CONFIG_MTK_PMIC_SHUTDOWN_CFG +#include +#endif #include #include #include +#if !CONFIG_MTK_PMIC_SHUTDOWN_CFG #include #include +#endif static void __dead2 mtk_system_reset_cros(void) { @@ -31,8 +38,13 @@ static void __dead2 mtk_system_off_cros(void) { INFO("MTK System Off\n"); +#if CONFIG_MTK_PMIC_SHUTDOWN_CFG + platform_power_hold(false); + mdelay(1000); +#else rtc_power_off_sequence(); pmic_power_off(); +#endif wfi(); ERROR("MTK System Off: operation not handled.\n"); diff --git a/plat/mediatek/mt8196/include/platform_def.h b/plat/mediatek/mt8196/include/platform_def.h index 72d83e64b..83370d6c5 100644 --- a/plat/mediatek/mt8196/include/platform_def.h +++ b/plat/mediatek/mt8196/include/platform_def.h @@ -87,7 +87,7 @@ * GPIO related constants ******************************************************************************/ #define GPIO_BASE (IO_PHYS + 0x0002D000) -#define RGU_BASE (IO_PHYS + 0x0C00B000) +#define RGU_BASE (IO_PHYS + 0x0C010000) #define DRM_BASE (IO_PHYS + 0x0000D000) #define IOCFG_RT_BASE (IO_PHYS + 0x02000000) #define IOCFG_RM1_BASE (IO_PHYS + 0x02020000) diff --git a/plat/mediatek/mt8196/platform.mk b/plat/mediatek/mt8196/platform.mk index 50508093a..520771dfa 100644 --- a/plat/mediatek/mt8196/platform.mk +++ b/plat/mediatek/mt8196/platform.mk @@ -41,6 +41,7 @@ MODULES-y += $(MTK_PLAT)/common MODULES-y += $(MTK_PLAT)/common/lpm_v2 MODULES-y += $(MTK_PLAT)/lib/mtk_init MODULES-y += $(MTK_PLAT)/lib/pm +MODULES-y += $(MTK_PLAT)/lib/system_reset MODULES-y += $(MTK_PLAT)/drivers/apusys MODULES-y += $(MTK_PLAT)/drivers/cirq MODULES-y += $(MTK_PLAT)/drivers/dp