1 // SPDX-License-Identifier: GPL-2.0+
4 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
18 #if defined (CONFIG_IMX)
20 #include <asm/arch/imx-regs.h>
21 #include <linux/delay.h>
26 /* setup GP Timer 1 */
28 for ( i=0; i<100; i++) TCTL1 = 0; /* We have no udelay by now */
29 TPRER1 = get_PERCLK1() / 1000000; /* 1 MHz */
30 TCTL1 |= TCTL_FRR | (1<<1); /* Freerun Mode, PERCLK1 input */
34 TCTL1 |= TCTL_TEN; /* Enable timer */
40 * timer without interrupts
42 static ulong get_timer_masked (void)
47 ulong get_timer (ulong base)
49 return get_timer_masked() - base;
52 void __udelay(unsigned long usec)
54 ulong endtime = get_timer_masked() + usec;
58 ulong now = get_timer_masked ();
64 * This function is derived from PowerPC code (read timebase as long long).
65 * On ARM it just returns the timer value.
67 unsigned long long get_ticks(void)
73 * This function is derived from PowerPC code (timebase clock frequency).
74 * On ARM it returns the number of timer ticks per second.
82 * Reset the cpu by setting up the watchdog timer and let him time out
86 /* Disable watchdog and set Time-Out field to 0 */
89 /* Write Service Sequence */
100 #endif /* defined (CONFIG_IMX) */