diff options
Diffstat (limited to 'arch/powerpc/platforms/powermac/time.c')
-rw-r--r-- | arch/powerpc/platforms/powermac/time.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c index edb9fcc64790..3ee6d8aa14c4 100644 --- a/arch/powerpc/platforms/powermac/time.c +++ b/arch/powerpc/platforms/powermac/time.c | |||
@@ -77,8 +77,7 @@ pmac_time_init(void) | |||
77 | #endif | 77 | #endif |
78 | } | 78 | } |
79 | 79 | ||
80 | unsigned long | 80 | unsigned long pmac_get_boot_time(void) |
81 | pmac_get_rtc_time(void) | ||
82 | { | 81 | { |
83 | #if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) | 82 | #if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) |
84 | struct adb_request req; | 83 | struct adb_request req; |
@@ -118,20 +117,33 @@ pmac_get_rtc_time(void) | |||
118 | return 0; | 117 | return 0; |
119 | } | 118 | } |
120 | 119 | ||
121 | int | 120 | void pmac_get_rtc_time(struct rtc_time *tm) |
122 | pmac_set_rtc_time(unsigned long nowtime) | ||
123 | { | 121 | { |
122 | unsigned long now; | ||
123 | |||
124 | now = pmac_get_boot_time(); | ||
125 | to_tm(now, tm); | ||
126 | tm->tm_year -= 1900; | ||
127 | tm->tm_mon -= 1; /* month is 0-based */ | ||
128 | } | ||
129 | |||
130 | int pmac_set_rtc_time(struct rtc_time *tm) | ||
131 | { | ||
132 | unsigned long nowtime; | ||
124 | #if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) | 133 | #if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) |
125 | struct adb_request req; | 134 | struct adb_request req; |
126 | #endif | 135 | #endif |
127 | 136 | ||
137 | nowtime = mktime(tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, | ||
138 | tm->tm_hour, tm->tm_min, tm->tm_sec); | ||
128 | nowtime += RTC_OFFSET; | 139 | nowtime += RTC_OFFSET; |
129 | 140 | ||
130 | switch (sys_ctrler) { | 141 | switch (sys_ctrler) { |
131 | #ifdef CONFIG_ADB_CUDA | 142 | #ifdef CONFIG_ADB_CUDA |
132 | case SYS_CTRLER_CUDA: | 143 | case SYS_CTRLER_CUDA: |
133 | if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME, | 144 | if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME, |
134 | nowtime >> 24, nowtime >> 16, nowtime >> 8, nowtime) < 0) | 145 | nowtime >> 24, nowtime >> 16, nowtime >> 8, |
146 | nowtime) < 0) | ||
135 | return 0; | 147 | return 0; |
136 | while (!req.complete) | 148 | while (!req.complete) |
137 | cuda_poll(); | 149 | cuda_poll(); |
@@ -221,7 +233,7 @@ time_sleep_notify(struct pmu_sleep_notifier *self, int when) | |||
221 | case PBOOK_SLEEP_NOW: | 233 | case PBOOK_SLEEP_NOW: |
222 | do { | 234 | do { |
223 | seq = read_seqbegin_irqsave(&xtime_lock, flags); | 235 | seq = read_seqbegin_irqsave(&xtime_lock, flags); |
224 | time_diff = xtime.tv_sec - pmac_get_rtc_time(); | 236 | time_diff = xtime.tv_sec - pmac_get_boot_time(); |
225 | } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); | 237 | } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); |
226 | break; | 238 | break; |
227 | case PBOOK_WAKE: | 239 | case PBOOK_WAKE: |