com_pnpbios.c revision 1.4.6.2 1 1.4.6.2 bouyer /* $NetBSD: com_pnpbios.c,v 1.4.6.2 2000/11/20 20:09:36 bouyer Exp $ */
2 1.4.6.2 bouyer /*
3 1.4.6.2 bouyer * Copyright (c) 1999
4 1.4.6.2 bouyer * Matthias Drochner. All rights reserved.
5 1.4.6.2 bouyer *
6 1.4.6.2 bouyer * Redistribution and use in source and binary forms, with or without
7 1.4.6.2 bouyer * modification, are permitted provided that the following conditions
8 1.4.6.2 bouyer * are met:
9 1.4.6.2 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.4.6.2 bouyer * notice, this list of conditions, and the following disclaimer.
11 1.4.6.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.4.6.2 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.4.6.2 bouyer * documentation and/or other materials provided with the distribution.
14 1.4.6.2 bouyer *
15 1.4.6.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 1.4.6.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 1.4.6.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 1.4.6.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 1.4.6.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 1.4.6.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 1.4.6.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.4.6.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 1.4.6.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 1.4.6.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 1.4.6.2 bouyer * SUCH DAMAGE.
26 1.4.6.2 bouyer */
27 1.4.6.2 bouyer
28 1.4.6.2 bouyer #include <sys/param.h>
29 1.4.6.2 bouyer #include <sys/systm.h>
30 1.4.6.2 bouyer #include <sys/errno.h>
31 1.4.6.2 bouyer #include <sys/ioctl.h>
32 1.4.6.2 bouyer #include <sys/syslog.h>
33 1.4.6.2 bouyer #include <sys/device.h>
34 1.4.6.2 bouyer #include <sys/proc.h>
35 1.4.6.2 bouyer #include <sys/termios.h>
36 1.4.6.2 bouyer
37 1.4.6.2 bouyer #include <machine/bus.h>
38 1.4.6.2 bouyer
39 1.4.6.2 bouyer #include <dev/isa/isavar.h>
40 1.4.6.2 bouyer #include <dev/isa/isadmavar.h>
41 1.4.6.2 bouyer
42 1.4.6.2 bouyer #include <i386/pnpbios/pnpbiosvar.h>
43 1.4.6.2 bouyer
44 1.4.6.2 bouyer #include <dev/ic/comvar.h>
45 1.4.6.2 bouyer
46 1.4.6.2 bouyer struct com_pnpbios_softc {
47 1.4.6.2 bouyer struct com_softc sc_com;
48 1.4.6.2 bouyer void *sc_ih;
49 1.4.6.2 bouyer };
50 1.4.6.2 bouyer
51 1.4.6.2 bouyer int com_pnpbios_match __P((struct device *, struct cfdata *, void *));
52 1.4.6.2 bouyer void com_pnpbios_attach __P((struct device *, struct device *, void *));
53 1.4.6.2 bouyer
54 1.4.6.2 bouyer struct cfattach com_pnpbios_ca = {
55 1.4.6.2 bouyer sizeof(struct com_pnpbios_softc), com_pnpbios_match, com_pnpbios_attach
56 1.4.6.2 bouyer };
57 1.4.6.2 bouyer
58 1.4.6.2 bouyer int
59 1.4.6.2 bouyer com_pnpbios_match(parent, match, aux)
60 1.4.6.2 bouyer struct device *parent;
61 1.4.6.2 bouyer struct cfdata *match;
62 1.4.6.2 bouyer void *aux;
63 1.4.6.2 bouyer {
64 1.4.6.2 bouyer struct pnpbiosdev_attach_args *aa = aux;
65 1.4.6.2 bouyer
66 1.4.6.2 bouyer if (strcmp(aa->idstr, "PNP0500") &&
67 1.4.6.2 bouyer strcmp(aa->idstr, "PNP0501") &&
68 1.4.6.2 bouyer strcmp(aa->idstr, "PNP0510") &&
69 1.4.6.2 bouyer strcmp(aa->idstr, "PNP0511"))
70 1.4.6.2 bouyer return (0);
71 1.4.6.2 bouyer
72 1.4.6.2 bouyer return (1);
73 1.4.6.2 bouyer }
74 1.4.6.2 bouyer
75 1.4.6.2 bouyer void
76 1.4.6.2 bouyer com_pnpbios_attach(parent, self, aux)
77 1.4.6.2 bouyer struct device *parent, *self;
78 1.4.6.2 bouyer void *aux;
79 1.4.6.2 bouyer {
80 1.4.6.2 bouyer struct com_pnpbios_softc *psc = (void *)self;
81 1.4.6.2 bouyer struct com_softc *sc = &psc->sc_com;
82 1.4.6.2 bouyer struct pnpbiosdev_attach_args *aa = aux;
83 1.4.6.2 bouyer bus_space_tag_t iot;
84 1.4.6.2 bouyer int iobase;
85 1.4.6.2 bouyer
86 1.4.6.2 bouyer if (pnpbios_getiobase(aa->pbt, aa->resc, 0, &iot, &iobase)) {
87 1.4.6.2 bouyer printf(": can't get iobase\n");
88 1.4.6.2 bouyer return;
89 1.4.6.2 bouyer }
90 1.4.6.2 bouyer
91 1.4.6.2 bouyer if (com_is_console(iot, iobase, &sc->sc_ioh))
92 1.4.6.2 bouyer sc->sc_iot = iot;
93 1.4.6.2 bouyer else if (pnpbios_io_map(aa->pbt, aa->resc, 0,
94 1.4.6.2 bouyer &sc->sc_iot, &sc->sc_ioh)) {
95 1.4.6.2 bouyer printf(": can't map i/o space\n");
96 1.4.6.2 bouyer return;
97 1.4.6.2 bouyer }
98 1.4.6.2 bouyer sc->sc_iobase = iobase;
99 1.4.6.2 bouyer
100 1.4.6.2 bouyer printf("\n");
101 1.4.6.2 bouyer pnpbios_print_devres(self, aa);
102 1.4.6.2 bouyer
103 1.4.6.2 bouyer printf("%s", self->dv_xname);
104 1.4.6.2 bouyer
105 1.4.6.2 bouyer /*
106 1.4.6.2 bouyer * if the chip isn't something we recognise skip it.
107 1.4.6.2 bouyer */
108 1.4.6.2 bouyer if (comprobe1(sc->sc_iot, sc->sc_ioh) == 0) {
109 1.4.6.2 bouyer printf(": com probe failed\n");
110 1.4.6.2 bouyer return;
111 1.4.6.2 bouyer }
112 1.4.6.2 bouyer
113 1.4.6.2 bouyer sc->sc_frequency = 115200 * 16;
114 1.4.6.2 bouyer
115 1.4.6.2 bouyer com_attach_subr(sc);
116 1.4.6.2 bouyer
117 1.4.6.2 bouyer psc->sc_ih = pnpbios_intr_establish(aa->pbt, aa->resc, 0, IPL_SERIAL,
118 1.4.6.2 bouyer comintr, sc);
119 1.4.6.2 bouyer }
120