1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Pistachio clocksource/timer setup 4 * 5 * Copyright (C) 2014 Google, Inc. 6 */ 7 8#include <linux/clk.h> 9#include <linux/clocksource.h> 10#include <linux/init.h> 11#include <linux/of.h> 12#include <linux/of_clk.h> 13 14#include <asm/mips-cps.h> 15#include <asm/time.h> 16 17unsigned int get_c0_compare_int(void) 18{ 19 return gic_get_c0_compare_int(); 20} 21 22int get_c0_perfcount_int(void) 23{ 24 return gic_get_c0_perfcount_int(); 25} 26EXPORT_SYMBOL_GPL(get_c0_perfcount_int); 27 28int get_c0_fdc_int(void) 29{ 30 return gic_get_c0_fdc_int(); 31} 32 33void __init plat_time_init(void) 34{ 35 struct device_node *np; 36 struct clk *clk; 37 38 of_clk_init(NULL); 39 timer_probe(); 40 41 np = of_get_cpu_node(0, NULL); 42 if (!np) { 43 pr_err("Failed to get CPU node\n"); 44 return; 45 } 46 47 clk = of_clk_get(np, 0); 48 if (IS_ERR(clk)) { 49 pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk)); 50 return; 51 } 52 53 mips_hpt_frequency = clk_get_rate(clk) / 2; 54 clk_put(clk); 55} 56