From 29f0ba2ca92547d483b6f968e688aaef18121255 Mon Sep 17 00:00:00 2001 From: Jarried Lin Date: Tue, 23 Jan 2024 18:26:22 +0800 Subject: soc/mediatek/mt8196: Initialize watchdog Add watchdog support for MT8196. TEST=build pass and WDT uart log BUG=b:317009620 Change-Id: I9d5e71aa27d469855c2bd65abc5309d69a018750 Signed-off-by: Jarried Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/83926 Tested-by: build bot (Jenkins) Reviewed-by: Yidi Lin Reviewed-by: Yu-Ping Wu --- src/soc/mediatek/mt8196/Makefile.mk | 1 + src/soc/mediatek/mt8196/bootblock.c | 2 ++ src/soc/mediatek/mt8196/include/soc/wdt.h | 14 ++++++++++++++ src/soc/mediatek/mt8196/wdt.c | 17 +++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 src/soc/mediatek/mt8196/include/soc/wdt.h create mode 100644 src/soc/mediatek/mt8196/wdt.c diff --git a/src/soc/mediatek/mt8196/Makefile.mk b/src/soc/mediatek/mt8196/Makefile.mk index 44fa59e927..75f21fca25 100644 --- a/src/soc/mediatek/mt8196/Makefile.mk +++ b/src/soc/mediatek/mt8196/Makefile.mk @@ -10,6 +10,7 @@ all-y += ../common/uart.c bootblock-y += bootblock.c bootblock-y += ../common/mmu_operations.c +bootblock-y += ../common/wdt.c ../common/wdt_req.c wdt.c romstage-y += ../common/cbmem.c romstage-y += emi.c diff --git a/src/soc/mediatek/mt8196/bootblock.c b/src/soc/mediatek/mt8196/bootblock.c index f48e78c309..770c6031da 100644 --- a/src/soc/mediatek/mt8196/bootblock.c +++ b/src/soc/mediatek/mt8196/bootblock.c @@ -2,8 +2,10 @@ #include #include +#include void bootblock_soc_init(void) { mtk_mmu_init(); + mtk_wdt_init(); } diff --git a/src/soc/mediatek/mt8196/include/soc/wdt.h b/src/soc/mediatek/mt8196/include/soc/wdt.h new file mode 100644 index 0000000000..a8299fb2e6 --- /dev/null +++ b/src/soc/mediatek/mt8196/include/soc/wdt.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ + +#ifndef SOC_MEDIATEK_MT8196_WDT_H +#define SOC_MEDIATEK_MT8196_WDT_H + +#include + +#define MTK_WDT_SPM_THERMAL_VAL 1 + +DEFINE_BIT(MTK_WDT_SPM_THERMAL_EN, 0) +DEFINE_BIT(MTK_WDT_THERMAL_EN, 18) +DEFINE_BIT(MTK_WDT_THERMAL_IRQ, 18) + +#endif /* SOC_MEDIATEK_MT8196_WDT_H */ diff --git a/src/soc/mediatek/mt8196/wdt.c b/src/soc/mediatek/mt8196/wdt.c new file mode 100644 index 0000000000..8b8db3bbac --- /dev/null +++ b/src/soc/mediatek/mt8196/wdt.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ + +/* + * This file is created based on MT8196 Functional Specification + * Chapter number: 7.3.4.4 + */ + +#include +#include +#include + +#define MTK_WDT_CLR_STATUS 0x230001FF + +void mtk_wdt_clr_status(void) +{ + write32(&mtk_wdt->wdt_mode, MTK_WDT_CLR_STATUS); +} -- cgit v1.2.3