summaryrefslogtreecommitdiff
path: root/sys/arch/arm
diff options
context:
space:
mode:
authorUwe Stuehler <uwe@cvs.openbsd.org>2005-02-28 13:21:18 +0000
committerUwe Stuehler <uwe@cvs.openbsd.org>2005-02-28 13:21:18 +0000
commit3e4147b9f2ad2921616e308e01a1455d09dacc2e (patch)
tree7a71e53c2720d53db8559342328c53cca2d10c30 /sys/arch/arm
parentc6524e9cece12d98792020ccce05338a911683b9 (diff)
Provide inittodr and resettodr for xscale, remove them from sa11x0, and
restore the time on resume.
Diffstat (limited to 'sys/arch/arm')
-rw-r--r--sys/arch/arm/sa11x0/sa11x0_ost.c15
-rw-r--r--sys/arch/arm/xscale/pxa2x0.c37
-rw-r--r--sys/arch/arm/xscale/pxa2x0_apm.c17
3 files changed, 49 insertions, 20 deletions
diff --git a/sys/arch/arm/sa11x0/sa11x0_ost.c b/sys/arch/arm/sa11x0/sa11x0_ost.c
index dbf7e8c46ea..730951fb58f 100644
--- a/sys/arch/arm/sa11x0/sa11x0_ost.c
+++ b/sys/arch/arm/sa11x0/sa11x0_ost.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sa11x0_ost.c,v 1.5 2005/01/24 22:57:16 drahn Exp $ */
+/* $OpenBSD: sa11x0_ost.c,v 1.6 2005/02/28 13:21:17 uwe Exp $ */
/* $NetBSD: sa11x0_ost.c,v 1.11 2003/07/15 00:24:51 lukem Exp $ */
/*
@@ -362,16 +362,3 @@ delay(usecs)
otick = tick;
}
}
-
-void
-resettodr()
-{
-}
-
-void
-inittodr(base)
- time_t base;
-{
- time.tv_sec = base;
- time.tv_usec = 0;
-}
diff --git a/sys/arch/arm/xscale/pxa2x0.c b/sys/arch/arm/xscale/pxa2x0.c
index c78e6d39fcf..9556121a798 100644
--- a/sys/arch/arm/xscale/pxa2x0.c
+++ b/sys/arch/arm/xscale/pxa2x0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pxa2x0.c,v 1.5 2005/01/16 17:50:09 drahn Exp $ */
+/* $OpenBSD: pxa2x0.c,v 1.6 2005/02/28 13:21:17 uwe Exp $ */
/* $NetBSD: pxa2x0.c,v 1.5 2003/12/12 16:42:44 thorpej Exp $ */
/*
@@ -124,6 +124,7 @@ struct pxaip_softc {
bus_space_tag_t sc_bust;
bus_dma_tag_t sc_dmat;
bus_space_handle_t sc_bush_clk;
+ bus_space_handle_t sc_bush_rtc;
};
/* prototypes */
@@ -174,6 +175,10 @@ pxaip_attach(struct device *parent, struct device *self, void *aux)
0, &sc->sc_bush_clk))
panic("pxaip_attach: failed to map CLKMAN");
+ if (bus_space_map(sc->sc_bust, PXA2X0_RTC_BASE, PXA2X0_RTC_SIZE,
+ 0, &sc->sc_bush_rtc))
+ panic("pxaip_attach: failed to map RTC");
+
/*
* Calculate clock speed
* This takes 2 secs at most.
@@ -423,3 +428,33 @@ pxa2x0_watchdog_boot(void)
for (rv = 0; rv < 0x20000000; rv++)
/* wait for watchdog reset */;
}
+
+void
+resettodr(void)
+{
+ struct pxaip_softc *sc = pxaip_sc;
+
+ bus_space_write_4(sc->sc_bust, sc->sc_bush_rtc, RTC_RCNR,
+ (u_int32_t)time.tv_sec);
+}
+
+void
+inittodr(time_t base)
+{
+ struct pxaip_softc *sc = pxaip_sc;
+ u_int32_t rcnr;
+
+ /* XXX decide if RCNR can be valid, based on the last reset
+ * XXX reason, i.e. RCSR. */
+ rcnr = bus_space_read_4(sc->sc_bust, sc->sc_bush_rtc, RTC_RCNR);
+
+ /* XXX check how much RCNR differs from the filesystem date. */
+ if (rcnr > base)
+ time.tv_sec = rcnr;
+ else {
+ printf("WARNING: using filesystem date -- CHECK AND RESET THE DATE!\n");
+ time.tv_sec = base;
+ }
+
+ time.tv_usec = 0;
+}
diff --git a/sys/arch/arm/xscale/pxa2x0_apm.c b/sys/arch/arm/xscale/pxa2x0_apm.c
index 3176ed99c8b..5dce4a0f5c2 100644
--- a/sys/arch/arm/xscale/pxa2x0_apm.c
+++ b/sys/arch/arm/xscale/pxa2x0_apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pxa2x0_apm.c,v 1.6 2005/02/24 21:06:02 drahn Exp $ */
+/* $OpenBSD: pxa2x0_apm.c,v 1.7 2005/02/28 13:21:17 uwe Exp $ */
/*-
* Copyright (c) 2001 Alexander Guy. All rights reserved.
@@ -200,13 +200,14 @@ struct pxa2x0_memcfg pxa2x0_memcfg = {
void pxa2x0_apm_sleep(struct pxa2x0_apm_softc *);
void pxa2x0_pi2c_open(bus_space_tag_t, bus_space_handle_t);
+void pxa2x0_pi2c_close(bus_space_tag_t, bus_space_handle_t);
int pxa2x0_pi2c_read(bus_space_tag_t, bus_space_handle_t, u_char, u_char *);
int pxa2x0_pi2c_write(bus_space_tag_t, bus_space_handle_t, u_char, u_char);
-void pxa2x0_pi2c_close(bus_space_tag_t, bus_space_handle_t);
int pxa2x0_pi2c_getvoltage(bus_space_tag_t, bus_space_handle_t, u_char *);
int pxa2x0_pi2c_setvoltage(bus_space_tag_t, bus_space_handle_t, u_char);
-void pxa2x0_pi2c_printregs(bus_space_tag_t, bus_space_handle_t);
+#if 0
void pxa2x0_pi2c_print(struct pxa2x0_apm_softc *);
+#endif
/* XXX used in pxa2x0_apm_asm.S */
bus_space_handle_t pxa2x0_gpio_ioh;
@@ -693,7 +694,10 @@ pxa2x0_apm_sleep(struct pxa2x0_apm_softc *sc)
/* XXX control battery charging in sleep mode. */
- /* XXX schedule RTC alarm to check the battery? */
+ resettodr();
+
+ /* XXX schedule RTC alarm to check the battery, or schedule
+ XXX wake-up shortly before an already programmed alarm? */
pxa2x0_wakeup_config(PXA2X0_WAKEUP_ALL, 1);
@@ -923,7 +927,7 @@ pxa2x0_apm_sleep(struct pxa2x0_apm_softc *sc)
bus_space_write_4(sc->sc_iot, ost_ioh, OST_OSCR0, sd.sd_oscr0);
bus_space_write_4(sc->sc_iot, ost_ioh, OST_OIER, sd.sd_oier);
- /* XXX update ticks from RTC. */
+ inittodr(0);
restore_interrupts(save);
@@ -1143,6 +1147,7 @@ pxa2x0_pi2c_setvoltage(bus_space_tag_t iot, bus_space_handle_t ioh,
return (res);
}
+#if 0
void
pxa2x0_pi2c_print(struct pxa2x0_apm_softc *sc)
{
@@ -1152,3 +1157,5 @@ pxa2x0_pi2c_print(struct pxa2x0_apm_softc *sc)
printf("xscale core voltage: %s\n", value == PI2C_VOLTAGE_HIGH ?
"high" : (value == PI2C_VOLTAGE_LOW ? "low" : "unkown"));
}
+#endif
+