diff options
Diffstat (limited to 'arch/x86/kernel/rtc.c')
-rw-r--r-- | arch/x86/kernel/rtc.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index eb9b1a198f5e..9615eee9b775 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <asm/vsyscall.h> | 9 | #include <asm/vsyscall.h> |
10 | 10 | ||
11 | #ifdef CONFIG_X86_32 | 11 | #ifdef CONFIG_X86_32 |
12 | # define CMOS_YEARS_OFFS 1900 | ||
13 | /* | 12 | /* |
14 | * This is a special lock that is owned by the CPU and holds the index | 13 | * This is a special lock that is owned by the CPU and holds the index |
15 | * register we are working with. It is required for NMI access to the | 14 | * register we are working with. It is required for NMI access to the |
@@ -17,14 +16,11 @@ | |||
17 | */ | 16 | */ |
18 | volatile unsigned long cmos_lock = 0; | 17 | volatile unsigned long cmos_lock = 0; |
19 | EXPORT_SYMBOL(cmos_lock); | 18 | EXPORT_SYMBOL(cmos_lock); |
20 | #else | ||
21 | /* | ||
22 | * x86-64 systems only exists since 2002. | ||
23 | * This will work up to Dec 31, 2100 | ||
24 | */ | ||
25 | # define CMOS_YEARS_OFFS 2000 | ||
26 | #endif | 19 | #endif |
27 | 20 | ||
21 | /* For two digit years assume time is always after that */ | ||
22 | #define CMOS_YEARS_OFFS 2000 | ||
23 | |||
28 | DEFINE_SPINLOCK(rtc_lock); | 24 | DEFINE_SPINLOCK(rtc_lock); |
29 | EXPORT_SYMBOL(rtc_lock); | 25 | EXPORT_SYMBOL(rtc_lock); |
30 | 26 | ||
@@ -98,7 +94,7 @@ int mach_set_rtc_mmss(unsigned long nowtime) | |||
98 | 94 | ||
99 | unsigned long mach_get_cmos_time(void) | 95 | unsigned long mach_get_cmos_time(void) |
100 | { | 96 | { |
101 | unsigned int year, mon, day, hour, min, sec, century = 0; | 97 | unsigned int status, year, mon, day, hour, min, sec, century = 0; |
102 | 98 | ||
103 | /* | 99 | /* |
104 | * If UIP is clear, then we have >= 244 microseconds before | 100 | * If UIP is clear, then we have >= 244 microseconds before |
@@ -116,14 +112,16 @@ unsigned long mach_get_cmos_time(void) | |||
116 | mon = CMOS_READ(RTC_MONTH); | 112 | mon = CMOS_READ(RTC_MONTH); |
117 | year = CMOS_READ(RTC_YEAR); | 113 | year = CMOS_READ(RTC_YEAR); |
118 | 114 | ||
119 | #if defined(CONFIG_ACPI) && defined(CONFIG_X86_64) | 115 | #ifdef CONFIG_ACPI |
120 | /* CHECKME: Is this really 64bit only ??? */ | ||
121 | if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && | 116 | if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID && |
122 | acpi_gbl_FADT.century) | 117 | acpi_gbl_FADT.century) |
123 | century = CMOS_READ(acpi_gbl_FADT.century); | 118 | century = CMOS_READ(acpi_gbl_FADT.century); |
124 | #endif | 119 | #endif |
125 | 120 | ||
126 | if (RTC_ALWAYS_BCD || !(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY)) { | 121 | status = CMOS_READ(RTC_CONTROL); |
122 | WARN_ON_ONCE(RTC_ALWAYS_BCD && (status & RTC_DM_BINARY)); | ||
123 | |||
124 | if (RTC_ALWAYS_BCD || !(status & RTC_DM_BINARY)) { | ||
127 | BCD_TO_BIN(sec); | 125 | BCD_TO_BIN(sec); |
128 | BCD_TO_BIN(min); | 126 | BCD_TO_BIN(min); |
129 | BCD_TO_BIN(hour); | 127 | BCD_TO_BIN(hour); |
@@ -136,11 +134,8 @@ unsigned long mach_get_cmos_time(void) | |||
136 | BCD_TO_BIN(century); | 134 | BCD_TO_BIN(century); |
137 | year += century * 100; | 135 | year += century * 100; |
138 | printk(KERN_INFO "Extended CMOS year: %d\n", century * 100); | 136 | printk(KERN_INFO "Extended CMOS year: %d\n", century * 100); |
139 | } else { | 137 | } else |
140 | year += CMOS_YEARS_OFFS; | 138 | year += CMOS_YEARS_OFFS; |
141 | if (year < 1970) | ||
142 | year += 100; | ||
143 | } | ||
144 | 139 | ||
145 | return mktime(year, mon, day, hour, min, sec); | 140 | return mktime(year, mon, day, hour, min, sec); |
146 | } | 141 | } |
@@ -151,8 +146,8 @@ unsigned char rtc_cmos_read(unsigned char addr) | |||
151 | unsigned char val; | 146 | unsigned char val; |
152 | 147 | ||
153 | lock_cmos_prefix(addr); | 148 | lock_cmos_prefix(addr); |
154 | outb_p(addr, RTC_PORT(0)); | 149 | outb(addr, RTC_PORT(0)); |
155 | val = inb_p(RTC_PORT(1)); | 150 | val = inb(RTC_PORT(1)); |
156 | lock_cmos_suffix(addr); | 151 | lock_cmos_suffix(addr); |
157 | return val; | 152 | return val; |
158 | } | 153 | } |
@@ -161,8 +156,8 @@ EXPORT_SYMBOL(rtc_cmos_read); | |||
161 | void rtc_cmos_write(unsigned char val, unsigned char addr) | 156 | void rtc_cmos_write(unsigned char val, unsigned char addr) |
162 | { | 157 | { |
163 | lock_cmos_prefix(addr); | 158 | lock_cmos_prefix(addr); |
164 | outb_p(addr, RTC_PORT(0)); | 159 | outb(addr, RTC_PORT(0)); |
165 | outb_p(val, RTC_PORT(1)); | 160 | outb(val, RTC_PORT(1)); |
166 | lock_cmos_suffix(addr); | 161 | lock_cmos_suffix(addr); |
167 | } | 162 | } |
168 | EXPORT_SYMBOL(rtc_cmos_write); | 163 | EXPORT_SYMBOL(rtc_cmos_write); |