[PATCH v2 3/8] timer: orion-timer: Add timer_get_boot_us() for BOOTSTAGE support

Tony Dinh mibodhi at gmail.com
Sat Sep 3 11:44:21 CEST 2022


Hi Stefan,

On Thu, Sep 1, 2022 at 11:25 PM Stefan Roese <sr at denx.de> wrote:
>
> Add timer_get_boot_us() to support boards, that have CONFIG_BOOTSTAGE
> enabled, like pogo_v4.
>
> Signed-off-by: Stefan Roese <sr at denx.de>
> ---
> v2:
> - Change timer_get_boot_us() to use the timer_early functions
> - Remove #if CONFIG_IS_ENABLED(BOOTSTAGE)
>
> Simon, I'm currently looking into this timer_get_boot_us() to using
> timer_early_get_count() etc consolidation.

Indeed, as you've mentioned above, I think timer_early_get_count() and
timer_early_get_rate() do need to take into consideration  what the
input_clock_type is for Kirkwood boards with CONFIG_BOOTSTAGE such as
the Pogo V4.

I'm seeing on the Pogo V4 test, the timer command reports time about 6
times slower than it should. It does seem to jive with the fact that
the Pogo V4 CONFIG_SYS_TCLK is 166Mhz, versus MVEBU 25MHz clock rate.

All the best,
Tony


>
>  drivers/timer/orion-timer.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/timer/orion-timer.c b/drivers/timer/orion-timer.c
> index 14f318e57d4d..6c0b8550412d 100644
> --- a/drivers/timer/orion-timer.c
> +++ b/drivers/timer/orion-timer.c
> @@ -1,6 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  #include <asm/io.h>
>  #include <common.h>
> +#include <div64.h>
>  #include <dm/device.h>
>  #include <dm/fdtaddr.h>
>  #include <timer.h>
> @@ -39,6 +40,14 @@ u64 notrace timer_early_get_count(void)
>         return timer_conv_64(~readl(MVEBU_TIMER_BASE + TIMER0_VAL));
>  }
>
> +ulong timer_get_boot_us(void)
> +{
> +       u64 ticks;
> +
> +       ticks = timer_early_get_count();
> +       return lldiv(ticks * 1000, timer_early_get_rate());
> +}
> +
>  static uint64_t orion_timer_get_count(struct udevice *dev)
>  {
>         struct orion_timer_priv *priv = dev_get_priv(dev);
> --
> 2.37.3
>


More information about the U-Boot mailing list