From patchwork Wed Jan 8 03:01:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weijie Gao X-Patchwork-Id: 239234 List-Id: U-Boot discussion From: weijie.gao at mediatek.com (Weijie Gao) Date: Wed, 8 Jan 2020 11:01:09 +0800 Subject: [PATCH 04/16] mips: add an option to support customized get_tbclk() Message-ID: <1578452469-6831-1-git-send-email-weijie.gao@mediatek.com> Some systems boot up at a very low CPU frequency and set up a higher CPU frequency in lowlevel initialization. Currently get_tbclk() uses a fixed value (CONFIG_SYS_MIPS_TIMER_FREQ) for MIPS architercture, and CONFIG_SYS_MIPS_TIMER_FREQ is usually related to the higher CPU frequency. If udelay() is used before setting up CPU frequency, it will be very inaccurate. This patch adds an option to allow a mach to define its own get_tbclk(). Signed-off-by: Weijie Gao --- arch/mips/Kconfig | 8 ++++++++ arch/mips/cpu/time.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 4688717593..52afbf79c5 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -502,6 +502,14 @@ config MIPS_BOOT_CONFIG_WORD1 help Value which is inserted as boot config word 1. +config MIPS_OVERRIDE_GET_TBCLK + bool + default n + help + Select this if you want to override the default get_tbclk() for your + system. This usually means the timer frequency of your system may + change in different boot stage. + endif endmenu diff --git a/arch/mips/cpu/time.c b/arch/mips/cpu/time.c index af324f77ce..61d1cd9ec0 100644 --- a/arch/mips/cpu/time.c +++ b/arch/mips/cpu/time.c @@ -12,7 +12,9 @@ unsigned long notrace timer_read_counter(void) return read_c0_count(); } +#ifndef CONFIG_MIPS_OVERRIDE_GET_TBCLK ulong notrace get_tbclk(void) { return CONFIG_SYS_MIPS_TIMER_FREQ; } +#endif