Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  PS3 time and rtc routines.
0004  *
0005  *  Copyright (C) 2006 Sony Computer Entertainment Inc.
0006  *  Copyright 2006 Sony Corp.
0007  */
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/platform_device.h>
0011 #include <linux/rtc.h>
0012 
0013 #include <asm/firmware.h>
0014 #include <asm/lv1call.h>
0015 #include <asm/ps3.h>
0016 
0017 #include "platform.h"
0018 
0019 void __init ps3_calibrate_decr(void)
0020 {
0021     int result;
0022     u64 tmp;
0023 
0024     result = ps3_repository_read_be_tb_freq(0, &tmp);
0025     BUG_ON(result);
0026 
0027     ppc_tb_freq = tmp;
0028     ppc_proc_freq = ppc_tb_freq * 40;
0029 }
0030 
0031 static u64 read_rtc(void)
0032 {
0033     int result;
0034     u64 rtc_val;
0035     u64 tb_val;
0036 
0037     result = lv1_get_rtc(&rtc_val, &tb_val);
0038     BUG_ON(result);
0039 
0040     return rtc_val;
0041 }
0042 
0043 time64_t __init ps3_get_boot_time(void)
0044 {
0045     return read_rtc() + ps3_os_area_get_rtc_diff();
0046 }
0047 
0048 static int __init ps3_rtc_init(void)
0049 {
0050     struct platform_device *pdev;
0051 
0052     if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
0053         return -ENODEV;
0054 
0055     pdev = platform_device_register_simple("rtc-ps3", -1, NULL, 0);
0056 
0057     return PTR_ERR_OR_ZERO(pdev);
0058 }
0059 device_initcall(ps3_rtc_init);