public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Cc: sjg@chromium.org, trini@konsulko.com,
	Patrick Delaunay <patrick.delaunay@st.com>,
	Jun Nie <jun.nie@linaro.org>, Shawn Guo <shawn.guo@linaro.org>,
	Fabio Estevam <festevam@denx.de>, Stefano Babic <sbabic@denx.de>,
	Michal Simek <michal.simek@xilinx.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Christian Gmeiner <christian.gmeiner@gmail.com>,
	Dario Binacchi <dariobin@libero.it>,
	Kever Yang <kever.yang@rock-chips.com>,
	Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Subject: [PATCH 10/10] bootstage/timer: Treewide remove timer_get_boot_us()
Date: Wed, 21 Sep 2022 16:06:25 +0200	[thread overview]
Message-ID: <20220921140625.999002-11-sr@denx.de> (raw)
In-Reply-To: <20220921140625.999002-1-sr@denx.de>

With the bootstage migration to timer_get_us() provided via
CONFIG_TIMER_EARLY timer_get_boot_us() is superfluous now. This patch
removes all occurances from the code.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Jun Nie <jun.nie@linaro.org>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: Dario Binacchi <dariobin@libero.it>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---
 arch/arm/cpu/armv7/arch_timer.c    |  9 ------
 arch/arm/cpu/armv8/generic_timer.c |  7 -----
 arch/arm/mach-imx/syscounter.c     |  8 ------
 arch/sandbox/cpu/cpu.c             | 11 -------
 drivers/timer/cadence-ttc.c        | 22 --------------
 drivers/timer/omap-timer.c         | 22 --------------
 drivers/timer/orion-timer.c        |  8 ------
 drivers/timer/rockchip_timer.c     | 46 ------------------------------
 drivers/timer/tsc_timer.c          |  5 ----
 lib/time.c                         | 20 -------------
 10 files changed, 158 deletions(-)

diff --git a/arch/arm/cpu/armv7/arch_timer.c b/arch/arm/cpu/armv7/arch_timer.c
index 80cfaf2d09a4..375b7e2797ef 100644
--- a/arch/arm/cpu/armv7/arch_timer.c
+++ b/arch/arm/cpu/armv7/arch_timer.c
@@ -49,15 +49,6 @@ unsigned long long get_ticks(void)
 	return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
 }
 
-
-ulong timer_get_boot_us(void)
-{
-	if (!gd->arch.timer_rate_hz)
-		timer_init();
-
-	return lldiv(get_ticks(), gd->arch.timer_rate_hz / 1000000);
-}
-
 ulong get_tbclk(void)
 {
 	return gd->arch.timer_rate_hz;
diff --git a/arch/arm/cpu/armv8/generic_timer.c b/arch/arm/cpu/armv8/generic_timer.c
index 01a1a167311e..680c547eaf7d 100644
--- a/arch/arm/cpu/armv8/generic_timer.c
+++ b/arch/arm/cpu/armv8/generic_timer.c
@@ -109,13 +109,6 @@ unsigned long usec2ticks(unsigned long usec)
 	return ticks;
 }
 
-ulong timer_get_boot_us(void)
-{
-	u64 val = get_ticks() * 1000000;
-
-	return val / get_tbclk();
-}
-
 unsigned long notrace timer_early_get_rate(void)
 {
 	return get_tbclk();
diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c
index dbe55ee3913d..d592329c163e 100644
--- a/arch/arm/mach-imx/syscounter.c
+++ b/arch/arm/mach-imx/syscounter.c
@@ -101,14 +101,6 @@ ulong get_timer(ulong base)
 	return tick_to_time(get_ticks()) - base;
 }
 
-ulong timer_get_boot_us(void)
-{
-	if (!gd->arch.timer_rate_hz)
-		timer_init();
-
-	return tick_to_time(get_ticks());
-}
-
 unsigned long notrace timer_early_get_rate(void)
 {
 	if (!gd->arch.timer_rate_hz)
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index d077948dd7bd..9c99839a1044 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -362,14 +362,3 @@ done:
 fail:
 	return NULL;
 }
-
-ulong timer_get_boot_us(void)
-{
-	static uint64_t base_count;
-	uint64_t count = os_get_nsec();
-
-	if (!base_count)
-		base_count = count;
-
-	return (count - base_count) / 1000;
-}
diff --git a/drivers/timer/cadence-ttc.c b/drivers/timer/cadence-ttc.c
index e26c7923a140..39b97825318b 100644
--- a/drivers/timer/cadence-ttc.c
+++ b/drivers/timer/cadence-ttc.c
@@ -36,28 +36,6 @@ struct cadence_ttc_priv {
 	struct cadence_ttc_regs *regs;
 };
 
-#if CONFIG_IS_ENABLED(BOOTSTAGE)
-ulong timer_get_boot_us(void)
-{
-	u64 ticks = 0;
-	u32 rate = 1;
-	u64 us;
-	int ret;
-
-	ret = dm_timer_init();
-	if (!ret) {
-		/* The timer is available */
-		rate = timer_get_rate(gd->timer);
-		timer_get_count(gd->timer, &ticks);
-	} else {
-		return 0;
-	}
-
-	us = (ticks * 1000) / rate;
-	return us;
-}
-#endif
-
 unsigned long notrace timer_early_get_rate(void)
 {
 	return 1;
diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c
index 315dbb634aa7..c680c4487154 100644
--- a/drivers/timer/omap-timer.c
+++ b/drivers/timer/omap-timer.c
@@ -84,28 +84,6 @@ static int omap_timer_of_to_plat(struct udevice *dev)
 	return 0;
 }
 
-#if CONFIG_IS_ENABLED(BOOTSTAGE)
-ulong timer_get_boot_us(void)
-{
-	u64 ticks = 0;
-	u32 rate = 1;
-	u64 us;
-	int ret;
-
-	ret = dm_timer_init();
-	if (!ret) {
-		/* The timer is available */
-		rate = timer_get_rate(gd->timer);
-		timer_get_count(gd->timer, &ticks);
-	} else {
-		return 0;
-	}
-
-	us = (ticks * 1000) / rate;
-	return us;
-}
-#endif
-
 unsigned long notrace timer_early_get_rate(void)
 {
 	return 1;
diff --git a/drivers/timer/orion-timer.c b/drivers/timer/orion-timer.c
index d0eab3ce781d..c0eadff81cf2 100644
--- a/drivers/timer/orion-timer.c
+++ b/drivers/timer/orion-timer.c
@@ -86,14 +86,6 @@ u64 notrace timer_early_get_count(void)
 	return orion_timer_get_count((void *)MVEBU_TIMER_BASE);
 }
 
-ulong timer_get_boot_us(void)
-{
-	u64 ticks;
-
-	ticks = timer_early_get_count();
-	return lldiv(ticks * 1000, timer_early_get_rate());
-}
-
 /* DM timer functions */
 static uint64_t dm_orion_timer_get_count(struct udevice *dev)
 {
diff --git a/drivers/timer/rockchip_timer.c b/drivers/timer/rockchip_timer.c
index 6e3483edce72..7bf79d5f073e 100644
--- a/drivers/timer/rockchip_timer.c
+++ b/drivers/timer/rockchip_timer.c
@@ -41,52 +41,6 @@ static inline int64_t rockchip_timer_get_curr_value(struct rk_timer *timer)
 	return cntr;
 }
 
-#if CONFIG_IS_ENABLED(BOOTSTAGE)
-ulong timer_get_boot_us(void)
-{
-	uint64_t  ticks = 0;
-	uint32_t  rate;
-	uint64_t  us;
-	int ret;
-
-	ret = dm_timer_init();
-
-	if (!ret) {
-		/* The timer is available */
-		rate = timer_get_rate(gd->timer);
-		timer_get_count(gd->timer, &ticks);
-	} else if (CONFIG_IS_ENABLED(OF_REAL) && ret == -EAGAIN) {
-		/* We have been called so early that the DM is not ready,... */
-		ofnode node = offset_to_ofnode(-1);
-		struct rk_timer *timer = NULL;
-
-		/*
-		 * ... so we try to access the raw timer, if it is specified
-		 * via the tick-timer property in /chosen.
-		 */
-		node = ofnode_get_chosen_node("tick-timer");
-		if (!ofnode_valid(node)) {
-			debug("%s: no /chosen/tick-timer\n", __func__);
-			return 0;
-		}
-
-		timer = (struct rk_timer *)ofnode_get_addr(node);
-
-		/* This timer is down-counting */
-		ticks = ~0uLL - rockchip_timer_get_curr_value(timer);
-		if (ofnode_read_u32(node, "clock-frequency", &rate)) {
-			debug("%s: could not read clock-frequency\n", __func__);
-			return 0;
-		}
-	} else {
-		return 0;
-	}
-
-	us = (ticks * 1000) / rate;
-	return us;
-}
-#endif
-
 static u64 timer_early_get_count_rate(uint32_t *rate)
 {
 	uint64_t ticks = 0;
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index 192c7b71a5a3..3cb2abed0c67 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -363,11 +363,6 @@ ulong notrace timer_get_us(void)
 	return get_ticks() / get_tbclk_mhz();
 }
 
-ulong timer_get_boot_us(void)
-{
-	return timer_get_us();
-}
-
 void __udelay(unsigned long usec)
 {
 	u64 now = get_ticks();
diff --git a/lib/time.c b/lib/time.c
index f3aaf472d103..7492b2bd9c62 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -42,26 +42,6 @@ unsigned long notrace timer_read_counter(void)
 	return readl(CONFIG_SYS_TIMER_COUNTER);
 #endif
 }
-
-ulong timer_get_boot_us(void)
-{
-	ulong count = timer_read_counter();
-
-#ifdef CONFIG_SYS_TIMER_RATE
-	const ulong timer_rate = CONFIG_SYS_TIMER_RATE;
-
-	if (timer_rate == 1000000)
-		return count;
-	else if (timer_rate > 1000000)
-		return lldiv(count, timer_rate / 1000000);
-	else
-		return (unsigned long long)count * 1000000 / timer_rate;
-#else
-	/* Assume the counter is in microseconds */
-	return count;
-#endif
-}
-
 #else
 extern unsigned long __weak timer_read_counter(void);
 #endif
-- 
2.37.3


  parent reply	other threads:[~2022-09-21 14:08 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 14:06 [PATCH 00/10] bootstage: Migrate from timer_get_boot_us() to timer_get_us() Stefan Roese
2022-09-21 14:06 ` [PATCH 01/10] arm: arch_timer: Add timer_early functions Stefan Roese
2022-09-25 14:15   ` Simon Glass
2022-09-21 14:06 ` [PATCH 02/10] arm: imx: syscounter: " Stefan Roese
2022-09-25 14:15   ` Simon Glass
2022-09-21 14:06 ` [PATCH 03/10] arm: armv8: generic_timer: " Stefan Roese
2022-09-25 14:15   ` Simon Glass
2022-09-21 14:06 ` [PATCH 04/10] timer: cadence-ttc: " Stefan Roese
2022-09-25 14:15   ` Simon Glass
2022-09-26 14:11     ` Stefan Roese
2022-09-28  1:54       ` Simon Glass
2022-09-30 12:02         ` Michal Simek
2022-09-30 13:45           ` Stefan Roese
2022-10-04 11:49             ` Michal Simek
2022-10-04 14:54               ` Stefan Roese
2022-10-04 16:29               ` Simon Glass
2022-10-05  6:59                 ` Michal Simek
2022-09-21 14:06 ` [PATCH 05/10] timer: omap-timer: " Stefan Roese
2022-09-21 14:06 ` [PATCH 06/10] timer: rockchip_timer: " Stefan Roese
2022-09-24  7:57   ` Kever Yang
2022-09-21 14:06 ` [PATCH 07/10] board_f/r: Allow selection of CONFIG_TIMER_EARLY w/o CONFIG_TIMER Stefan Roese
2022-09-25 14:15   ` Simon Glass
2022-09-26 13:52     ` Stefan Roese
2022-09-28  1:54       ` Simon Glass
2022-09-30  5:36         ` Stefan Roese
2022-09-30 13:28           ` Simon Glass
2022-09-30 13:52             ` Stefan Roese
2022-09-21 14:06 ` [PATCH 08/10] board_f/r: Don't call timer_init() when TIMER is enabled Stefan Roese
2022-09-21 14:06 ` [PATCH 09/10] bootstage: Migrate from timer_get_boot_us() to timer_get_us() Stefan Roese
2022-09-28 10:20   ` Simon Glass
2022-09-30 11:30   ` Michal Simek
2022-09-21 14:06 ` Stefan Roese [this message]
2022-09-25 14:15   ` [PATCH 10/10] bootstage/timer: Treewide remove timer_get_boot_us() Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220921140625.999002-11-sr@denx.de \
    --to=sr@denx.de \
    --cc=andre.przywara@arm.com \
    --cc=christian.gmeiner@gmail.com \
    --cc=dariobin@libero.it \
    --cc=festevam@denx.de \
    --cc=jun.nie@linaro.org \
    --cc=kever.yang@rock-chips.com \
    --cc=michal.simek@xilinx.com \
    --cc=patrick.delaunay@st.com \
    --cc=philipp.tomsich@theobroma-systems.com \
    --cc=sbabic@denx.de \
    --cc=shawn.guo@linaro.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox