Skip to content

Commit f06f7eb

Browse files
committed
arm64: add timer support
Signed-off-by: Sreenidhi Bharathkar Ramesh <[email protected]>
1 parent 4640691 commit f06f7eb

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Github.com pull request). Note that these email addresses are not
88
guaranteed to be current; they are simply a unique indicator of the
99
individual who committed them.
1010

11+
Abhishek Joshi, Broadcom
12+
1113
Abhishek Kulkarni, Indiana University
1214
1315
Adrian Knoth, Friedrich-Schiller-Universitat Jena

opal/include/opal/sys/arm64/timer.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2008 The University of Tennessee and The University
33
* of Tennessee Research Foundation. All rights
44
* reserved.
5+
* Copyright (c) 2016 Broadcom Limited. All rights reserved.
56
* $COPYRIGHT$
67
*
78
* Additional copyrights may follow
@@ -20,14 +21,21 @@ static inline opal_timer_t
2021
opal_sys_timer_get_cycles(void)
2122
{
2223
opal_timer_t ret;
23-
struct tms accurate_clock;
2424

25-
times(&accurate_clock);
26-
ret = accurate_clock.tms_utime + accurate_clock.tms_stime;
25+
__asm__ __volatile__ ("mrs %0, CNTVCT_EL0" : "=r" (ret));
2726

2827
return ret;
2928
}
3029

30+
31+
static inline opal_timer_t
32+
opal_sys_timer_freq(void)
33+
{
34+
opal_timer_t freq;
35+
__asm__ __volatile__ ("mrs %0, CNTFRQ_EL0" : "=r" (freq));
36+
return (opal_timer_t)(freq);
37+
}
38+
3139
#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 1
3240

3341
#endif /* ! OPAL_SYS_ARCH_TIMER_H */

opal/include/opal/sys/timer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2016 Broadcom Limited. All rights reserved.
1213
* $COPYRIGHT$
1314
*
1415
* Additional copyrights may follow
@@ -84,6 +85,8 @@ BEGIN_C_DECLS
8485
#include "opal/sys/amd64/timer.h"
8586
#elif OPAL_ASSEMBLY_ARCH == OPAL_ARM
8687
#include "opal/sys/arm/timer.h"
88+
#elif OPAL_ASSEMBLY_ARCH == OPAL_ARM64
89+
#include "opal/sys/arm64/timer.h"
8790
#elif OPAL_ASSEMBLY_ARCH == OPAL_IA32
8891
#include "opal/sys/ia32/timer.h"
8992
#elif OPAL_ASSEMBLY_ARCH == OPAL_IA64

opal/mca/timer/linux/configure.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
1414
# Copyright (c) 2015 Research Organization for Information Science
1515
# and Technology (RIST). All rights reserved.
16+
# Copyright (c) 2016 Broadcom Limited. All rights reserved.
1617
# $COPYRIGHT$
1718
#
1819
# Additional copyrights may follow
@@ -46,7 +47,7 @@ AC_DEFUN([MCA_opal_timer_linux_CONFIG],[
4647
[timer_linux_happy="no"])])
4748

4849
case "${host}" in
49-
i?86-*linux*|x86_64*linux*|ia64-*linux*|powerpc-*linux*|powerpc64-*linux*|sparc*-*linux*)
50+
i?86-*linux*|x86_64*linux*|ia64-*linux*|powerpc-*linux*|powerpc64-*linux*|sparc*-*linux*|aarch64-*linux*)
5051
AS_IF([test "$timer_linux_happy" = "yes"],
5152
[AS_IF([test -r "/proc/cpuinfo"],
5253
[timer_linux_happy="yes"],

opal/mca/timer/linux/timer_linux_component.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1616
* reserved.
1717
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
18+
* Copyright (c) 2016 Broadcom Limited. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -107,6 +108,10 @@ static int opal_timer_linux_find_freq(void)
107108

108109
opal_timer_linux_freq = 0;
109110

111+
#if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
112+
opal_timer_linux_freq = opal_sys_timer_freq();
113+
#endif
114+
110115
if (0 == opal_timer_linux_freq) {
111116
/* first, look for a timebase field. probably only on PPC,
112117
but one never knows */

0 commit comments

Comments
 (0)