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 / mxs / timer.c
index 2039106e4074ef5d5a21f13f67a74627b30463a1..5ab4ed0c5a3da057a52ed4bc41a2b726d26e2866 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Freescale i.MX28 timer driver
  *
@@ -6,30 +7,15 @@
  *
  * Based on code from LTIB:
  * (C) Copyright 2009-2010 Freescale Semiconductor, Inc.
- *
- * 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 <init.h>
+#include <time.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/sys_proto.h>
+#include <linux/delay.h>
 
 /* Maximum fixed count */
 #if defined(CONFIG_MX23)
@@ -107,6 +93,8 @@ unsigned long long get_ticks(void)
                TIMROT_RUNNING_COUNTn_RUNNING_COUNT_OFFSET;
 #elif defined(CONFIG_MX28)
        now = readl(&timrot_regs->hw_timrot_running_count0);
+#else
+#error "Don't know how to read timrot_regs"
 #endif
 
        if (lastdec >= now) {
@@ -125,14 +113,9 @@ unsigned long long get_ticks(void)
        return timestamp;
 }
 
-ulong get_timer_masked(void)
-{
-       return tick_to_time(get_ticks());
-}
-
 ulong get_timer(ulong base)
 {
-       return get_timer_masked() - base;
+       return tick_to_time(get_ticks()) - base;
 }
 
 /* We use the HW_DIGCTL_MICROSECONDS register for sub-millisecond timer. */