diff options
Diffstat (limited to 'arch/ppc64/kernel/pmac_time.c')
-rw-r--r-- | arch/ppc64/kernel/pmac_time.c | 174 |
1 files changed, 0 insertions, 174 deletions
diff --git a/arch/ppc64/kernel/pmac_time.c b/arch/ppc64/kernel/pmac_time.c deleted file mode 100644 index 928bf213ec4e..000000000000 --- a/arch/ppc64/kernel/pmac_time.c +++ /dev/null | |||
@@ -1,174 +0,0 @@ | |||
1 | /* | ||
2 | * Support for periodic interrupts (100 per second) and for getting | ||
3 | * the current time from the RTC on Power Macintoshes. | ||
4 | * | ||
5 | * We use the decrementer register for our periodic interrupts. | ||
6 | * | ||
7 | * Paul Mackerras August 1996. | ||
8 | * Copyright (C) 1996 Paul Mackerras. | ||
9 | * Copyright (C) 2003-2005 Benjamin Herrenschmidt. | ||
10 | * | ||
11 | */ | ||
12 | #include <linux/config.h> | ||
13 | #include <linux/errno.h> | ||
14 | #include <linux/sched.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/param.h> | ||
17 | #include <linux/string.h> | ||
18 | #include <linux/mm.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/time.h> | ||
21 | #include <linux/adb.h> | ||
22 | #include <linux/pmu.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/rtc.h> | ||
25 | |||
26 | #include <asm/sections.h> | ||
27 | #include <asm/prom.h> | ||
28 | #include <asm/system.h> | ||
29 | #include <asm/io.h> | ||
30 | #include <asm/pgtable.h> | ||
31 | #include <asm/machdep.h> | ||
32 | #include <asm/time.h> | ||
33 | #include <asm/nvram.h> | ||
34 | #include <asm/smu.h> | ||
35 | |||
36 | #undef DEBUG | ||
37 | |||
38 | #ifdef DEBUG | ||
39 | #define DBG(x...) printk(x) | ||
40 | #else | ||
41 | #define DBG(x...) | ||
42 | #endif | ||
43 | |||
44 | /* Apparently the RTC stores seconds since 1 Jan 1904 */ | ||
45 | #define RTC_OFFSET 2082844800 | ||
46 | |||
47 | /* | ||
48 | * Calibrate the decrementer frequency with the VIA timer 1. | ||
49 | */ | ||
50 | #define VIA_TIMER_FREQ_6 4700000 /* time 1 frequency * 6 */ | ||
51 | |||
52 | extern struct timezone sys_tz; | ||
53 | extern void to_tm(int tim, struct rtc_time * tm); | ||
54 | |||
55 | void pmac_get_rtc_time(struct rtc_time *tm) | ||
56 | { | ||
57 | switch(sys_ctrler) { | ||
58 | #ifdef CONFIG_ADB_PMU | ||
59 | case SYS_CTRLER_PMU: { | ||
60 | /* TODO: Move that to a function in the PMU driver */ | ||
61 | struct adb_request req; | ||
62 | unsigned int now; | ||
63 | |||
64 | if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0) | ||
65 | return; | ||
66 | pmu_wait_complete(&req); | ||
67 | if (req.reply_len != 4) | ||
68 | printk(KERN_ERR "pmac_get_rtc_time: PMU returned a %d" | ||
69 | " bytes reply\n", req.reply_len); | ||
70 | now = (req.reply[0] << 24) + (req.reply[1] << 16) | ||
71 | + (req.reply[2] << 8) + req.reply[3]; | ||
72 | DBG("get: %u -> %u\n", (int)now, (int)(now - RTC_OFFSET)); | ||
73 | now -= RTC_OFFSET; | ||
74 | |||
75 | to_tm(now, tm); | ||
76 | tm->tm_year -= 1900; | ||
77 | tm->tm_mon -= 1; | ||
78 | |||
79 | DBG("-> tm_mday: %d, tm_mon: %d, tm_year: %d, %d:%02d:%02d\n", | ||
80 | tm->tm_mday, tm->tm_mon, tm->tm_year, | ||
81 | tm->tm_hour, tm->tm_min, tm->tm_sec); | ||
82 | break; | ||
83 | } | ||
84 | #endif /* CONFIG_ADB_PMU */ | ||
85 | |||
86 | #ifdef CONFIG_PMAC_SMU | ||
87 | case SYS_CTRLER_SMU: | ||
88 | smu_get_rtc_time(tm, 1); | ||
89 | break; | ||
90 | #endif /* CONFIG_PMAC_SMU */ | ||
91 | default: | ||
92 | ; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | int pmac_set_rtc_time(struct rtc_time *tm) | ||
97 | { | ||
98 | switch(sys_ctrler) { | ||
99 | #ifdef CONFIG_ADB_PMU | ||
100 | case SYS_CTRLER_PMU: { | ||
101 | /* TODO: Move that to a function in the PMU driver */ | ||
102 | struct adb_request req; | ||
103 | unsigned int nowtime; | ||
104 | |||
105 | DBG("set: tm_mday: %d, tm_mon: %d, tm_year: %d," | ||
106 | " %d:%02d:%02d\n", | ||
107 | tm->tm_mday, tm->tm_mon, tm->tm_year, | ||
108 | tm->tm_hour, tm->tm_min, tm->tm_sec); | ||
109 | |||
110 | nowtime = mktime(tm->tm_year + 1900, tm->tm_mon + 1, | ||
111 | tm->tm_mday, tm->tm_hour, tm->tm_min, | ||
112 | tm->tm_sec); | ||
113 | |||
114 | DBG("-> %u -> %u\n", (int)nowtime, | ||
115 | (int)(nowtime + RTC_OFFSET)); | ||
116 | nowtime += RTC_OFFSET; | ||
117 | |||
118 | if (pmu_request(&req, NULL, 5, PMU_SET_RTC, | ||
119 | nowtime >> 24, nowtime >> 16, | ||
120 | nowtime >> 8, nowtime) < 0) | ||
121 | return -ENXIO; | ||
122 | pmu_wait_complete(&req); | ||
123 | if (req.reply_len != 0) | ||
124 | printk(KERN_ERR "pmac_set_rtc_time: PMU returned a %d" | ||
125 | " bytes reply\n", req.reply_len); | ||
126 | return 0; | ||
127 | } | ||
128 | #endif /* CONFIG_ADB_PMU */ | ||
129 | |||
130 | #ifdef CONFIG_PMAC_SMU | ||
131 | case SYS_CTRLER_SMU: | ||
132 | return smu_set_rtc_time(tm, 1); | ||
133 | #endif /* CONFIG_PMAC_SMU */ | ||
134 | default: | ||
135 | return -ENODEV; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | unsigned long __init pmac_get_boot_time(void) | ||
140 | { | ||
141 | struct rtc_time tm; | ||
142 | |||
143 | pmac_get_rtc_time(&tm); | ||
144 | return mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, | ||
145 | tm.tm_hour, tm.tm_min, tm.tm_sec); | ||
146 | } | ||
147 | |||
148 | /* | ||
149 | * Query the OF and get the decr frequency. | ||
150 | * FIXME: merge this with generic_calibrate_decr | ||
151 | */ | ||
152 | void __init pmac_calibrate_decr(void) | ||
153 | { | ||
154 | struct device_node *cpu; | ||
155 | unsigned int *fp; | ||
156 | |||
157 | /* | ||
158 | * The cpu node should have a timebase-frequency property | ||
159 | * to tell us the rate at which the decrementer counts. | ||
160 | */ | ||
161 | cpu = find_type_devices("cpu"); | ||
162 | if (cpu == 0) | ||
163 | panic("can't find cpu node in time_init"); | ||
164 | fp = (unsigned int *) get_property(cpu, "timebase-frequency", NULL); | ||
165 | if (fp == 0) | ||
166 | panic("can't get cpu timebase frequency"); | ||
167 | ppc_tb_freq = *fp; | ||
168 | |||
169 | fp = (unsigned int *)get_property(cpu, "clock-frequency", NULL); | ||
170 | if (fp == 0) | ||
171 | panic("can't get cpu processor frequency"); | ||
172 | ppc_proc_freq = *fp; | ||
173 | } | ||
174 | |||