aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-i386/mach-default/mach_time.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-i386/mach-default/mach_time.h')
-rw-r--r--include/asm-i386/mach-default/mach_time.h37
1 files changed, 13 insertions, 24 deletions
diff --git a/include/asm-i386/mach-default/mach_time.h b/include/asm-i386/mach-default/mach_time.h
index b749aa44a86f..31eb5de6f3dc 100644
--- a/include/asm-i386/mach-default/mach_time.h
+++ b/include/asm-i386/mach-default/mach_time.h
@@ -82,21 +82,8 @@ static inline int mach_set_rtc_mmss(unsigned long nowtime)
82static inline unsigned long mach_get_cmos_time(void) 82static inline unsigned long mach_get_cmos_time(void)
83{ 83{
84 unsigned int year, mon, day, hour, min, sec; 84 unsigned int year, mon, day, hour, min, sec;
85 int i;
86 85
87 /* The Linux interpretation of the CMOS clock register contents: 86 do {
88 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
89 * RTC registers show the second which has precisely just started.
90 * Let's hope other operating systems interpret the RTC the same way.
91 */
92 /* read RTC exactly on falling edge of update flag */
93 for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */
94 if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
95 break;
96 for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */
97 if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
98 break;
99 do { /* Isn't this overkill ? UIP above should guarantee consistency */
100 sec = CMOS_READ(RTC_SECONDS); 87 sec = CMOS_READ(RTC_SECONDS);
101 min = CMOS_READ(RTC_MINUTES); 88 min = CMOS_READ(RTC_MINUTES);
102 hour = CMOS_READ(RTC_HOURS); 89 hour = CMOS_READ(RTC_HOURS);
@@ -104,16 +91,18 @@ static inline unsigned long mach_get_cmos_time(void)
104 mon = CMOS_READ(RTC_MONTH); 91 mon = CMOS_READ(RTC_MONTH);
105 year = CMOS_READ(RTC_YEAR); 92 year = CMOS_READ(RTC_YEAR);
106 } while (sec != CMOS_READ(RTC_SECONDS)); 93 } while (sec != CMOS_READ(RTC_SECONDS));
107 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) 94
108 { 95 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
109 BCD_TO_BIN(sec); 96 BCD_TO_BIN(sec);
110 BCD_TO_BIN(min); 97 BCD_TO_BIN(min);
111 BCD_TO_BIN(hour); 98 BCD_TO_BIN(hour);
112 BCD_TO_BIN(day); 99 BCD_TO_BIN(day);
113 BCD_TO_BIN(mon); 100 BCD_TO_BIN(mon);
114 BCD_TO_BIN(year); 101 BCD_TO_BIN(year);
115 } 102 }
116 if ((year += 1900) < 1970) 103
104 year += 1900;
105 if (year < 1970)
117 year += 100; 106 year += 100;
118 107
119 return mktime(year, mon, day, hour, min, sec); 108 return mktime(year, mon, day, hour, min, sec);