From d8bed2d001e8882850643230a45a7dc362e8e368 Mon Sep 17 00:00:00 2001 From: Yu-Ping Wu Date: Thu, 18 Jul 2024 14:41:49 +0800 Subject: drivers/pc80/rtc/mc146818rtc: Add assertion of bank selection for AMD As described in CB:83495, in AMD platforms, the bit 4 of CMOS Register A is bank selection. Since the MC146818 driver accesses VBNV via Bank 0, the value set in cmos_init() must not contain that bit. To prevent RTC_FREQ_SELECT_DEFAULT from being incorrectly modified, add an static assertion about the bank selection for AMD. Note that the kernel driver also ensures RTC_AMD_BANK_SELECT isn't set for AMD [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/rtc/rtc-mc146818-lib.c?id=3ae8fd4157 BUG=b:346716300 TEST=none BRANCH=skyrim Change-Id: I6122201914c40604f86dcca6025b55c595ef609e Signed-off-by: Yu-Ping Wu Reviewed-on: https://review.coreboot.org/c/coreboot/+/83537 Tested-by: build bot (Jenkins) Reviewed-by: Karthik Ramasubramanian --- src/drivers/pc80/rtc/mc146818rtc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/drivers/pc80') diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c index b4ddadd4f7..1c4428a447 100644 --- a/src/drivers/pc80/rtc/mc146818rtc.c +++ b/src/drivers/pc80/rtc/mc146818rtc.c @@ -65,6 +65,9 @@ int cmos_error(void) #define RTC_CONTROL_DEFAULT (RTC_24H) #define RTC_FREQ_SELECT_DEFAULT (RTC_REF_CLCK_32KHZ | RTC_RATE_1024HZ) +_Static_assert(!CONFIG(SOC_AMD_COMMON) || !(RTC_FREQ_SELECT_DEFAULT & RTC_AMD_BANK_SELECT), + "Bank 1 should not be selected for AMD"); + static bool __cmos_init(bool invalid) { bool cmos_invalid; -- cgit v1.2.3