Annotation of sys/arch/hppa/dev/com_ssio.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: com_ssio.c,v 1.2 2007/06/24 16:28:39 kettenis Exp $ */
! 2:
! 3: /*
! 4: * Copyright (c) 2007 Mark Kettenis
! 5: *
! 6: * Permission to use, copy, modify, and distribute this software for any
! 7: * purpose with or without fee is hereby granted, provided that the above
! 8: * copyright notice and this permission notice appear in all copies.
! 9: *
! 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
! 11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
! 12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
! 13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
! 14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
! 15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
! 16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
! 17: */
! 18:
! 19: #include <sys/param.h>
! 20: #include <sys/systm.h>
! 21: #include <sys/device.h>
! 22: #include <sys/tty.h>
! 23:
! 24: #include <machine/bus.h>
! 25: #include <machine/iomod.h>
! 26:
! 27: #include <dev/ic/comreg.h>
! 28: #include <dev/ic/comvar.h>
! 29:
! 30: #include <hppa/dev/ssiovar.h>
! 31:
! 32: #define COM_SSIO_FREQ 1843200
! 33:
! 34: int com_ssio_match(struct device *, void *, void *);
! 35: void com_ssio_attach(struct device *, struct device *, void *);
! 36:
! 37: struct cfattach com_ssio_ca = {
! 38: sizeof(struct com_softc), com_ssio_match, com_ssio_attach
! 39: };
! 40:
! 41: int
! 42: com_ssio_match(struct device *parent, void *match, void *aux)
! 43: {
! 44: struct cfdata *cf = match;
! 45: struct ssio_attach_args *saa = aux;
! 46:
! 47: if (strcmp(saa->saa_name, "com") != 0)
! 48: return (0);
! 49:
! 50: /* Check locators. */
! 51: if (cf->ssiocf_irq != SSIO_UNK_IRQ && cf->ssiocf_irq != saa->saa_irq)
! 52: return (0);
! 53:
! 54: return (1);
! 55: }
! 56:
! 57: void
! 58: com_ssio_attach(struct device *parent, struct device *self, void *aux)
! 59: {
! 60: struct com_softc *sc = (void *)self;
! 61: struct ssio_attach_args *saa = aux;
! 62:
! 63: sc->sc_iot = saa->saa_iot;
! 64: sc->sc_iobase = saa->saa_iobase;
! 65: if (bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS,
! 66: 0, &sc->sc_ioh)) {
! 67: printf(": cannot map io space\n");
! 68: return;
! 69: }
! 70:
! 71: if (PAGE0->mem_cons.pz_class == PCL_DUPLEX &&
! 72: PAGE0->mem_cons.pz_hpa == sc->sc_ioh) {
! 73: bus_space_unmap(sc->sc_iot, sc->sc_ioh, COM_NPORTS);
! 74: comcnattach(sc->sc_iot, sc->sc_iobase, comdefaultrate,
! 75: COM_SSIO_FREQ, comconscflag);
! 76: }
! 77:
! 78: sc->sc_frequency = COM_SSIO_FREQ;
! 79: com_attach_subr(sc);
! 80:
! 81: sc->sc_ih = ssio_intr_establish(IPL_TTY, saa->saa_irq,
! 82: comintr, sc, sc->sc_dev.dv_xname);
! 83: }
CVSweb