aboutsummaryrefslogtreecommitdiff
path: root/sys/x86
diff options
context:
space:
mode:
authorAustin Zhang <austin.zhang@dell.com>2022-01-13 17:13:25 +0000
committerEric van Gyzen <vangyzen@FreeBSD.org>2022-01-13 17:24:00 +0000
commite1ef6c0ef256f797d629b9490db3f0034b28ae43 (patch)
tree5ef04bc3a4554a47e348cbffc9c5bef53459410d /sys/x86
parent900a792250c2e8824ce7ebc49fef59ba6e82c9a4 (diff)
downloadsrc-e1ef6c0ef256f797d629b9490db3f0034b28ae43.tar.gz
src-e1ef6c0ef256f797d629b9490db3f0034b28ae43.zip
atrtc: reads Century field from FADT table
The ACPI spec describes the FADT->Century field as: The RTC CMOS RAM index to the century of data value (hundred and thousand year decimals). If this field contains a zero, then the RTC centenary feature is not supported. If this field has a non-zero value, then this field contains an index into RTC RAM space that OSPM can use to program the centenary field. Use this field to decide whether to program the CENTURY register of the CMOS RTC device. Reviewed by: akumar3@isilon.com, dab, vangyzen MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D33667 MFC after: 1 week Sponsored by: Dell EMC Isilon
Diffstat (limited to 'sys/x86')
-rw-r--r--sys/x86/isa/atrtc.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/sys/x86/isa/atrtc.c b/sys/x86/isa/atrtc.c
index cad8015435d0..aff838c53851 100644
--- a/sys/x86/isa/atrtc.c
+++ b/sys/x86/isa/atrtc.c
@@ -79,6 +79,7 @@ MTX_SYSINIT(atrtc_time_lock_init, &atrtc_time_lock, "atrtc_time", MTX_DEF);
int atrtcclock_disable = 0;
+static int rtc_century = 0;
static int rtc_reg = -1;
static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
static u_char rtc_statusb = RTCSB_24HR;
@@ -421,6 +422,31 @@ atrtc_acpi_disabled(void)
}
static int
+rtc_acpi_century_get(void)
+{
+#ifdef DEV_ACPI
+ ACPI_TABLE_FADT *fadt;
+ vm_paddr_t physaddr;
+ int century;
+
+ physaddr = acpi_find_table(ACPI_SIG_FADT);
+ if (physaddr == 0)
+ return (0);
+
+ fadt = acpi_map_table(physaddr, ACPI_SIG_FADT);
+ if (fadt == NULL)
+ return (0);
+
+ century = fadt->Century;
+ acpi_unmap_table(fadt);
+
+ return (century);
+#else
+ return (0);
+#endif
+}
+
+static int
atrtc_probe(device_t dev)
{
int result;
@@ -435,6 +461,7 @@ atrtc_probe(device_t dev)
device_set_desc(dev, "AT realtime clock");
return (BUS_PROBE_LOW_PRIORITY);
}
+ rtc_century = rtc_acpi_century_get();
return (result);
}
@@ -548,9 +575,8 @@ atrtc_settime(device_t dev __unused, struct timespec *ts)
rtcout_locked(RTC_DAY, bct.day);
rtcout_locked(RTC_MONTH, bct.mon);
rtcout_locked(RTC_YEAR, bct.year & 0xff);
-#ifdef USE_RTC_CENTURY
- rtcout_locked(RTC_CENTURY, bct.year >> 8);
-#endif
+ if (rtc_century)
+ rtcout_locked(rtc_century, bct.year >> 8);
/*
* Re-enable RTC updates and interrupts.
@@ -592,9 +618,8 @@ atrtc_gettime(device_t dev, struct timespec *ts)
bct.day = rtcin_locked(RTC_DAY);
bct.mon = rtcin_locked(RTC_MONTH);
bct.year = rtcin_locked(RTC_YEAR);
-#ifdef USE_RTC_CENTURY
- bct.year |= rtcin_locked(RTC_CENTURY) << 8;
-#endif
+ if (rtc_century)
+ bct.year |= rtcin_locked(rtc_century) << 8;
mtx_unlock_spin(&atrtc_lock);
mtx_unlock(&atrtc_time_lock);
/* dow is unused in timespec conversion and we have no nsec info. */