aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/rtc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 11:25:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 11:25:51 -0400
commit9e9abecfc0ff3a9ad2ead954b37bbfcb863c775e (patch)
tree0c3ffda953b82750638a06507591ad587b565ff2 /arch/x86/kernel/rtc.c
parentd7bb545d86825e635cab33a1dd81ca0ad7b92887 (diff)
parent77ad386e596c6b0930cc2e09e3cce485e3ee7f72 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86: (613 commits) x86: standalone trampoline code x86: move suspend wakeup code to C x86: coding style fixes to arch/x86/kernel/acpi/sleep.c x86: setup_trampoline() - fix section mismatch warning x86: section mismatch fixes, #1 x86: fix paranoia about using BIOS quickboot mechanism. x86: print out buggy mptable x86: use cpu_online() x86: use cpumask_of_cpu() x86: remove unnecessary tmp local variable x86: remove unnecessary memset() x86: use ioapic_read_entry() and ioapic_write_entry() x86: avoid redundant loop in io_apic_level_ack_pending() x86: remove superfluous initialisation in boot code. x86: merge mpparse_{32,64}.c x86: unify mp_register_gsi x86: unify mp_config_acpi_legacy_irqs x86: unify mp_register_ioapic x86: unify uniq_io_apic_id x86: unify smp_scan_config ...
Diffstat (limited to 'arch/x86/kernel/rtc.c')
-rw-r--r--arch/x86/kernel/rtc.c33
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 */
18volatile unsigned long cmos_lock = 0; 17volatile unsigned long cmos_lock = 0;
19EXPORT_SYMBOL(cmos_lock); 18EXPORT_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
28DEFINE_SPINLOCK(rtc_lock); 24DEFINE_SPINLOCK(rtc_lock);
29EXPORT_SYMBOL(rtc_lock); 25EXPORT_SYMBOL(rtc_lock);
30 26
@@ -98,7 +94,7 @@ int mach_set_rtc_mmss(unsigned long nowtime)
98 94
99unsigned long mach_get_cmos_time(void) 95unsigned 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);
161void rtc_cmos_write(unsigned char val, unsigned char addr) 156void 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}
168EXPORT_SYMBOL(rtc_cmos_write); 163EXPORT_SYMBOL(rtc_cmos_write);