Unverified Commit d636f67e authored by Antonio Niño Díaz's avatar Antonio Niño Díaz Committed by GitHub
Browse files

Merge pull request #1805 from antonio-nino-diaz-arm/an/generic-timer

drivers: generic_delay_timer: Assert presence of Generic Timer
parents a45ccf13 29a24134
/* /*
* 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 * SPDX-License-Identifier: BSD-3-Clause
*/ */
#include <assert.h> #include <assert.h>
#include <arch_features.h>
#include <arch_helpers.h> #include <arch_helpers.h>
#include <common/bl_common.h> #include <common/bl_common.h>
#include <common/debug.h> #include <common/debug.h>
...@@ -43,6 +44,8 @@ void generic_delay_timer_init_args(uint32_t mult, uint32_t div) ...@@ -43,6 +44,8 @@ void generic_delay_timer_init_args(uint32_t mult, uint32_t div)
void generic_delay_timer_init(void) void generic_delay_timer_init(void)
{ {
assert(is_armv7_gentimer_present());
/* Value in ticks */ /* Value in ticks */
unsigned int mult = MHZ_TICKS_PER_SEC; unsigned int mult = MHZ_TICKS_PER_SEC;
......
...@@ -114,6 +114,8 @@ ...@@ -114,6 +114,8 @@
#define ID_PFR1_VIRTEXT_MASK U(0xf) #define ID_PFR1_VIRTEXT_MASK U(0xf)
#define GET_VIRT_EXT(id) (((id) >> ID_PFR1_VIRTEXT_SHIFT) \ #define GET_VIRT_EXT(id) (((id) >> ID_PFR1_VIRTEXT_SHIFT) \
& ID_PFR1_VIRTEXT_MASK) & 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_SHIFT U(28)
#define ID_PFR1_GIC_MASK U(0xf) #define ID_PFR1_GIC_MASK U(0xf)
......
...@@ -11,6 +11,12 @@ ...@@ -11,6 +11,12 @@
#include <arch_helpers.h> #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) static inline bool is_armv8_2_ttcnp_present(void)
{ {
return ((read_id_mmfr4() >> ID_MMFR4_CNP_SHIFT) & return ((read_id_mmfr4() >> ID_MMFR4_CNP_SHIFT) &
......
...@@ -11,6 +11,12 @@ ...@@ -11,6 +11,12 @@
#include <arch_helpers.h> #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) static inline bool is_armv8_2_ttcnp_present(void)
{ {
return ((read_id_aa64mmfr2_el1() >> ID_AA64MMFR2_EL1_CNP_SHIFT) & return ((read_id_aa64mmfr2_el1() >> ID_AA64MMFR2_EL1_CNP_SHIFT) &
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment