aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorGeoff Levand <geoffrey.levand@am.sony.com>2007-10-06 17:35:46 -0400
committerPaul Mackerras <paulus@samba.org>2007-10-09 07:01:58 -0400
commitd7b98e3dd87b4512462f6cdfe646a8e59673e62e (patch)
treee75ad71fca09dd7561528b9e2039ee8f03353b40 /arch/powerpc
parent418ef2094eb8b0916d6cbda10e2ab857b9f64d97 (diff)
[POWERPC] PS3: Add os-area rtc_diff set/get routines
Updates for PS3 os-area rtc_diff set/get routines o Add a new routine ps3_os_area_set_rtc_diff(). o Rename ps3_os_area_rtc_diff() to ps3_os_area_get_rtc_diff(). o Remove static variable rtc_shift with calls to ps3_os_area_get_rtc_diff(). Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/ps3/os-area.c19
-rw-r--r--arch/powerpc/platforms/ps3/platform.h3
-rw-r--r--arch/powerpc/platforms/ps3/time.c14
3 files changed, 22 insertions, 14 deletions
diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c
index db311a147c28..473aee8580ce 100644
--- a/arch/powerpc/platforms/ps3/os-area.c
+++ b/arch/powerpc/platforms/ps3/os-area.c
@@ -261,16 +261,31 @@ void __init ps3_os_area_save_params(void)
261} 261}
262 262
263/** 263/**
264 * ps3_os_area_rtc_diff - Returns the rtc diff value. 264 * ps3_os_area_get_rtc_diff - Returns the rtc diff value.
265 */ 265 */
266 266
267u64 ps3_os_area_rtc_diff(void) 267u64 ps3_os_area_get_rtc_diff(void)
268{ 268{
269 return saved_params.rtc_diff ? saved_params.rtc_diff 269 return saved_params.rtc_diff ? saved_params.rtc_diff
270 : SECONDS_FROM_1970_TO_2000; 270 : SECONDS_FROM_1970_TO_2000;
271} 271}
272 272
273/** 273/**
274 * ps3_os_area_set_rtc_diff - Set the rtc diff value.
275 *
276 * An asynchronous write is needed to support writing updates from
277 * the timer interrupt context.
278 */
279
280void ps3_os_area_set_rtc_diff(u64 rtc_diff)
281{
282 if (saved_params.rtc_diff != rtc_diff) {
283 saved_params.rtc_diff = rtc_diff;
284 os_area_queue_work();
285 }
286}
287
288/**
274 * ps3_os_area_get_av_multi_out - Returns the default video mode. 289 * ps3_os_area_get_av_multi_out - Returns the default video mode.
275 */ 290 */
276 291
diff --git a/arch/powerpc/platforms/ps3/platform.h b/arch/powerpc/platforms/ps3/platform.h
index 9109c313e492..6b4f4dd2d15a 100644
--- a/arch/powerpc/platforms/ps3/platform.h
+++ b/arch/powerpc/platforms/ps3/platform.h
@@ -63,7 +63,8 @@ int ps3_set_rtc_time(struct rtc_time *time);
63/* os area */ 63/* os area */
64 64
65void __init ps3_os_area_save_params(void); 65void __init ps3_os_area_save_params(void);
66u64 ps3_os_area_rtc_diff(void); 66u64 ps3_os_area_get_rtc_diff(void);
67void ps3_os_area_set_rtc_diff(u64 rtc_diff);
67 68
68/* spu */ 69/* spu */
69 70
diff --git a/arch/powerpc/platforms/ps3/time.c b/arch/powerpc/platforms/ps3/time.c
index 802a9ccacb5e..d0daf7d6d3b2 100644
--- a/arch/powerpc/platforms/ps3/time.c
+++ b/arch/powerpc/platforms/ps3/time.c
@@ -50,12 +50,6 @@ static void __maybe_unused _dump_time(int time, const char *func,
50 _dump_tm(&tm, func, line); 50 _dump_tm(&tm, func, line);
51} 51}
52 52
53/**
54 * rtc_shift - Difference in seconds between 1970 and the ps3 rtc value.
55 */
56
57static s64 rtc_shift;
58
59void __init ps3_calibrate_decr(void) 53void __init ps3_calibrate_decr(void)
60{ 54{
61 int result; 55 int result;
@@ -66,8 +60,6 @@ void __init ps3_calibrate_decr(void)
66 60
67 ppc_tb_freq = tmp; 61 ppc_tb_freq = tmp;
68 ppc_proc_freq = ppc_tb_freq * 40; 62 ppc_proc_freq = ppc_tb_freq * 40;
69
70 rtc_shift = ps3_os_area_rtc_diff();
71} 63}
72 64
73static u64 read_rtc(void) 65static u64 read_rtc(void)
@@ -87,18 +79,18 @@ int ps3_set_rtc_time(struct rtc_time *tm)
87 u64 now = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, 79 u64 now = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
88 tm->tm_hour, tm->tm_min, tm->tm_sec); 80 tm->tm_hour, tm->tm_min, tm->tm_sec);
89 81
90 rtc_shift = now - read_rtc(); 82 ps3_os_area_set_rtc_diff(now - read_rtc());
91 return 0; 83 return 0;
92} 84}
93 85
94void ps3_get_rtc_time(struct rtc_time *tm) 86void ps3_get_rtc_time(struct rtc_time *tm)
95{ 87{
96 to_tm(read_rtc() + rtc_shift, tm); 88 to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm);
97 tm->tm_year -= 1900; 89 tm->tm_year -= 1900;
98 tm->tm_mon -= 1; 90 tm->tm_mon -= 1;
99} 91}
100 92
101unsigned long __init ps3_get_boot_time(void) 93unsigned long __init ps3_get_boot_time(void)
102{ 94{
103 return read_rtc() + rtc_shift; 95 return read_rtc() + ps3_os_area_get_rtc_diff();
104} 96}