drivers: generic_delay_timer: Assert presence of Generic Timer
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Wed, 6 Feb 2019 09:23:04 +0000 (09:23 +0000)
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>
Wed, 6 Feb 2019 09:54:42 +0000 (09:54 +0000)
The Generic Timer is an optional extension to an ARMv7-A implementation.
The generic delay timer can be used from any architecture supported by
the Trusted Firmware. In ARMv7 it is needed to check that this feature
is present. In ARMv8 it is always present.

Change-Id: Ib7e8ec13ffbb2f64445d4ee48ed00f26e34b79b7
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
drivers/delay_timer/generic_delay_timer.c
include/arch/aarch32/arch.h
include/arch/aarch32/arch_features.h
include/arch/aarch64/arch_features.h

index 4b67ed0d148bec3b47ad91d44850a8514ef6d8d6..3d0a11f5953fc308f609be3813019ff139b32893 100644 (file)
@@ -1,11 +1,12 @@
 /*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include <assert.h>
 
+#include <arch_features.h>
 #include <arch_helpers.h>
 #include <common/bl_common.h>
 #include <common/debug.h>
@@ -43,6 +44,8 @@ void generic_delay_timer_init_args(uint32_t mult, uint32_t div)
 
 void generic_delay_timer_init(void)
 {
+       assert(is_armv7_gentimer_present());
+
        /* Value in ticks */
        unsigned int mult = MHZ_TICKS_PER_SEC;
 
index 4af3e903763851ecdf4fb00ec8482a112aefeaac..3421e042d817e10e4e26f60b08bd7b0767587b59 100644 (file)
 #define ID_PFR1_VIRTEXT_MASK   U(0xf)
 #define GET_VIRT_EXT(id)       (((id) >> ID_PFR1_VIRTEXT_SHIFT) \
                                 & ID_PFR1_VIRTEXT_MASK)
+#define ID_PFR1_GENTIMER_SHIFT U(16)
+#define ID_PFR1_GENTIMER_MASK  U(0xf)
 #define ID_PFR1_GIC_SHIFT      U(28)
 #define ID_PFR1_GIC_MASK       U(0xf)
 
index d9341026774e307fcf341faf36415d6afa39784e..ddf09680be46b784e06aff271b55a4f384041020 100644 (file)
 
 #include <arch_helpers.h>
 
+static inline bool is_armv7_gentimer_present(void)
+{
+       return ((read_id_pfr1() >> ID_PFR1_GENTIMER_SHIFT) &
+               ID_PFR1_GENTIMER_MASK) != 0U;
+}
+
 static inline bool is_armv8_2_ttcnp_present(void)
 {
        return ((read_id_mmfr4() >> ID_MMFR4_CNP_SHIFT) &
index 9bf43bf85ab492a8e452b4738b9e2c8e13c78946..da8b6e4f1cf4554c6f7f4f9558204bd1ac583e2c 100644 (file)
 
 #include <arch_helpers.h>
 
+static inline bool is_armv7_gentimer_present(void)
+{
+       /* The Generic Timer is always present in an ARMv8-A implementation */
+       return true;
+}
+
 static inline bool is_armv8_2_ttcnp_present(void)
 {
        return ((read_id_aa64mmfr2_el1() >> ID_AA64MMFR2_EL1_CNP_SHIFT) &