diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-05-15 23:02:26 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-05-15 23:02:26 +0000 |
commit | f465ca8986581eacce2f0ab962c6590956537ed0 (patch) | |
tree | ee65d955360a912331a303220f8ac2ce8d5a8f4b /sys/arch/sgi/dev/power.c | |
parent | c38525da63f69afbdf3eb2d6740e009d7c8a68bc (diff) |
TOD clock support for IOC3 flavours with DS174x chips (which are rebadged
MK48Txx). Entangled with preliminary changes which will hopefully eventually
lead to power(4) attaching on IP30 (but not finished yet).
Diffstat (limited to 'sys/arch/sgi/dev/power.c')
-rw-r--r-- | sys/arch/sgi/dev/power.c | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/sys/arch/sgi/dev/power.c b/sys/arch/sgi/dev/power.c index 35f5c8f3146..1afd06ef776 100644 --- a/sys/arch/sgi/dev/power.c +++ b/sys/arch/sgi/dev/power.c @@ -1,4 +1,4 @@ -/* $OpenBSD: power.c,v 1.7 2008/09/16 16:38:25 jasper Exp $ */ +/* $OpenBSD: power.c,v 1.8 2009/05/15 23:02:23 miod Exp $ */ /* * Copyright (c) 2007 Jasper Lievisse Adriaanse <jasper@openbsd.org> @@ -36,18 +36,12 @@ struct power_softc { struct device sc_dev; bus_space_tag_t sc_st; bus_space_handle_t sc_sh; - bus_space_handle_t sc_isash; }; -int power_match(struct device *, void *, void *); void power_attach(struct device *, struct device *, void *); -int power_intr(void *aux); - -struct cfattach power_ca = { - sizeof(struct power_softc), - power_match, - power_attach -}; +int power_match(struct device *, void *, void *); +int power_intr(void *); +int power_intr_macebus(void *); struct cfdriver power_cd = { NULL, "power", DV_DULL @@ -59,63 +53,66 @@ power_match(struct device *parent, void *match, void *aux) return (1); } +struct cfattach power_ca = { + sizeof(struct power_softc), power_match, power_attach +}; + void power_attach(struct device *parent, struct device *self, void *aux) { struct power_softc *sc = (void *)self; struct confargs *ca = aux; - extern bus_space_handle_t clock_h; extern bus_space_handle_t mace_h; sc->sc_st = ca->ca_iot; - /* Map subregion to clock address space. */ - if (bus_space_subregion(sc->sc_st, clock_h, 0, 0x50, &sc->sc_sh)) { - printf(": failed to map clock address space!\n"); - return; - } - /* Map subregion to ISA control registers. */ - if (bus_space_subregion(sc->sc_st, mace_h, 0, 0x80, &sc->sc_isash)) { + if (bus_space_subregion(sc->sc_st, mace_h, 0, 0x80, &sc->sc_sh)) { printf(": failed to map ISA control registers!\n"); return; } /* Establish interrupt handler. */ if (macebus_intr_establish(NULL, ca->ca_intr, IST_EDGE, IPL_TTY, - power_intr, sc, sc->sc_dev.dv_xname)) + power_intr_macebus, sc, sc->sc_dev.dv_xname)) printf("\n"); else printf(": unable to establish interrupt!\n"); } int -power_intr(void *arg) +power_intr_macebus(void *arg) { struct power_softc *sc = (void *)arg; u_int64_t val; - extern int kbd_reset; /* Check to see if this interrupt is for us. */ - val = bus_space_read_8(sc->sc_st, sc->sc_isash, MACE_ISA_INT_STAT); - if (val & MACE_ISA_INT_RTC) { - - /* - * Prevent further interrupts by clearing the kickstart flag - * in the DS1687's extended control register. - */ - val = bus_space_read_1(sc->sc_st, sc->sc_sh, DS1687_EXT_CTRL); - bus_space_write_1(sc->sc_st, sc->sc_sh, DS1687_EXT_CTRL, - val & ~DS1687_KICKSTART); - - if (kbd_reset == 1) { - kbd_reset = 0; - psignal(initproc, SIGUSR2); - } - - return (1); - } + val = bus_space_read_8(sc->sc_st, sc->sc_sh, MACE_ISA_INT_STAT); + if (val & MACE_ISA_INT_RTC) + return power_intr(arg); - return (0); + return 0; } +int +power_intr(void *unused) +{ + extern int kbd_reset; + int val; + + /* + * Prevent further interrupts by clearing the kickstart flag + * in the DS1687's extended control register. + */ + val = dsrtc_register_read(DS1687_EXT_CTRL); + if (val == -1) + return 1; /* no rtc attached */ + dsrtc_register_write(DS1687_EXT_CTRL, val & ~DS1687_KICKSTART); + + if (kbd_reset == 1) { + kbd_reset = 0; + psignal(initproc, SIGUSR2); + } + + return 1; +} |