2019-06-03 05:44:50 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-03-05 11:49:30 +00:00
|
|
|
/*
|
|
|
|
* Based on arch/arm/kernel/time.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1991, 1992, 1995 Linus Torvalds
|
|
|
|
* Modifications for ARM (C) 1994-2001 Russell King
|
|
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
|
|
*/
|
|
|
|
|
2014-05-29 17:16:54 +00:00
|
|
|
#include <linux/clockchips.h>
|
2012-03-05 11:49:30 +00:00
|
|
|
#include <linux/export.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/timex.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/profile.h>
|
|
|
|
#include <linux/syscore_ops.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/irq.h>
|
2012-11-20 10:06:00 +00:00
|
|
|
#include <linux/delay.h>
|
2013-04-10 23:27:51 +00:00
|
|
|
#include <linux/clocksource.h>
|
2020-02-12 10:09:34 +00:00
|
|
|
#include <linux/of_clk.h>
|
2015-03-24 14:02:50 +00:00
|
|
|
#include <linux/acpi.h>
|
2012-03-05 11:49:30 +00:00
|
|
|
|
2012-11-20 10:06:00 +00:00
|
|
|
#include <clocksource/arm_arch_timer.h>
|
2012-03-05 11:49:30 +00:00
|
|
|
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
#include <asm/stacktrace.h>
|
2019-10-21 15:28:23 +00:00
|
|
|
#include <asm/paravirt.h>
|
2012-03-05 11:49:30 +00:00
|
|
|
|
|
|
|
unsigned long profile_pc(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
struct stackframe frame;
|
|
|
|
|
|
|
|
if (!in_lock_functions(regs->pc))
|
|
|
|
return regs->pc;
|
|
|
|
|
2019-07-02 13:07:28 +00:00
|
|
|
start_backtrace(&frame, regs->regs[29], regs->pc);
|
|
|
|
|
2012-03-05 11:49:30 +00:00
|
|
|
do {
|
2015-12-15 08:33:40 +00:00
|
|
|
int ret = unwind_frame(NULL, &frame);
|
2012-03-05 11:49:30 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return 0;
|
|
|
|
} while (in_lock_functions(frame.pc));
|
|
|
|
|
|
|
|
return frame.pc;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(profile_pc);
|
|
|
|
|
|
|
|
void __init time_init(void)
|
|
|
|
{
|
2012-11-20 10:06:00 +00:00
|
|
|
u32 arch_timer_rate;
|
|
|
|
|
2014-04-14 07:38:53 +00:00
|
|
|
of_clk_init(NULL);
|
2017-05-26 15:40:46 +00:00
|
|
|
timer_probe();
|
2012-11-20 10:06:00 +00:00
|
|
|
|
2014-05-29 17:16:54 +00:00
|
|
|
tick_setup_hrtimer_broadcast();
|
|
|
|
|
2012-11-20 10:06:00 +00:00
|
|
|
arch_timer_rate = arch_timer_get_rate();
|
2013-04-10 23:27:51 +00:00
|
|
|
if (!arch_timer_rate)
|
|
|
|
panic("Unable to initialise architected timer.\n");
|
2012-11-20 10:06:00 +00:00
|
|
|
|
|
|
|
/* Calibrate the delay loop directly */
|
|
|
|
lpj_fine = arch_timer_rate / HZ;
|
2019-10-21 15:28:23 +00:00
|
|
|
|
|
|
|
pv_time_init();
|
2012-03-05 11:49:30 +00:00
|
|
|
}
|