Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56214 )
Change subject: drivers/pc80/rtc: Make use of alt-century byte configurable ......................................................................
drivers/pc80/rtc: Make use of alt-century byte configurable
This legacy alt-century byte sits amidst CMOS and conflicts many option tables. It usually has no meaning to the hardware and needs to be main- tained manually. Let's disable its usage by default if the CMOS option table is enabled.
Change-Id: Ifba3d77120c2474393ac5e64faac1baeeb58c893 Signed-off-by: Nico Huber nico.h@gmx.de --- M src/drivers/pc80/rtc/Kconfig M src/drivers/pc80/rtc/mc146818rtc.c 2 files changed, 16 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/56214/1
diff --git a/src/drivers/pc80/rtc/Kconfig b/src/drivers/pc80/rtc/Kconfig index 350863e..7958682 100644 --- a/src/drivers/pc80/rtc/Kconfig +++ b/src/drivers/pc80/rtc/Kconfig @@ -2,3 +2,10 @@ bool default y if ARCH_X86 depends on PC80_SYSTEM + +config USE_PC_CMOS_ALTCENTURY + bool "Use legacy-BIOS alt-century byte in CMOS" + default y if !USE_OPTION_TABLE + depends on DRIVERS_MC146818 + help + May be useful for legacy OSs that assume its presence. diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c index 42671a9..e0c2400 100644 --- a/src/drivers/pc80/rtc/mc146818rtc.c +++ b/src/drivers/pc80/rtc/mc146818rtc.c @@ -191,11 +191,11 @@ */ void cmos_check_update_date(void) { - u8 year, century; + u8 year, century = 0;
- /* Assume hardware always supports RTC_CLK_ALTCENTURY. */ wait_uip(); - century = cmos_read(RTC_CLK_ALTCENTURY); + if (CONFIG(USE_PC_CMOS_ALTCENTURY)) + century = cmos_read(RTC_CLK_ALTCENTURY); year = cmos_read(RTC_CLK_YEAR);
/* @@ -215,8 +215,8 @@ cmos_write(bin2bcd(time->mday), RTC_CLK_DAYOFMONTH); cmos_write(bin2bcd(time->mon), RTC_CLK_MONTH); cmos_write(bin2bcd(time->year % 100), RTC_CLK_YEAR); - /* Same assumption as above: We always have RTC_CLK_ALTCENTURY */ - cmos_write(bin2bcd(time->year / 100), RTC_CLK_ALTCENTURY); + if (CONFIG(USE_PC_CMOS_ALTCENTURY)) + cmos_write(bin2bcd(time->year / 100), RTC_CLK_ALTCENTURY); cmos_write(bin2bcd(time->wday + 1), RTC_CLK_DAYOFWEEK); return 0; } @@ -230,8 +230,10 @@ time->mday = bcd2bin(cmos_read(RTC_CLK_DAYOFMONTH)); time->mon = bcd2bin(cmos_read(RTC_CLK_MONTH)); time->year = bcd2bin(cmos_read(RTC_CLK_YEAR)); - /* Same assumption as above: We always have RTC_CLK_ALTCENTURY */ - time->year += bcd2bin(cmos_read(RTC_CLK_ALTCENTURY)) * 100; + if (CONFIG(USE_PC_CMOS_ALTCENTURY)) + time->year += bcd2bin(cmos_read(RTC_CLK_ALTCENTURY)) * 100; + else if (time->year <= 69) + time->year += 100; time->wday = bcd2bin(cmos_read(RTC_CLK_DAYOFWEEK)) - 1; return 0; }