Skip to contentSkip to conversation

ARM: qemu-arm: Dynamically determine timer frequency

PATCH New Tuomas Tynkkynen 2 participants 4 messages Apr 12, 2018 – Apr 29, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: qemu-arm: Dynamically determine timer frequency

After commit 46fc679ede5f69 ("arm: timer: get frequency for arch timer armv7 in cp15 cntfrq") the ARM architected timer driver knows how to determine the timer frequency at runtime by reading the CNTFRQ register, so we don't need to hardcode the timer frequency anymore.

---
 include/configs/qemu-arm.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/configs/qemu-arm.h +1 -3
index 839bc10a18..b29a54ef89 100644
@@ -19,11 +19,9 @@
 #define CONFIG_SYS_LOAD_ADDR		(CONFIG_SYS_SDRAM_BASE + SZ_2M)
 #define CONFIG_SYS_MALLOC_LEN		SZ_16M
 
-/* QEMU implements a 62.5MHz architected timer */
-/* FIXME: can we rely on CNTFREQ instead of hardcoding this fact here? */
+/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
 #define CONFIG_SYS_ARCH_TIMER
 #define CONFIG_SYS_HZ                       1000
-#define CONFIG_SYS_HZ_CLOCK                 62500000
 
 /* For block devices, QEMU emulates an ICH9 AHCI controller over PCI */
 #define CONFIG_SYS_SCSI_MAX_SCSI_ID 6
Signature · 1 line
2.16.3
#1 lore raw

PATCH 2/2 arm: move SYS_ARCH_TIMER to KConfig

From: Andre Przywara <[email protected]>

SYS_ARCH_TIMER guards the usage of the ARM Generic Timer (aka arch timer) in U-Boot.
At the moment it is mandatory for ARMv8 and used by a few ARMv7 boards. Add a proper Kconfig symbol to express this dependency properly, allowing certain board configuration to later disable arch timer in case there are any problems with it.

[tuomas: rebase + fix conflicts and resync with moveconfig & use select]
---
 arch/arm/Kconfig                     | 11 +++++++++++
 arch/arm/cpu/armv8/Makefile          |  2 +-
 arch/arm/mach-imx/mx7ulp/Kconfig     |  1 +
 arch/arm/mach-qemu/Kconfig           |  1 +
 arch/arm/mach-stm32mp/Kconfig        |  1 +
 include/configs/mx7ulp_evk.h         |  1 -
 include/configs/qemu-arm.h           |  1 -
 include/configs/stm32mp1.h           |  1 -
 include/configs/ti_armv7_keystone2.h |  1 -
 scripts/config_whitelist.txt         |  1 -
 10 files changed, 15 insertions(+), 6 deletions(-)
arch/arm/Kconfig +11 -0
index 190f883aa8..421210ed46 100644
@@ -242,6 +242,16 @@ config SYS_CACHELINE_SIZE
 	default 64 if SYS_CACHE_SHIFT_6
 	default 32 if SYS_CACHE_SHIFT_5
 
+config SYS_ARCH_TIMER
+	bool "ARM Generic Timer support"
+	depends on CPU_V7 || ARM64
+	default y if ARM64
+	help
+	  The ARM Generic Timer (aka arch-timer) provides an architected
+	  interface to a timer source on an SoC.
+	  It is mandantory for ARMv8 implementation and widely available
+	  on ARMv7 systems.
+
 config ARM_SMCCC
 	bool "Support for ARM SMC Calling Convention (SMCCC)"
 	depends on CPU_V7 || ARM64
@@ -583,6 +593,7 @@ config ARCH_KEYSTONE
 	select SUPPORT_SPL
 	select SYS_THUMB_BUILD
 	select CMD_POWEROFF
+	select SYS_ARCH_TIMER
 	imply CMD_MTDPARTS
 	imply FIT
 	imply CMD_SAVES
arch/arm/cpu/armv8/Makefile +1 -1
index 1249547436..d18b38eb9e 100644
@@ -9,7 +9,7 @@ extra-y	:= start.o
 
 obj-y	+= cpu.o
 ifndef CONFIG_$(SPL_TPL_)TIMER
-obj-y	+= generic_timer.o
+obj-$(CONFIG_SYS_ARCH_TIMER) += generic_timer.o
 endif
 obj-y	+= cache_v8.o
 obj-y	+= exceptions.o
arch/arm/mach-imx/mx7ulp/Kconfig +1 -0
index 1bdc85a9a0..d4b0299dbd 100644
@@ -9,6 +9,7 @@ choice
 
 config TARGET_MX7ULP_EVK
         bool "Support mx7ulp EVK board"
+	select SYS_ARCH_TIMER
 
 endchoice
 
arch/arm/mach-qemu/Kconfig +1 -0
index 133163aecf..226dfa362f 100644
@@ -16,6 +16,7 @@ config TARGET_QEMU_ARM_32BIT
 	depends on ARCH_QEMU
 	select CPU_V7
 	select ARCH_SUPPORT_PSCI
+	select SYS_ARCH_TIMER
 
 config TARGET_QEMU_ARM_64BIT
 	bool "Support qemu_arm64"
arch/arm/mach-stm32mp/Kconfig +1 -0
index 8ca97bf0c9..4d59480c19 100644
@@ -27,6 +27,7 @@ config TARGET_STM32MP1
 	select CPU_V7
 	select PINCTRL_STM32
 	select STM32_RESET
+	select SYS_ARCH_TIMER
 	select SYSRESET_SYSCON
 	help
 		target STMicroelectronics SOC STM32MP1 family
include/configs/mx7ulp_evk.h +0 -1
index c2223bd858..3dcda9ea77 100644
@@ -46,7 +46,6 @@
 /* Using ULP WDOG for reset */
 #define WDOG_BASE_ADDR			WDG1_RBASE
 
-#define CONFIG_SYS_ARCH_TIMER
 #define CONFIG_SYS_HZ_CLOCK		1000000 /* Fixed at 1Mhz from TSTMR */
 
 #define CONFIG_INITRD_TAG
include/configs/qemu-arm.h +0 -1
index b29a54ef89..f306b41635 100644
@@ -20,7 +20,6 @@
 #define CONFIG_SYS_MALLOC_LEN		SZ_16M
 
 /* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
-#define CONFIG_SYS_ARCH_TIMER
 #define CONFIG_SYS_HZ                       1000
 
 /* For block devices, QEMU emulates an ICH9 AHCI controller over PCI */
include/configs/stm32mp1.h +0 -1
index da0e259736..b2b654ca7a 100644
@@ -17,7 +17,6 @@
  * Number of clock ticks in 1 sec
  */
 #define CONFIG_SYS_HZ				1000
-#define CONFIG_SYS_ARCH_TIMER
 
 /*
  * malloc() pool size
include/configs/ti_armv7_keystone2.h +0 -1
index e87acca650..6f2a33e187 100644
@@ -17,7 +17,6 @@
 
 /* SoC Configuration */
 #define CONFIG_ARCH_CPU_INIT
-#define CONFIG_SYS_ARCH_TIMER
 #define CONFIG_SPL_TARGET		"u-boot-spi.gph"
 #define CONFIG_SYS_DCACHE_OFF
 
scripts/config_whitelist.txt +0 -1
index 84b5030d36..1e272e1f64 100644
@@ -2090,7 +2090,6 @@ CONFIG_SYS_APP1_BASE
 CONFIG_SYS_APP1_SIZE
 CONFIG_SYS_APP2_BASE
 CONFIG_SYS_APP2_SIZE
-CONFIG_SYS_ARCH_TIMER
 CONFIG_SYS_ARM_CACHE_WRITETHROUGH
 CONFIG_SYS_AT91_CPU_NAME
 CONFIG_SYS_AT91_MAIN_CLOCK
Signature · 1 line
2.16.3
#2 lore raw

PATCH 2/2 arm: move SYS_ARCH_TIMER to KConfig

Quoted 9 lines · Tuomas Tynkkynen

From: Andre Przywara <[email protected]>

SYS_ARCH_TIMER guards the usage of the ARM Generic Timer (aka arch timer) in U-Boot.
At the moment it is mandatory for ARMv8 and used by a few ARMv7 boards. Add a proper Kconfig symbol to express this dependency properly, allowing certain board configuration to later disable arch timer in case there are any problems with it.

Quoted 3 lines
[tuomas: rebase + fix conflicts and resync with moveconfig & use select]

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- 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/20180429/2e032aa7/attachment.sig>
#3 lore raw

PATCH 1/2 ARM: qemu-arm: Dynamically determine timer frequency

In reply to Tuomas Tynkkynen
Quoted 6 lines · Tuomas Tynkkynen

After commit 46fc679ede5f69 ("arm: timer: get frequency for arch timer armv7 in cp15 cntfrq") the ARM architected timer driver knows how to determine the timer frequency at runtime by reading the CNTFRQ register, so we don't need to hardcode the timer frequency anymore.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- 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/20180429/cc69a141/attachment.sig>