diff options
author | Nico Huber <nico.h@gmx.de> | 2021-07-12 17:10:59 +0200 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2021-07-23 11:05:30 +0000 |
commit | dee281d03f090b81ba848713be6e864beb7f79d7 (patch) | |
tree | 7f25402ee063c5005d689bc34623b391e6770d2f /src/drivers/pc80/rtc/mc146818rtc.c | |
parent | 4df5779ba98dcd4c983c1eb70e22e00e691b9eab (diff) |
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>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56214
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
Diffstat (limited to 'src/drivers/pc80/rtc/mc146818rtc.c')
-rw-r--r-- | src/drivers/pc80/rtc/mc146818rtc.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c index 42671a94a0..9153a03fd0 100644 --- a/src/drivers/pc80/rtc/mc146818rtc.c +++ b/src/drivers/pc80/rtc/mc146818rtc.c @@ -191,11 +191,11 @@ static int cmos_date_invalid(void) */ 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 @@ int rtc_set(const struct rtc_time *time) 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,13 @@ int rtc_get(struct rtc_time *time) 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 { + time->year += 1900; + if (time->year < 1970) + time->year += 100; + } time->wday = bcd2bin(cmos_read(RTC_CLK_DAYOFWEEK)) - 1; return 0; } |