]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/arm/cpu/arm926ejs/omap/timer.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[karo-tx-uboot.git] / arch / arm / cpu / arm926ejs / omap / timer.c
index 88a0ee677eacec1776f29955092a839e7693ac7a..3e660347ee4aa026c737cd3b2e1da2e759cc8340 100644 (file)
  * (C) Copyright 2004
  * Philippe Robin, ARM Ltd. <philippe.robin@arm.com>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+ 
  */
 
 #include <common.h>
+#include <asm/io.h>
 
-#define TIMER_LOAD_VAL 0xffffffff
+#define TIMER_CLOCK    (CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV))
+#define TIMER_LOAD_VAL 0xffffffff
 
 /* macro to read the 32 bit timer */
-#define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
+#define READ_TIMER     readl(CONFIG_SYS_TIMERBASE+8) \
+                       / (TIMER_CLOCK / CONFIG_SYS_HZ)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define timestamp gd->tbl
-#define lastdec gd->lastinc
+#define timestamp gd->arch.tbl
+#define lastdec gd->arch.lastinc
 
 int timer_init (void)
 {
@@ -65,22 +52,11 @@ int timer_init (void)
 /*
  * timer without interrupts
  */
-
-void reset_timer (void)
-{
-       reset_timer_masked ();
-}
-
 ulong get_timer (ulong base)
 {
        return get_timer_masked () - base;
 }
 
-void set_timer (ulong t)
-{
-       timestamp = t;
-}
-
 /* delay x useconds AND preserve advance timestamp value */
 void __udelay (unsigned long usec)
 {
@@ -125,7 +101,8 @@ ulong get_timer_masked (void)
                 * (TLV-now) amount of time after passing though -1
                 * nts = new "advancing time stamp"...it could also roll and cause problems.
                 */
-               timestamp += lastdec + TIMER_LOAD_VAL - now;
+               timestamp += lastdec + (TIMER_LOAD_VAL / (TIMER_CLOCK /
+                                       CONFIG_SYS_HZ)) - now;
        }
        lastdec = now;
 
@@ -171,8 +148,5 @@ unsigned long long get_ticks(void)
  */
 ulong get_tbclk (void)
 {
-       ulong tbclk;
-
-       tbclk = CONFIG_SYS_HZ;
-       return tbclk;
+       return CONFIG_SYS_HZ;
 }