From c52a10a28e92b4481793e98f57cc060d4231fcc3 Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Thu, 8 Apr 2021 19:07:49 +0800 Subject: [PATCH] mediatek: mt8195: add rtc power off sequence mt8195 also uses mt6359p RTC. Revice mt8192 RTC and share the driver with mt8195. Change-Id: I20c73f6e0af67ef9d4c3d4e0ff373f93950e07db Signed-off-by: Yidi Lin --- .../rtc/rtc.c => common/drivers/rtc/rtc_mt6359p.c} | 0 .../rtc/rtc.h => common/drivers/rtc/rtc_mt6359p.h} | 6 +++--- plat/mediatek/mt8192/include/rtc.h | 12 ++++++++++++ plat/mediatek/mt8192/platform.mk | 4 ++-- plat/mediatek/mt8195/include/rtc.h | 12 ++++++++++++ plat/mediatek/mt8195/plat_pm.c | 2 ++ plat/mediatek/mt8195/platform.mk | 3 +++ 7 files changed, 34 insertions(+), 5 deletions(-) rename plat/mediatek/{mt8192/drivers/rtc/rtc.c => common/drivers/rtc/rtc_mt6359p.c} (100%) rename plat/mediatek/{mt8192/drivers/rtc/rtc.h => common/drivers/rtc/rtc_mt6359p.h} (98%) create mode 100644 plat/mediatek/mt8192/include/rtc.h create mode 100644 plat/mediatek/mt8195/include/rtc.h diff --git a/plat/mediatek/mt8192/drivers/rtc/rtc.c b/plat/mediatek/common/drivers/rtc/rtc_mt6359p.c similarity index 100% rename from plat/mediatek/mt8192/drivers/rtc/rtc.c rename to plat/mediatek/common/drivers/rtc/rtc_mt6359p.c diff --git a/plat/mediatek/mt8192/drivers/rtc/rtc.h b/plat/mediatek/common/drivers/rtc/rtc_mt6359p.h similarity index 98% rename from plat/mediatek/mt8192/drivers/rtc/rtc.h rename to plat/mediatek/common/drivers/rtc/rtc_mt6359p.h index 419bfe42c..04726e390 100644 --- a/plat/mediatek/mt8192/drivers/rtc/rtc.h +++ b/plat/mediatek/common/drivers/rtc/rtc_mt6359p.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef RTC_H -#define RTC_H +#ifndef RTC_MT6359P_H +#define RTC_MT6359P_H /* RTC registers */ enum { @@ -194,4 +194,4 @@ int32_t RTC_Write_Trigger(void); int32_t Writeif_unlock(void); void rtc_power_off_sequence(void); -#endif /* RTC_H */ +#endif /* RTC_MT6359P_H */ diff --git a/plat/mediatek/mt8192/include/rtc.h b/plat/mediatek/mt8192/include/rtc.h new file mode 100644 index 000000000..a9c7bc83f --- /dev/null +++ b/plat/mediatek/mt8192/include/rtc.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2021, MediaTek Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef RTC_H +#define RTC_H + +#include + +#endif /* RTC_H */ diff --git a/plat/mediatek/mt8192/platform.mk b/plat/mediatek/mt8192/platform.mk index 49d1059bd..86e353f22 100644 --- a/plat/mediatek/mt8192/platform.mk +++ b/plat/mediatek/mt8192/platform.mk @@ -10,6 +10,7 @@ MTK_PLAT_SOC := ${MTK_PLAT}/${PLAT} PLAT_INCLUDES := -I${MTK_PLAT}/common/ \ -I${MTK_PLAT}/common/drivers/gic600/ \ -I${MTK_PLAT}/common/drivers/gpio/ \ + -I${MTK_PLAT}/common/drivers/rtc/ \ -I${MTK_PLAT}/common/drivers/timer/ \ -I${MTK_PLAT}/common/drivers/uart/ \ -I${MTK_PLAT}/common/lpm/ \ @@ -21,7 +22,6 @@ PLAT_INCLUDES := -I${MTK_PLAT}/common/ \ -I${MTK_PLAT_SOC}/drivers/mcdi/ \ -I${MTK_PLAT_SOC}/drivers/pmic/ \ -I${MTK_PLAT_SOC}/drivers/ptp3/ \ - -I${MTK_PLAT_SOC}/drivers/rtc/ \ -I${MTK_PLAT_SOC}/drivers/spmc/ GICV3_SUPPORT_GIC600 := 1 @@ -46,6 +46,7 @@ BL31_SOURCES += common/desc_image_load.c \ ${MTK_PLAT}/common/drivers/gpio/mtgpio_common.c \ ${MTK_PLAT}/common/drivers/pmic_wrap/pmic_wrap_init_v2.c \ ${MTK_PLAT}/common/drivers/rtc/rtc_common.c \ + ${MTK_PLAT}/common/drivers/rtc/rtc_mt6359p.c \ ${MTK_PLAT}/common/drivers/timer/mt_timer.c \ ${MTK_PLAT}/common/drivers/uart/uart.c \ ${MTK_PLAT}/common/lpm/mt_lp_rm.c \ @@ -57,7 +58,6 @@ BL31_SOURCES += common/desc_image_load.c \ ${MTK_PLAT_SOC}/aarch64/plat_helpers.S \ ${MTK_PLAT_SOC}/bl31_plat_setup.c \ ${MTK_PLAT_SOC}/drivers/pmic/pmic.c \ - ${MTK_PLAT_SOC}/drivers/rtc/rtc.c \ ${MTK_PLAT_SOC}/plat_pm.c \ ${MTK_PLAT_SOC}/plat_topology.c \ ${MTK_PLAT_SOC}/plat_sip_calls.c \ diff --git a/plat/mediatek/mt8195/include/rtc.h b/plat/mediatek/mt8195/include/rtc.h new file mode 100644 index 000000000..a9c7bc83f --- /dev/null +++ b/plat/mediatek/mt8195/include/rtc.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2021, MediaTek Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef RTC_H +#define RTC_H + +#include + +#endif /* RTC_H */ diff --git a/plat/mediatek/mt8195/plat_pm.c b/plat/mediatek/mt8195/plat_pm.c index 7cc25655b..522d4437a 100644 --- a/plat/mediatek/mt8195/plat_pm.c +++ b/plat/mediatek/mt8195/plat_pm.c @@ -20,6 +20,7 @@ #include #include #include +#include /* * Cluster state request: @@ -355,6 +356,7 @@ static void __dead2 plat_mtk_system_off(void) { INFO("MTK System Off\n"); + rtc_power_off_sequence(); pmic_power_off(); wfi(); diff --git a/plat/mediatek/mt8195/platform.mk b/plat/mediatek/mt8195/platform.mk index e37e4404d..4d3ad59e1 100644 --- a/plat/mediatek/mt8195/platform.mk +++ b/plat/mediatek/mt8195/platform.mk @@ -10,6 +10,7 @@ MTK_PLAT_SOC := ${MTK_PLAT}/${PLAT} PLAT_INCLUDES := -I${MTK_PLAT}/common/ \ -I${MTK_PLAT}/common/drivers/gic600/ \ -I${MTK_PLAT}/common/drivers/gpio/ \ + -I${MTK_PLAT}/common/drivers/rtc/ \ -I${MTK_PLAT}/common/drivers/timer/ \ -I${MTK_PLAT_SOC}/drivers/gpio/ \ -I${MTK_PLAT_SOC}/drivers/mcdi/ \ @@ -39,6 +40,8 @@ BL31_SOURCES += common/desc_image_load.c \ ${MTK_PLAT}/common/drivers/gic600/mt_gic_v3.c \ ${MTK_PLAT}/common/drivers/gpio/mtgpio_common.c \ ${MTK_PLAT}/common/drivers/pmic_wrap/pmic_wrap_init_v2.c \ + ${MTK_PLAT}/common/drivers/rtc/rtc_common.c \ + ${MTK_PLAT}/common/drivers/rtc/rtc_mt6359p.c \ ${MTK_PLAT}/common/drivers/timer/mt_timer.c \ ${MTK_PLAT}/common/mtk_cirq.c \ ${MTK_PLAT}/common/mtk_plat_common.c \ -- GitLab