summaryrefslogtreecommitdiff
path: root/sys/arch/arm
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2008-01-03 17:59:33 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2008-01-03 17:59:33 +0000
commitd9282dc964cb8afe064d9454467d83e4cc011900 (patch)
tree560d1af3c7f912757775ec8d7e8a9f44ebe65902 /sys/arch/arm
parentb6068a5c1566025ae04c45e5fd0ae1f7c53ea5e9 (diff)
Move zaurus to __HAVE_TIMECOUNTER.
ok deraadt@
Diffstat (limited to 'sys/arch/arm')
-rw-r--r--sys/arch/arm/xscale/pxa2x0.c16
-rw-r--r--sys/arch/arm/xscale/pxa2x0_clock.c51
2 files changed, 28 insertions, 39 deletions
diff --git a/sys/arch/arm/xscale/pxa2x0.c b/sys/arch/arm/xscale/pxa2x0.c
index a3fed5406d9..5fdd3a4b607 100644
--- a/sys/arch/arm/xscale/pxa2x0.c
+++ b/sys/arch/arm/xscale/pxa2x0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pxa2x0.c,v 1.11 2005/11/11 23:59:58 deraadt Exp $ */
+/* $OpenBSD: pxa2x0.c,v 1.12 2008/01/03 17:59:32 kettenis Exp $ */
/* $NetBSD: pxa2x0.c,v 1.5 2003/12/12 16:42:44 thorpej Exp $ */
/*
@@ -108,6 +108,7 @@ __KERNEL_RCSID(0, "$NetBSD: pxa2x0.c,v 1.5 2003/12/12 16:42:44 thorpej Exp $");
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/reboot.h>
+#include <sys/timetc.h>
#include <machine/cpu.h>
#include <machine/bus.h>
@@ -437,15 +438,19 @@ void
resettodr(void)
{
struct pxaip_softc *sc = pxaip_sc;
+ struct timeval tv;
+
+ microtime(&tv);
bus_space_write_4(sc->sc_bust, sc->sc_bush_rtc, RTC_RCNR,
- (u_int32_t)time.tv_sec);
+ (u_int32_t)tv.tv_sec);
}
void
inittodr(time_t base)
{
struct pxaip_softc *sc = pxaip_sc;
+ struct timespec ts;
u_int32_t rcnr;
/* XXX decide if RCNR can be valid, based on the last reset
@@ -454,11 +459,12 @@ inittodr(time_t base)
/* XXX check how much RCNR differs from the filesystem date. */
if (rcnr > base)
- time.tv_sec = rcnr;
+ ts.tv_sec = rcnr;
else {
printf("WARNING: using filesystem date -- CHECK AND RESET THE DATE!\n");
- time.tv_sec = base;
+ ts.tv_sec = base;
}
- time.tv_usec = 0;
+ ts.tv_nsec = 0;
+ tc_setclock(&ts);
}
diff --git a/sys/arch/arm/xscale/pxa2x0_clock.c b/sys/arch/arm/xscale/pxa2x0_clock.c
index efbc4d2be57..89b9c444614 100644
--- a/sys/arch/arm/xscale/pxa2x0_clock.c
+++ b/sys/arch/arm/xscale/pxa2x0_clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pxa2x0_clock.c,v 1.5 2007/01/11 07:24:52 robert Exp $ */
+/* $OpenBSD: pxa2x0_clock.c,v 1.6 2008/01/03 17:59:32 kettenis Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@openbsd.org>
@@ -16,12 +16,11 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/time.h>
#include <sys/device.h>
+#include <sys/timetc.h>
#include <machine/bus.h>
#include <machine/intr.h>
@@ -72,6 +71,13 @@ struct cfdriver pxaost_cd = {
NULL, "pxaost", DV_DULL
};
+u_int pxaost_get_timecount(struct timecounter *tc);
+
+static struct timecounter pxaost_timecounter = {
+ pxaost_get_timecount, NULL, 0xffffffff, CLK4_TIMER_FREQUENCY,
+ "pxaost", 0, NULL
+};
+
int
pxaost_match(parent, match, aux)
struct device *parent;
@@ -117,6 +123,13 @@ pxaost_attach(parent, self, aux)
}
+u_int
+pxaost_get_timecount(struct timecounter *tc)
+{
+ return bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
+ OST_OSCR4);
+}
+
int
clockintr(arg)
void *arg;
@@ -239,38 +252,8 @@ cpu_initclocks()
clk + pxaost_sc->sc_clock_count);
bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR5,
clk + pxaost_sc->sc_statclock_count);
-}
-
-void
-microtime(tvp)
- register struct timeval *tvp;
-{
- int s, deltacnt;
- u_int32_t counter, expected;
-
- if (pxaost_sc == NULL) {
- tvp->tv_sec = 0;
- tvp->tv_usec = 0;
- return;
- }
-
- s = splhigh();
- counter = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
- OST_OSCR4);
- expected = pxaost_sc->sc_clock_count;
-
- *tvp = time;
- splx(s);
-
- /* number of CLK4_TIMER_FREQUENCY ticks past time */
- deltacnt = counter - expected + pxaost_sc->sc_clock_step;
- tvp->tv_usec += deltacnt * 1000000ULL / CLK4_TIMER_FREQUENCY;
-
- while (tvp->tv_usec >= 1000000) {
- tvp->tv_sec++;
- tvp->tv_usec -= 1000000;
- }
+ tc_init(&pxaost_timecounter);
}
void