printk: auto adapt arch_timer_rate for CONFIG_PRINTK_TIME_FROM_ARM_ARCH_TIMER

Signed-off-by: Liang Chen <cl@rock-chips.com>
Change-Id: I0e9ec4b4872bb3ca7ae066a3c894dd47206040f2
This commit is contained in:
Liang Chen
2024-04-23 18:54:14 +08:00
parent 87b51e9bdb
commit 40b5dbb463

View File

@@ -61,13 +61,23 @@
#include "internal.h"
#ifdef CONFIG_PRINTK_TIME_FROM_ARM_ARCH_TIMER
#include <clocksource/arm_arch_timer.h>
#include <asm/arch_timer.h>
static u64 get_local_clock(void)
{
u64 ns;
static u32 mhz;
if (!mhz) {
mhz = arch_timer_get_cntfrq() / 1000000;
if (!mhz)
mhz = 24;
}
if (mhz == 1000)
return arch_timer_read_counter();
ns = arch_timer_read_counter() * 1000;
do_div(ns, 24);
do_div(ns, mhz);
return ns;
}