summaryrefslogtreecommitdiff
path: root/arch/arc/lib/timer.c
diff options
context:
space:
mode:
authorTom Rini <trini@ti.com>2015-01-20 16:41:11 -0500
committerTom Rini <trini@ti.com>2015-01-20 16:41:11 -0500
commit768f6096f9c389b5ed36bee2957bee16b085fc4a (patch)
tree75d1efa0368647df87dfe4dbd16a101cbdecdc60 /arch/arc/lib/timer.c
parent1cd20006989532c0a688870a43727ace58997785 (diff)
parentfdff23702a361e89a153222233231af4d00d6e2a (diff)
Merge git://git.denx.de/u-boot-arc
Diffstat (limited to 'arch/arc/lib/timer.c')
-rw-r--r--arch/arc/lib/timer.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/arc/lib/timer.c b/arch/arc/lib/timer.c
new file mode 100644
index 00000000000..a0acbbc01a4
--- /dev/null
+++ b/arch/arc/lib/timer.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <asm/arcregs.h>
+
+#define NH_MODE (1 << 1) /* Disable timer if CPU is halted */
+
+int timer_init(void)
+{
+ write_aux_reg(ARC_AUX_TIMER0_CTRL, NH_MODE);
+ /* Set max value for counter/timer */
+ write_aux_reg(ARC_AUX_TIMER0_LIMIT, 0xffffffff);
+ /* Set initial count value and restart counter/timer */
+ write_aux_reg(ARC_AUX_TIMER0_CNT, 0);
+ return 0;
+}
+
+unsigned long timer_read_counter(void)
+{
+ return read_aux_reg(ARC_AUX_TIMER0_CNT);
+}