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