public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer
@ 2015-07-22 22:56 Stephen Warren
  2015-07-23 20:18 ` Simon Glass
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Stephen Warren @ 2015-07-22 22:56 UTC (permalink / raw)
  To: u-boot

From: Thierry Reding <treding@nvidia.com>

Some SoCs come with a custom timer interface, so allow them to use that
instead.

swarren notes: I did consider reworking this patch so the Makefile only
compiles generic_timer.c ifndef CONFIG_SYS_TIMER_COUNTER. However, I can
foresee a time where generic_timer.c contains both routines to implement
U-Boot's internal timer, and to perform other operations related to the
generic timer, such as initializing the CNTFRQ register for a booted OS.
If that happens, this version of the change will result in simpler future
patches.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/cpu/armv8/generic_timer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/cpu/armv8/generic_timer.c b/arch/arm/cpu/armv8/generic_timer.c
index 8e60baebc534..98a865cf6ffc 100644
--- a/arch/arm/cpu/armv8/generic_timer.c
+++ b/arch/arm/cpu/armv8/generic_timer.c
@@ -9,6 +9,7 @@
 #include <command.h>
 #include <asm/system.h>
 
+#ifndef CONFIG_SYS_TIMER_COUNTER
 /*
  * Generic timer implementation of get_tbclk()
  */
@@ -40,3 +41,4 @@ unsigned long timer_read_counter(void)
 #endif
 	return cntpct;
 }
+#endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer
  2015-07-22 22:56 [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer Stephen Warren
@ 2015-07-23 20:18 ` Simon Glass
  2015-07-23 20:54 ` Tom Rini
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2015-07-23 20:18 UTC (permalink / raw)
  To: u-boot

On 22 July 2015 at 16:56, Stephen Warren <swarren@wwwdotorg.org> wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Some SoCs come with a custom timer interface, so allow them to use that
> instead.
>
> swarren notes: I did consider reworking this patch so the Makefile only
> compiles generic_timer.c ifndef CONFIG_SYS_TIMER_COUNTER. However, I can
> foresee a time where generic_timer.c contains both routines to implement
> U-Boot's internal timer, and to perform other operations related to the
> generic timer, such as initializing the CNTFRQ register for a booted OS.
> If that happens, this version of the change will result in simpler future
> patches.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> Signed-off-by: Tom Warren <twarren@nvidia.com>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  arch/arm/cpu/armv8/generic_timer.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer
  2015-07-22 22:56 [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer Stephen Warren
  2015-07-23 20:18 ` Simon Glass
@ 2015-07-23 20:54 ` Tom Rini
  2015-07-28  9:33 ` Thierry Reding
  2015-07-28  9:35 ` [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier Thierry Reding
  3 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2015-07-23 20:54 UTC (permalink / raw)
  To: u-boot

On Wed, Jul 22, 2015 at 04:56:10PM -0600, Stephen Warren wrote:

> From: Thierry Reding <treding@nvidia.com>
> 
> Some SoCs come with a custom timer interface, so allow them to use that
> instead.
> 
> swarren notes: I did consider reworking this patch so the Makefile only
> compiles generic_timer.c ifndef CONFIG_SYS_TIMER_COUNTER. However, I can
> foresee a time where generic_timer.c contains both routines to implement
> U-Boot's internal timer, and to perform other operations related to the
> generic timer, such as initializing the CNTFRQ register for a booted OS.
> If that happens, this version of the change will result in simpler future
> patches.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> Signed-off-by: Tom Warren <twarren@nvidia.com>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

Reviewed-by: Tom Rini <trini@konsulko.com>



> -- 
> 1.9.1
> 

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150723/2abb6de4/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer
  2015-07-22 22:56 [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer Stephen Warren
  2015-07-23 20:18 ` Simon Glass
  2015-07-23 20:54 ` Tom Rini
@ 2015-07-28  9:33 ` Thierry Reding
  2015-07-28  9:35 ` [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier Thierry Reding
  3 siblings, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2015-07-28  9:33 UTC (permalink / raw)
  To: u-boot

On Wed, Jul 22, 2015 at 04:56:10PM -0600, Stephen Warren wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Some SoCs come with a custom timer interface, so allow them to use that
> instead.
> 
> swarren notes: I did consider reworking this patch so the Makefile only
> compiles generic_timer.c ifndef CONFIG_SYS_TIMER_COUNTER. However, I can
> foresee a time where generic_timer.c contains both routines to implement
> U-Boot's internal timer, and to perform other operations related to the
> generic timer, such as initializing the CNTFRQ register for a booted OS.
> If that happens, this version of the change will result in simpler future
> patches.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> Signed-off-by: Tom Warren <twarren@nvidia.com>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  arch/arm/cpu/armv8/generic_timer.c | 2 ++
>  1 file changed, 2 insertions(+)

Marc Zyngier and David Feng had objections to this when I posted[0]. I
ended up solving this differently, by initializing the architectural
timer earlier and then using the architected timer on ARM64.

I'll post the two patches I have in my tree as a replacement for this
and sorry for causing such a mess.

Thierry

[0]: http://lists.denx.de/pipermail/u-boot/2015-March/208505.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150728/74770271/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier
  2015-07-22 22:56 [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer Stephen Warren
                   ` (2 preceding siblings ...)
  2015-07-28  9:33 ` Thierry Reding
@ 2015-07-28  9:35 ` Thierry Reding
  2015-07-28  9:35   ` [U-Boot] [PATCH 2/2] ARM: tegra: Use architected timer on ARMv8 Thierry Reding
  2015-07-28 16:08   ` [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier Stephen Warren
  3 siblings, 2 replies; 8+ messages in thread
From: Thierry Reding @ 2015-07-28  9:35 UTC (permalink / raw)
  To: u-boot

From: Thierry Reding <treding@nvidia.com>

A subsequent patch will enable the use of the architected timer on
ARMv8. Doing so implies that udelay() will be backed by this timer
implementation, and hence the architected timer must be ready when
udelay() is first called. The first time udelay() is used is while
resetting the debug UART, which happens very early. Make sure that
arch_timer_init() is called before that.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 arch/arm/mach-tegra/board2.c | 6 ++++++
 arch/arm/mach-tegra/clock.c  | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index 82a8a3c08959..f76fcbec5a7d 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -218,6 +218,12 @@ void gpio_early_init(void) __attribute__((weak, alias("__gpio_early_init")));
 
 int board_early_init_f(void)
 {
+	/* Do any special system timer/TSC setup */
+#if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
+	if (!tegra_cpu_is_non_secure())
+#endif
+		arch_timer_init();
+
 	pinmux_init();
 	board_init_uart_f();
 
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 0e0f7431b2fb..551ce88960e3 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -618,12 +618,6 @@ void clock_init(void)
 	debug("PLLC = %d\n", pll_rate[CLOCK_ID_CGENERAL]);
 	debug("PLLD = %d\n", pll_rate[CLOCK_ID_DISPLAY]);
 	debug("PLLX = %d\n", pll_rate[CLOCK_ID_XCPU]);
-
-	/* Do any special system timer/TSC setup */
-#if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
-	if (!tegra_cpu_is_non_secure())
-#endif
-		arch_timer_init();
 }
 
 static void set_avp_clock_source(u32 src)
-- 
2.4.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: tegra: Use architected timer on ARMv8
  2015-07-28  9:35 ` [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier Thierry Reding
@ 2015-07-28  9:35   ` Thierry Reding
  2015-08-02 21:29     ` Simon Glass
  2015-07-28 16:08   ` [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier Stephen Warren
  1 sibling, 1 reply; 8+ messages in thread
From: Thierry Reding @ 2015-07-28  9:35 UTC (permalink / raw)
  To: u-boot

From: Thierry Reding <treding@nvidia.com>

ARMv8 requires an architected timer to be present, so it can be used
instead of the Tegra US timer. This allows for better code reuse.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 include/configs/tegra-common.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/configs/tegra-common.h b/include/configs/tegra-common.h
index 7b4c0d70636e..62b047115343 100644
--- a/include/configs/tegra-common.h
+++ b/include/configs/tegra-common.h
@@ -18,8 +18,11 @@
 
 #include <asm/arch/tegra.h>		/* get chip and board defs */
 
+/* Use the Tegra US timer on ARMv7, but the architected timer on ARMv8. */
+#ifndef CONFIG_ARM64
 #define CONFIG_SYS_TIMER_RATE		1000000
 #define CONFIG_SYS_TIMER_COUNTER	NV_PA_TMRUS_BASE
+#endif
 
 /*
  * Display CPU and Board information
-- 
2.4.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier
  2015-07-28  9:35 ` [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier Thierry Reding
  2015-07-28  9:35   ` [U-Boot] [PATCH 2/2] ARM: tegra: Use architected timer on ARMv8 Thierry Reding
@ 2015-07-28 16:08   ` Stephen Warren
  1 sibling, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2015-07-28 16:08 UTC (permalink / raw)
  To: u-boot

On 07/28/2015 03:35 AM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> A subsequent patch will enable the use of the architected timer on
> ARMv8. Doing so implies that udelay() will be backed by this timer
> implementation, and hence the architected timer must be ready when
> udelay() is first called. The first time udelay() is used is while
> resetting the debug UART, which happens very early. Make sure that
> arch_timer_init() is called before that.

The series,
Acked-by: Stephen Warren <swarren@nvidia.com>

Again I've tested these in the context of a downstream/L4T version of 
U-Boot and they worked out fine. However since I haven't tested the 
exact upstream code-base, I won't give a Tested-by tag.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: tegra: Use architected timer on ARMv8
  2015-07-28  9:35   ` [U-Boot] [PATCH 2/2] ARM: tegra: Use architected timer on ARMv8 Thierry Reding
@ 2015-08-02 21:29     ` Simon Glass
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2015-08-02 21:29 UTC (permalink / raw)
  To: u-boot

Hi Thierry,

On 28 July 2015 at 03:35, Thierry Reding <thierry.reding@gmail.com> wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> ARMv8 requires an architected timer to be present, so it can be used
> instead of the Tegra US timer. This allows for better code reuse.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  include/configs/tegra-common.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/include/configs/tegra-common.h b/include/configs/tegra-common.h
> index 7b4c0d70636e..62b047115343 100644
> --- a/include/configs/tegra-common.h
> +++ b/include/configs/tegra-common.h
> @@ -18,8 +18,11 @@
>
>  #include <asm/arch/tegra.h>            /* get chip and board defs */
>
> +/* Use the Tegra US timer on ARMv7, but the architected timer on ARMv8. */
> +#ifndef CONFIG_ARM64
>  #define CONFIG_SYS_TIMER_RATE          1000000
>  #define CONFIG_SYS_TIMER_COUNTER       NV_PA_TMRUS_BASE
> +#endif
>
>  /*
>   * Display CPU and Board information
> --
> 2.4.5
>

Shouldn't this go in tegra210-common.h or similar?

Regards,
Simon

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-08-02 21:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-22 22:56 [U-Boot] [PATCH] armv8: Allow SoCs to override the generic timer Stephen Warren
2015-07-23 20:18 ` Simon Glass
2015-07-23 20:54 ` Tom Rini
2015-07-28  9:33 ` Thierry Reding
2015-07-28  9:35 ` [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier Thierry Reding
2015-07-28  9:35   ` [U-Boot] [PATCH 2/2] ARM: tegra: Use architected timer on ARMv8 Thierry Reding
2015-08-02 21:29     ` Simon Glass
2015-07-28 16:08   ` [U-Boot] [PATCH 1/2] ARM: tegra: Initialize timer earlier Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox