aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/pc80
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2014-04-30 21:31:44 -0700
committerMarc Jones <marc.jones@se-eng.com>2014-12-30 22:10:41 +0100
commit03abaee2196ef5598742132df0e3c224d1ebd11c (patch)
treea856770408e14bd8817a3f87fe73d7530d327e64 /src/drivers/pc80
parent3afa03e995c39aa60e23f3af2714a51abe54e948 (diff)
drivers/pc80/mc146818rtc: Assume we always have ALTCENTURY
This patch has a rather twisted history. It was originally split off from a chromium patch, which moved ALTCENTURY to Kconfig. However, since we have no user without ALTCENTURY, we've agreed that the best way to proceed is to eliminate the non-ALTCENTURY case entirely. The old commit message and identifiers are kept below for reference: The availability of "ALTCENTURY" is now set through a kconfig variable so it can be available to the RTC driver without having to have a specialized interface. BUG=None TEST=Built and booted on Link with the event log code modified to use the RTC interface. Verified that the event times were accurate. BRANCH=nyan Original-Change-Id: Ifa807898e583254e57167fd44932ea86627a02ee Original-Signed-off-by: Gabe Black <gabeblack@google.com> Original-Reviewed-on: https://chromium-review.googlesource.com/197795 Original-Reviewed-by: David Hendricks <dhendrix@chromium.org> Original-Tested-by: Gabe Black <gabeblack@chromium.org> Original-Commit-Queue: Gabe Black <gabeblack@chromium.org> This is the second half the following patch. (cherry picked from commit 9e0fd75142d29afe34f6c6b9ce0099f478ca5a93) Signed-off-by: Marc Jones <marc.jones@se-eng.com> Change-Id: I8e871f31c3d4be7676abf9454ca90808d1ddca03 Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://review.coreboot.org/7987 Reviewed-by: Marc Jones <marc.jones@se-eng.com> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/drivers/pc80')
-rw-r--r--src/drivers/pc80/mc146818rtc.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/drivers/pc80/mc146818rtc.c b/src/drivers/pc80/mc146818rtc.c
index 84abd4309c..fc3adf0cb8 100644
--- a/src/drivers/pc80/mc146818rtc.c
+++ b/src/drivers/pc80/mc146818rtc.c
@@ -32,7 +32,7 @@
#endif
-static void cmos_reset_date(u8 has_century)
+static void cmos_reset_date(void)
{
/* Now setup a default date equals to the build date */
struct rtc_time time = {
@@ -45,7 +45,7 @@ static void cmos_reset_date(u8 has_century)
bcd2bin(coreboot_build_date.year),
.wday = bcd2bin(coreboot_build_date.weekday)
};
- rtc_set(&time, has_century);
+ rtc_set(&time);
}
#if CONFIG_USE_OPTION_TABLE
@@ -123,7 +123,7 @@ void cmos_init(int invalid)
cmos_write(0, i);
#endif
if (cmos_invalid)
- cmos_reset_date(RTC_HAS_NO_ALTCENTURY);
+ cmos_reset_date();
printk(BIOS_WARNING, "RTC:%s%s%s%s\n",
invalid?" Clear requested":"",
@@ -325,12 +325,12 @@ enum cb_err set_option(const char *name, void *value)
* hurts some OSes. Even if we don't set USE_OPTION_TABLE, we need
* to make sure the date is valid.
*/
-void cmos_check_update_date(u8 has_century)
+void cmos_check_update_date()
{
u8 year, century;
- /* Note: Need to check if the hardware supports RTC_CLK_ALTCENTURY. */
- century = has_century ? cmos_read(RTC_CLK_ALTCENTURY) : 0;
+ /* Assume hardware always supports RTC_CLK_ALTCENTURY. */
+ century = cmos_read(RTC_CLK_ALTCENTURY);
year = cmos_read(RTC_CLK_YEAR);
/*
@@ -339,25 +339,23 @@ void cmos_check_update_date(u8 has_century)
* if the date is valid.
*/
if (century > 0x99 || year > 0x99) /* Invalid date */
- cmos_reset_date(has_century);
+ cmos_reset_date();
}
-int rtc_set(const struct rtc_time *time, u8 has_century)
-{
+int rtc_set(const struct rtc_time *time){
cmos_write(bin2bcd(time->sec), RTC_CLK_SECOND);
cmos_write(bin2bcd(time->min), RTC_CLK_MINUTE);
cmos_write(bin2bcd(time->hour), RTC_CLK_HOUR);
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);
- if (has_century)
- cmos_write(bin2bcd(time->year / 100),
- RTC_CLK_ALTCENTURY);
+ /* Same assumption as above: We always have RTC_CLK_ALTCENTURY */
+ cmos_write(bin2bcd(time->year / 100), RTC_CLK_ALTCENTURY);
cmos_write(bin2bcd(time->wday + 1), RTC_CLK_DAYOFWEEK);
return 0;
}
-int rtc_get(struct rtc_time *time, u8 has_century)
+int rtc_get(struct rtc_time *time)
{
time->sec = bcd2bin(cmos_read(RTC_CLK_SECOND));
time->min = bcd2bin(cmos_read(RTC_CLK_MINUTE));
@@ -365,10 +363,8 @@ int rtc_get(struct rtc_time *time, u8 has_century)
time->mday = bcd2bin(cmos_read(RTC_CLK_DAYOFMONTH));
time->mon = bcd2bin(cmos_read(RTC_CLK_MONTH));
time->year = bcd2bin(cmos_read(RTC_CLK_YEAR));
- if (has_century)
- time->year += bcd2bin(cmos_read(RTC_CLK_ALTCENTURY)) * 100;
- else
- time->year += 2000;
+ /* Same assumption as above: We always have RTC_CLK_ALTCENTURY */
+ time->year += bcd2bin(cmos_read(RTC_CLK_ALTCENTURY)) * 100;
time->wday = bcd2bin(cmos_read(RTC_CLK_DAYOFWEEK)) - 1;
return 0;
}