Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / cpu / arm926ejs / mx27 / timer.c
index 058dbee29c8b2a57b169bb1e924be6695a363445..408e88aa129e9594a77143d41e629ebad5addd11 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2002
  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  *
  * (C) Copyright 2009
  * Ilya Yanok, Emcraft Systems Ltd, <yanok@emcraft.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
  */
 
 #include <common.h>
 #include <div64.h>
+#include <init.h>
+#include <time.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
+#include <asm/ptrace.h>
+#include <linux/delay.h>
 
 /* General purpose timers bitfields */
 #define GPTCR_SWR              (1 << 15)       /* Software reset       */
@@ -45,8 +32,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define timestamp gd->tbl
-#define lastinc gd->lastinc
+#define timestamp      (gd->arch.tbl)
+#define lastinc                (gd->arch.lastinc)
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
@@ -124,16 +111,7 @@ int timer_init(void)
        return 0;
 }
 
-void reset_timer_masked(void)
-{
-       struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE;
-       /* reset time */
-       /* capture current incrementer value time */
-       lastinc = readl(&regs->gpt_tcn);
-       timestamp = 0; /* start "advancing" time stamp from 0 */
-}
-
-unsigned long long get_ticks (void)
+unsigned long long get_ticks(void)
 {
        struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE;
        ulong now = readl(&regs->gpt_tcn); /* current tick value */
@@ -152,7 +130,7 @@ unsigned long long get_ticks (void)
        return timestamp;
 }
 
-ulong get_timer_masked (void)
+static ulong get_timer_masked(void)
 {
        /*
         * get_ticks() returns a long long (64 bit), it wraps in
@@ -163,13 +141,13 @@ ulong get_timer_masked (void)
        return tick_to_time(get_ticks());
 }
 
-ulong get_timer (ulong base)
+ulong get_timer(ulong base)
 {
-       return get_timer_masked () - base;
+       return get_timer_masked() - base;
 }
 
 /* delay x useconds AND preserve advance timstamp value */
-void __udelay (unsigned long usec)
+void __udelay(unsigned long usec)
 {
        unsigned long long tmp;
        ulong tmo;
@@ -180,3 +158,8 @@ void __udelay (unsigned long usec)
        while (get_ticks() < tmp)       /* loop till event */
                 /*NOP*/;
 }
+
+ulong get_tbclk(void)
+{
+       return CONFIG_MX27_CLK32;
+}