3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
6 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
7 * Marius Groeger <mgroeger@sysgo.de>
10 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
11 * Alex Zuepke <azu@sysgo.de>
13 * See file CREDITS for list of people who contributed to this
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #include <asm/arch/ixp425.h>
35 #ifndef CONFIG_USE_IRQ
36 ulong get_timer (ulong base)
38 return get_timer_masked () - base;
41 void ixp425_udelay(unsigned long usec)
44 * This function has a max usec, but since it is called from udelay
45 * we should not have to worry... be happy
47 unsigned long usecs = CFG_HZ/1000000L & ~IXP425_OST_RELOAD_MASK;
49 *IXP425_OSST = IXP425_OSST_TIMER_1_PEND;
50 usecs |= IXP425_OST_ONE_SHOT | IXP425_OST_ENABLE;
51 *IXP425_OSRT1 = usecs;
52 while (!(*IXP425_OSST & IXP425_OSST_TIMER_1_PEND));
55 void udelay (unsigned long usec)
57 while (usec--) ixp425_udelay(1);
60 static ulong reload_constant = 0xfffffff0;
62 void reset_timer_masked (void)
64 ulong reload = reload_constant | IXP425_OST_ONE_SHOT | IXP425_OST_ENABLE;
66 *IXP425_OSST = IXP425_OSST_TIMER_1_PEND;
67 *IXP425_OSRT1 = reload;
70 ulong get_timer_masked (void)
73 * Note that it is possible for this to wrap!
74 * In this case we return max.
76 ulong current = *IXP425_OST1;
77 if (*IXP425_OSST & IXP425_OSST_TIMER_1_PEND)
79 return reload_constant;
81 return (reload_constant - current);
83 #endif /* #ifndef CONFIG_USE_IRQ */