blob: cbb3fca7b6fa32c1f8e3867e080c0d34ca3f15e8 [file] [log] [blame]
Zubair Lutfullah Kakakhel9937f5f2015-10-26 11:30:56 +00001/*
2 * Xilfpga clocksource/timer setup
3 *
4 * Copyright (C) 2015 Imagination Technologies
5 * Author: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 */
11
12#include <linux/clk.h>
13#include <linux/clk-provider.h>
14#include <linux/clocksource.h>
15#include <linux/of.h>
16
17#include <asm/time.h>
18
19void __init plat_time_init(void)
20{
21 struct device_node *np;
22 struct clk *clk;
23
24 of_clk_init(NULL);
Linus Torvaldsb84da9f2015-11-15 09:10:53 -080025 clocksource_probe();
Zubair Lutfullah Kakakhel9937f5f2015-10-26 11:30:56 +000026
27 np = of_get_cpu_node(0, NULL);
28 if (!np) {
29 pr_err("Failed to get CPU node\n");
30 return;
31 }
32
33 clk = of_clk_get(np, 0);
34 if (IS_ERR(clk)) {
35 pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
36 return;
37 }
38
39 mips_hpt_frequency = clk_get_rate(clk) / 2;
40 clk_put(clk);
41}