2006-11-23 06:46:51 +07:00
|
|
|
/*
|
|
|
|
* 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>
|
2009-02-24 20:04:20 +07:00
|
|
|
#include <linux/platform_device.h>
|
2016-05-31 01:58:01 +07:00
|
|
|
#include <linux/rtc.h>
|
2006-11-23 06:46:51 +07:00
|
|
|
|
2009-08-24 05:54:32 +07:00
|
|
|
#include <asm/firmware.h>
|
2006-11-23 06:46:51 +07:00
|
|
|
#include <asm/lv1call.h>
|
|
|
|
#include <asm/ps3.h>
|
|
|
|
|
|
|
|
#include "platform.h"
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-04-23 15:36:40 +07:00
|
|
|
time64_t __init ps3_get_boot_time(void)
|
2006-11-23 06:46:51 +07:00
|
|
|
{
|
2009-02-24 20:04:20 +07:00
|
|
|
return read_rtc() + ps3_os_area_get_rtc_diff();
|
2006-11-23 06:46:51 +07:00
|
|
|
}
|
|
|
|
|
2009-02-24 20:04:20 +07:00
|
|
|
static int __init ps3_rtc_init(void)
|
2006-11-23 06:46:51 +07:00
|
|
|
{
|
2009-02-24 20:04:20 +07:00
|
|
|
struct platform_device *pdev;
|
2006-11-23 06:46:51 +07:00
|
|
|
|
2009-08-24 05:54:32 +07:00
|
|
|
if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2009-02-24 20:04:20 +07:00
|
|
|
pdev = platform_device_register_simple("rtc-ps3", -1, NULL, 0);
|
|
|
|
|
2013-07-15 08:50:32 +07:00
|
|
|
return PTR_ERR_OR_ZERO(pdev);
|
2006-11-23 06:46:51 +07:00
|
|
|
}
|
2015-05-02 07:05:49 +07:00
|
|
|
device_initcall(ps3_rtc_init);
|