1 /* $OpenBSD: lpt_ssio.c,v 1.2 2022/03/13 08:04:38 mpi 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 <machine/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(struct device *, void *, void *);
31 void lpt_ssio_attach(struct device *, struct device *, void *);
32
33 const struct cfattach lpt_ssio_ca = {
34 sizeof(struct lpt_softc), lpt_ssio_match, lpt_ssio_attach
35 };
36
37 int
lpt_ssio_match(struct device * parent,void * match,void * aux)38 lpt_ssio_match(struct device *parent, void *match, void *aux)
39 {
40 struct cfdata *cf = match;
41 struct ssio_attach_args *saa = aux;
42
43 if (strcmp(saa->saa_name, "lpt") != 0)
44 return (0);
45
46 /* Check locators. */
47 if (cf->ssiocf_irq != SSIO_UNK_IRQ && cf->ssiocf_irq != saa->saa_irq)
48 return (0);
49
50 return (1);
51 }
52
53 void
lpt_ssio_attach(struct device * parent,struct device * self,void * aux)54 lpt_ssio_attach(struct device *parent, struct device *self, void *aux)
55 {
56 struct lpt_softc *sc = (void *)self;
57 struct ssio_attach_args *saa = aux;
58
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 printf(": cannot map io space\n");
63 return;
64 }
65
66 lpt_attach_common(sc);
67
68 sc->sc_ih = ssio_intr_establish(IPL_TTY, saa->saa_irq,
69 lptintr, sc, sc->sc_dev.dv_xname);
70 }
71