From 0099832cdab2337da5d3efc92fdd9b7a4f645cc1 Mon Sep 17 00:00:00 2001 From: Werner Zeh Date: Tue, 18 Jan 2022 12:31:08 +0100 Subject: [PATCH] soc/intel/ehl: Add Kconfig option to disable reset on TCO expiration The TCO timer is the default watchdog of an x86 host and can reset the system once it has expired for the second time. There are applications where this reset is not acceptable while the TCO is used. In these applications the TCO expire event generates an interrupt and software takes care. There is a bit in the TCO1_CNT register on Elkhart Lake to prevent this reset on expiration (called NO_REBOOT, see doc #636722 ). This bit can either be strapped on hardware or set in this register to avoid the reset on expiration. While the hardware strap cannot be overridden in software, the pure software solution is more flexible. Unfortunately, the location for this bit differs among the different platforms. This is why it has to be handled on soc level rather than on TCO common code level. This commit adds a Kconfig option where NO_REBOOT can be enabled. This makes it easy to reach this feature over to the mainboard where it can be selected if needed. Change-Id: Iaa81bfbe688edd717aa02db86f0a93fecdfcd16b Signed-off-by: Werner Zeh Reviewed-on: https://review.coreboot.org/c/coreboot/+/61177 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber --- src/soc/intel/elkhartlake/Kconfig | 10 ++++++++++ src/soc/intel/elkhartlake/bootblock/bootblock.c | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/soc/intel/elkhartlake/Kconfig b/src/soc/intel/elkhartlake/Kconfig index 37807897aa..b8296021fc 100644 --- a/src/soc/intel/elkhartlake/Kconfig +++ b/src/soc/intel/elkhartlake/Kconfig @@ -251,4 +251,14 @@ config SOC_INTEL_ELKHARTLAKE_DEBUG_CONSENT config PRERAM_CBMEM_CONSOLE_SIZE hex default 0x1400 + +config SOC_INTEL_ELKHARTLAKE_TCO_NO_REBOOT_EN + bool "Disable reset on second TCO expiration" + depends on SOC_INTEL_COMMON_BLOCK_TCO + default n + help + Setting this option will prevent a host reset if the TCO timer expires + for the second time. Since this feature is not exposed to the OS in the + standard TCO interface, this setting can be enabled on firmware level. + This might be useful depending on the TCO policy. endif diff --git a/src/soc/intel/elkhartlake/bootblock/bootblock.c b/src/soc/intel/elkhartlake/bootblock/bootblock.c index b8086a42ab..cc0bb8f0c4 100644 --- a/src/soc/intel/elkhartlake/bootblock/bootblock.c +++ b/src/soc/intel/elkhartlake/bootblock/bootblock.c @@ -1,10 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include #include +#include #include asmlinkage void bootblock_c_entry(uint64_t base_timestamp) @@ -30,4 +32,11 @@ void bootblock_soc_init(void) /* Programming TCO_BASE_ADDRESS and TCO Timer Halt */ tco_configure(); + if (CONFIG(SOC_INTEL_ELKHARTLAKE_TCO_NO_REBOOT_EN)) { + uint16_t reg = tco_read_reg(TCO1_CNT); + /* NO_REBOOT is enabled via bit 0 in TCO1_CNT. */ + reg |= 0x01; + tco_write_reg(TCO1_CNT, reg); + printk(BIOS_DEBUG, "TCO: Disable reset on second expiration.\n"); + } }