12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/kernel.h>
16 #include <linux/string.h>
19 #include <linux/time.h>
20 #include <linux/adb.h>
21 #include <linux/cuda.h>
22 #include <linux/pmu.h>
25 #include <linux/rtc.h>
27 #include <asm/sections.h>
30 #include <asm/pgtable.h>
31 #include <asm/machdep.h>
33 #include <asm/nvram.h>
39 #define DBG(x...) printk(x)
45 #define RTC_OFFSET 2082844800
50 #define VIA_TIMER_FREQ_6 4700000
63 #define T1MODE_CONT 0x40
77 if (delta & 0x00800000UL)
78 delta |= 0xFF000000
UL;
80 printk(
"GMT Delta read from XPRAM: %d minutes, DST: %s\n", delta/60,
86 #if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU)
87 static void to_rtc_time(
unsigned long now,
struct rtc_time *
tm)
95 #if defined(CONFIG_ADB_CUDA) || defined(CONFIG_ADB_PMU) || \
96 defined(CONFIG_PMAC_SMU)
97 static unsigned long from_rtc_time(
struct rtc_time *
tm)
104 #ifdef CONFIG_ADB_CUDA
112 while (!
req.complete)
114 if (
req.reply_len != 7)
117 now = (
req.reply[3] << 24) + (
req.reply[4] << 16)
118 + (
req.reply[5] << 8) +
req.reply[6];
122 #define cuda_get_rtc_time(tm) to_rtc_time(cuda_get_time(), (tm))
126 unsigned int nowtime;
131 nowtime >> 24, nowtime >> 16, nowtime >> 8,
134 while (!
req.complete)
136 if ((
req.reply_len != 3) && (
req.reply_len != 7))
143 #define cuda_get_time() 0
144 #define cuda_get_rtc_time(tm)
145 #define cuda_set_rtc_time(tm) 0
148 #ifdef CONFIG_ADB_PMU
160 now = (req.
reply[0] << 24) + (req.
reply[1] << 16)
165 #define pmu_get_rtc_time(tm) to_rtc_time(pmu_get_time(), (tm))
169 unsigned int nowtime;
174 nowtime >> 16, nowtime >> 8, nowtime) < 0)
177 if (
req.reply_len != 0)
184 #define pmu_get_time() 0
185 #define pmu_get_rtc_time(tm)
186 #define pmu_set_rtc_time(tm) 0
189 #ifdef CONFIG_PMAC_SMU
196 return from_rtc_time(&tm);
200 #define smu_get_time() 0
201 #define smu_get_rtc_time(tm, spin)
202 #define smu_set_rtc_time(tm, spin) 0
210 case SYS_CTRLER_CUDA:
225 case SYS_CTRLER_CUDA:
242 case SYS_CTRLER_CUDA:
258 int __init via_calibrate_decr(
void)
261 volatile unsigned char __iomem *via;
263 unsigned int dstart, dend;
276 via =
ioremap(rsrc.start, resource_size(&rsrc));
295 while ((
in_8(&via[IFR]) & T1_INT) == 0)
322 if (via_calibrate_decr())
331 if (via_calibrate_decr())