diff mbox series

[U-Boot,24/36] armv8: add timer_get_boot_us() for generic timer

Message ID 1522142971-20739-25-git-send-email-kever.yang@rock-chips.com
State Changes Requested
Delegated to: Philipp Tomsich
Headers show
Series rockchip: clean up board file for rockchip SoCs | expand

Commit Message

Kever Yang March 27, 2018, 9:29 a.m. UTC
We need timer_get_boot_us() for boot stage if we use generic timer only.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
---

 arch/arm/cpu/armv8/generic_timer.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Philipp Tomsich April 1, 2018, 8:21 p.m. UTC | #1
> We need timer_get_boot_us() for boot stage if we use generic timer only.
> 
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
> 
>  arch/arm/cpu/armv8/generic_timer.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Philipp Tomsich April 1, 2018, 9:53 p.m. UTC | #2
On Tue, 27 Mar 2018, Kever Yang wrote:

> We need timer_get_boot_us() for boot stage if we use generic timer only.
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>

See below for requested changes/questions.

> ---
>
> arch/arm/cpu/armv8/generic_timer.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm/cpu/armv8/generic_timer.c b/arch/arm/cpu/armv8/generic_timer.c
> index a2dda33..d96217e 100644
> --- a/arch/arm/cpu/armv8/generic_timer.c
> +++ b/arch/arm/cpu/armv8/generic_timer.c
> @@ -7,6 +7,7 @@
>
> #include <common.h>
> #include <command.h>
> +#include <div64.h>
> #include <asm/system.h>
>
> DECLARE_GLOBAL_DATA_PTR;
> @@ -52,6 +53,11 @@ uint64_t get_ticks(void)
> 	return ticks;
> }
>
> +ulong timer_get_boot_us(void)
> +{
> +	return lldiv(get_ticks(), CONFIG_SYS_HZ_CLOCK / (CONFIG_SYS_HZ * 1000));
> +}
> +

Can we be sure that this does never conflict with what is added by another 
timer implementation (e.g. DM_TIMER)?  If not, you may have to add some 
additional infrastructure to allow selection of what timer is the 
boot-timer.

> unsigned long usec2ticks(unsigned long usec)
> {
> 	ulong ticks;
>
diff mbox series

Patch

diff --git a/arch/arm/cpu/armv8/generic_timer.c b/arch/arm/cpu/armv8/generic_timer.c
index a2dda33..d96217e 100644
--- a/arch/arm/cpu/armv8/generic_timer.c
+++ b/arch/arm/cpu/armv8/generic_timer.c
@@ -7,6 +7,7 @@ 
 
 #include <common.h>
 #include <command.h>
+#include <div64.h>
 #include <asm/system.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -52,6 +53,11 @@  uint64_t get_ticks(void)
 	return ticks;
 }
 
+ulong timer_get_boot_us(void)
+{
+	return lldiv(get_ticks(), CONFIG_SYS_HZ_CLOCK / (CONFIG_SYS_HZ * 1000));
+}
+
 unsigned long usec2ticks(unsigned long usec)
 {
 	ulong ticks;