2019-06-03 12:44:50 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-03-05 18:49:30 +07: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-30 00:16:54 +07:00
|
|
|
#include <linux/clockchips.h>
|
2012-03-05 18:49:30 +07: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 17:06:00 +07:00
|
|
|
#include <linux/delay.h>
|
2013-04-11 06:27:51 +07:00
|
|
|
#include <linux/clocksource.h>
|
2014-04-14 14:38:53 +07:00
|
|
|
#include <linux/clk-provider.h>
|
2015-03-24 21:02:50 +07:00
|
|
|
#include <linux/acpi.h>
|
2012-03-05 18:49:30 +07:00
|
|
|
|
2012-11-20 17:06:00 +07:00
|
|
|
#include <clocksource/arm_arch_timer.h>
|
2012-03-05 18:49:30 +07:00
|
|
|
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
#include <asm/stacktrace.h>
|
2019-10-21 22:28:23 +07:00
|
|
|
#include <asm/paravirt.h>
|
2012-03-05 18:49:30 +07:00
|
|
|
|
|
|
|
unsigned long profile_pc(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
struct stackframe frame;
|
|
|
|
|
|
|
|
if (!in_lock_functions(regs->pc))
|
|
|
|
return regs->pc;
|
|
|
|
|
2019-07-02 20:07:28 +07:00
|
|
|
start_backtrace(&frame, regs->regs[29], regs->pc);
|
|
|
|
|
2012-03-05 18:49:30 +07:00
|
|
|
do {
|
2015-12-15 15:33:40 +07:00
|
|
|
int ret = unwind_frame(NULL, &frame);
|
2012-03-05 18:49:30 +07: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 17:06:00 +07:00
|
|
|
u32 arch_timer_rate;
|
|
|
|
|
2014-04-14 14:38:53 +07:00
|
|
|
of_clk_init(NULL);
|
2017-05-26 22:40:46 +07:00
|
|
|
timer_probe();
|
2012-11-20 17:06:00 +07:00
|
|
|
|
2014-05-30 00:16:54 +07:00
|
|
|
tick_setup_hrtimer_broadcast();
|
|
|
|
|
2012-11-20 17:06:00 +07:00
|
|
|
arch_timer_rate = arch_timer_get_rate();
|
2013-04-11 06:27:51 +07:00
|
|
|
if (!arch_timer_rate)
|
|
|
|
panic("Unable to initialise architected timer.\n");
|
2012-11-20 17:06:00 +07:00
|
|
|
|
|
|
|
/* Calibrate the delay loop directly */
|
|
|
|
lpj_fine = arch_timer_rate / HZ;
|
2019-10-21 22:28:23 +07:00
|
|
|
|
|
|
|
pv_time_init();
|
2012-03-05 18:49:30 +07:00
|
|
|
}
|