aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips/mc146818-time.h
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2006-03-28 21:24:50 -0500
committerPaul Mackerras <paulus@samba.org>2006-03-28 21:24:50 -0500
commitbac30d1a78d0f11c613968fc8b351a91ed465386 (patch)
treee52f3c876522a2f6047a6ec1c27df2e8a79486b8 /include/asm-mips/mc146818-time.h
parente8222502ee6157e2713da9e0792c21f4ad458d50 (diff)
parentca9ba4471c1203bb6e759b76e83167fec54fe590 (diff)
Merge ../linux-2.6
Diffstat (limited to 'include/asm-mips/mc146818-time.h')
-rw-r--r--include/asm-mips/mc146818-time.h33
1 files changed, 2 insertions, 31 deletions
diff --git a/include/asm-mips/mc146818-time.h b/include/asm-mips/mc146818-time.h
index 47214861093b..41ac8d363c67 100644
--- a/include/asm-mips/mc146818-time.h
+++ b/include/asm-mips/mc146818-time.h
@@ -86,43 +86,14 @@ static inline int mc146818_set_rtc_mmss(unsigned long nowtime)
86 return retval; 86 return retval;
87} 87}
88 88
89/*
90 * Returns true if a clock update is in progress
91 */
92static inline unsigned char rtc_is_updating(void)
93{
94 unsigned char uip;
95 unsigned long flags;
96
97 spin_lock_irqsave(&rtc_lock, flags);
98 uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
99 spin_unlock_irqrestore(&rtc_lock, flags);
100 return uip;
101}
102
103static inline unsigned long mc146818_get_cmos_time(void) 89static inline unsigned long mc146818_get_cmos_time(void)
104{ 90{
105 unsigned int year, mon, day, hour, min, sec; 91 unsigned int year, mon, day, hour, min, sec;
106 int i;
107 unsigned long flags; 92 unsigned long flags;
108 93
109 /*
110 * The Linux interpretation of the CMOS clock register contents:
111 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
112 * RTC registers show the second which has precisely just started.
113 * Let's hope other operating systems interpret the RTC the same way.
114 */
115
116 /* read RTC exactly on falling edge of update flag */
117 for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */
118 if (rtc_is_updating())
119 break;
120 for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */
121 if (!rtc_is_updating())
122 break;
123
124 spin_lock_irqsave(&rtc_lock, flags); 94 spin_lock_irqsave(&rtc_lock, flags);
125 do { /* Isn't this overkill ? UIP above should guarantee consistency */ 95
96 do {
126 sec = CMOS_READ(RTC_SECONDS); 97 sec = CMOS_READ(RTC_SECONDS);
127 min = CMOS_READ(RTC_MINUTES); 98 min = CMOS_READ(RTC_MINUTES);
128 hour = CMOS_READ(RTC_HOURS); 99 hour = CMOS_READ(RTC_HOURS);