diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2015-05-21 19:32:30 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2015-05-21 19:32:30 +0000 |
commit | cb63ad0daa3ece2613c750920d5f40669a6ec416 (patch) | |
tree | a5d239c75a0a8529587c5d7ffea9613974bed297 /sys | |
parent | e9457486b634c0000deedd66dbceb18f0a2a6e82 (diff) |
Establish interrupts for both keyboard and mouse slots at pckbc attach time,
rather than lazily from pckbc when slots are discovered. This is consistent
with what other isa devices (and pckbc on non-isa busses) do, and as a side
effect, this makes the dmesg output shorter.
This will also let us get rid of pckbc's intr_establish() callback in a
later diff.
Prompted by krw@ noticing ugly kernel output in a configuration with the
mouse slot left empty. ok krw@ mpi@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/isa/pckbc_isa.c | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/sys/dev/isa/pckbc_isa.c b/sys/dev/isa/pckbc_isa.c index 1bd6bfbe5cc..43730a77c49 100644 --- a/sys/dev/isa/pckbc_isa.c +++ b/sys/dev/isa/pckbc_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pckbc_isa.c,v 1.16 2015/05/04 09:33:46 mpi Exp $ */ +/* $OpenBSD: pckbc_isa.c,v 1.17 2015/05/21 19:32:29 miod Exp $ */ /* $NetBSD: pckbc_isa.c,v 1.2 2000/03/23 07:01:35 thorpej Exp $ */ /* @@ -43,15 +43,8 @@ int pckbc_isa_match(struct device *, void *, void *); void pckbc_isa_attach(struct device *, struct device *, void *); int pckbc_isa_activate(struct device *, int); -struct pckbc_isa_softc { - struct pckbc_softc sc_pckbc; - - isa_chipset_tag_t sc_ic; - int sc_irq[PCKBC_NSLOTS]; -}; - -struct cfattach pckbc_isa_ca = { - sizeof(struct pckbc_isa_softc), pckbc_isa_match, pckbc_isa_attach, +const struct cfattach pckbc_isa_ca = { + sizeof(struct pckbc_softc), pckbc_isa_match, pckbc_isa_attach, NULL, pckbc_isa_activate }; @@ -96,6 +89,9 @@ pckbc_isa_match(struct device *parent, void *match, void *aux) ia->ia_iobase = IO_KBD; ia->ia_iosize = 5; ia->ia_msize = 0x0; + ia->ipa_nirq = PCKBC_NSLOTS; + ia->ipa_irq[PCKBC_KBD_SLOT].num = 1; + ia->ipa_irq[PCKBC_AUX_SLOT].num = 12; return (1); @@ -109,16 +105,16 @@ fail: int pckbc_isa_activate(struct device *self, int act) { - struct pckbc_isa_softc *isc = (struct pckbc_isa_softc *)self; + struct pckbc_softc *sc = (struct pckbc_softc *)self; int rv = 0; switch (act) { case DVACT_SUSPEND: rv = config_activate_children(self, act); - pckbc_stop(&isc->sc_pckbc); + pckbc_stop(sc); break; case DVACT_RESUME: - pckbc_reset(&isc->sc_pckbc); + pckbc_reset(sc); rv = config_activate_children(self, act); break; default: @@ -131,22 +127,28 @@ pckbc_isa_activate(struct device *self, int act) void pckbc_isa_attach(struct device *parent, struct device *self, void *aux) { - struct pckbc_isa_softc *isc = (void *)self; - struct pckbc_softc *sc = &isc->sc_pckbc; + struct pckbc_softc *sc = (struct pckbc_softc *)self; struct cfdata *cf = self->dv_cfdata; struct isa_attach_args *ia = aux; struct pckbc_internal *t; bus_space_tag_t iot; bus_space_handle_t ioh_d, ioh_c; + void *rv; + int slot; - isc->sc_ic = ia->ia_ic; iot = ia->ia_iot; - /* - * Set up IRQs for "normal" ISA. - */ - isc->sc_irq[PCKBC_KBD_SLOT] = 1; - isc->sc_irq[PCKBC_AUX_SLOT] = 12; + printf("\n"); + + for (slot = 0; slot < PCKBC_NSLOTS; slot++) { + rv = isa_intr_establish(ia->ia_ic, ia->ipa_irq[slot].num, + IST_EDGE, IPL_TTY, pckbcintr, sc, sc->sc_dv.dv_xname); + if (rv == NULL) { + printf("%s: unable to establish interrupt for irq %d", + sc->sc_dv.dv_xname, ia->ipa_irq[slot].num); + /* XXX fail attach? */ + } + } sc->intr_establish = pckbc_isa_intr_establish; @@ -170,8 +172,6 @@ pckbc_isa_attach(struct device *parent, struct device *self, void *aux) t->t_sc = sc; sc->id = t; - printf("\n"); - /* Finish off the attach. */ pckbc_attach(sc, cf->cf_flags); } @@ -179,14 +179,5 @@ pckbc_isa_attach(struct device *parent, struct device *self, void *aux) void pckbc_isa_intr_establish(struct pckbc_softc *sc, pckbc_slot_t slot) { - struct pckbc_isa_softc *isc = (void *)sc; - void *rv; - - rv = isa_intr_establish(isc->sc_ic, isc->sc_irq[slot], IST_EDGE, - IPL_TTY, pckbcintr, sc, sc->sc_dv.dv_xname); - if (rv == NULL) { - printf(": unable to establish interrupt"); - } else { - printf(": using irq %d", isc->sc_irq[slot]); - } + /* done in attach */ } |