Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
0004  * Author: Fuxin Zhang, zhangfx@lemote.com
0005  *
0006  * Copyright (C) 2009 Lemote Inc.
0007  * Author: Wu Zhangjin, wuzhangjin@gmail.com
0008  */
0009 
0010 #include <asm/time.h>
0011 #include <asm/hpet.h>
0012 
0013 #include <loongson.h>
0014 #include <linux/clk.h>
0015 #include <linux/of_clk.h>
0016 
0017 void __init plat_time_init(void)
0018 {
0019     struct clk *clk;
0020     struct device_node *np;
0021 
0022     if (loongson_sysconf.fw_interface == LOONGSON_DTB) {
0023         of_clk_init(NULL);
0024 
0025         np = of_get_cpu_node(0, NULL);
0026         if (!np) {
0027             pr_err("Failed to get CPU node\n");
0028             return;
0029         }
0030 
0031         clk = of_clk_get(np, 0);
0032         if (IS_ERR(clk)) {
0033             pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
0034             return;
0035         }
0036 
0037         cpu_clock_freq = clk_get_rate(clk);
0038         clk_put(clk);
0039     }
0040 
0041     /* setup mips r4k timer */
0042     mips_hpt_frequency = cpu_clock_freq / 2;
0043 
0044 #ifdef CONFIG_RS780_HPET
0045     setup_hpet_timer();
0046 #endif
0047 }