Home | History | Annotate | Line # | Download | only in dev
      1 /*	$OpenBSD: lpt_ssio.c,v 1.1 2007/06/20 18:22:15 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 
     23 #include <sys/bus.h>
     24 
     25 #include <dev/ic/lptreg.h>
     26 #include <dev/ic/lptvar.h>
     27 
     28 #include <hppa/dev/ssiovar.h>
     29 
     30 int lpt_ssio_match(device_t, cfdata_t, void *);
     31 void lpt_ssio_attach(device_t, device_t, void *);
     32 
     33 CFATTACH_DECL_NEW(lpt_ssio, sizeof(struct lpt_softc),
     34     lpt_ssio_match, lpt_ssio_attach, NULL, NULL);
     35 
     36 int
     37 lpt_ssio_match(device_t parent, cfdata_t match, void *aux)
     38 {
     39 	cfdata_t cf = match;
     40 	struct ssio_attach_args *saa = aux;
     41 
     42 	if (strcmp(saa->saa_name, "lpt") != 0)
     43 		return (0);
     44 
     45 	/* Check locators. */
     46 	if (cf->ssiocf_irq != SSIO_UNK_IRQ && cf->ssiocf_irq != saa->saa_irq)
     47 		return (0);
     48 
     49 	return (1);
     50 }
     51 
     52 void
     53 lpt_ssio_attach(device_t parent, device_t self, void *aux)
     54 {
     55 	struct lpt_softc *sc = device_private(self);
     56 	struct ssio_attach_args *saa = aux;
     57 
     58 	sc->sc_dev = self;
     59 	sc->sc_iot = saa->saa_iot;
     60 	if (bus_space_map(sc->sc_iot, saa->saa_iobase, LPT_NPORTS,
     61 	    0, &sc->sc_ioh)) {
     62 		aprint_error(": can't map i/o ports\n");
     63 		return;
     64 	}
     65 
     66 	lpt_attach_subr(sc);
     67 
     68 	sc->sc_ih = ssio_intr_establish(IPL_TTY, saa->saa_irq,
     69 	    lptintr, sc, device_xname(self));
     70 
     71 	aprint_normal("\n");
     72 }
     73