1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
* PS3 time and rtc routines.
*
* Copyright (C) 2006 Sony Computer Entertainment Inc.
* Copyright 2006 Sony Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <asm/rtc.h>
#include <asm/lv1call.h>
#include <asm/ps3.h>
#include "platform.h"
#define dump_tm(_a) _dump_tm(_a, __func__, __LINE__)
static void _dump_tm(const struct rtc_time *tm, const char* func, int line)
{
pr_debug("%s:%d tm_sec %d\n", func, line, tm->tm_sec);
pr_debug("%s:%d tm_min %d\n", func, line, tm->tm_min);
pr_debug("%s:%d tm_hour %d\n", func, line, tm->tm_hour);
pr_debug("%s:%d tm_mday %d\n", func, line, tm->tm_mday);
pr_debug("%s:%d tm_mon %d\n", func, line, tm->tm_mon);
pr_debug("%s:%d tm_year %d\n", func, line, tm->tm_year);
pr_debug("%s:%d tm_wday %d\n", func, line, tm->tm_wday);
}
#define dump_time(_a) _dump_time(_a, __func__, __LINE__)
static void __attribute__ ((unused)) _dump_time(int time, const char* func,
int line)
{
struct rtc_time tm;
to_tm(time, &tm);
pr_debug("%s:%d time %d\n", func, line, time);
_dump_tm(&tm, func, line);
}
/**
* rtc_shift - Difference in seconds between 1970 and the ps3 rtc value.
*/
static s64 rtc_shift;
void __init ps3_calibrate_decr(void)
{
int result;
u64 tmp;
result = ps3_repository_read_be_tb_freq(0, &tmp);
BUG_ON(result);
ppc_tb_freq = tmp;
ppc_proc_freq = ppc_tb_freq * 40;
rtc_shift = ps3_os_area_rtc_diff();
}
static u64 read_rtc(void)
{
int result;
u64 rtc_val;
u64 tb_val;
result = lv1_get_rtc(&rtc_val, &tb_val);
BUG_ON(result);
return rtc_val;
}
int ps3_set_rtc_time(struct rtc_time *tm)
{
u64 now = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
rtc_shift = now - read_rtc();
return 0;
}
void ps3_get_rtc_time(struct rtc_time *tm)
{
to_tm(read_rtc() + rtc_shift, tm);
tm->tm_year -= 1900;
tm->tm_mon -= 1;
}
unsigned long __init ps3_get_boot_time(void)
{
return read_rtc() + rtc_shift;
}
|