com_mainbus.c revision 1.2.6.2 1 1.2.6.2 bouyer /* $NetBSD: com_mainbus.c,v 1.2.6.2 2000/11/20 20:07:02 bouyer Exp $ */
2 1.2.6.2 bouyer
3 1.2.6.2 bouyer /*
4 1.2.6.2 bouyer * Copyright (c) 2000 Soren S. Jorvang. All rights reserved.
5 1.2.6.2 bouyer *
6 1.2.6.2 bouyer * Redistribution and use in source and binary forms, with or without
7 1.2.6.2 bouyer * modification, are permitted provided that the following conditions
8 1.2.6.2 bouyer * are met:
9 1.2.6.2 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.2.6.2 bouyer * notice, this list of conditions, and the following disclaimer.
11 1.2.6.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.2.6.2 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.2.6.2 bouyer * documentation and/or other materials provided with the distribution.
14 1.2.6.2 bouyer *
15 1.2.6.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 1.2.6.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 1.2.6.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 1.2.6.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 1.2.6.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 1.2.6.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 1.2.6.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.2.6.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 1.2.6.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 1.2.6.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 1.2.6.2 bouyer * SUCH DAMAGE.
26 1.2.6.2 bouyer */
27 1.2.6.2 bouyer
28 1.2.6.2 bouyer #include <sys/param.h>
29 1.2.6.2 bouyer #include <sys/systm.h>
30 1.2.6.2 bouyer #include <sys/ioctl.h>
31 1.2.6.2 bouyer #include <sys/select.h>
32 1.2.6.2 bouyer #include <sys/tty.h>
33 1.2.6.2 bouyer #include <sys/proc.h>
34 1.2.6.2 bouyer #include <sys/user.h>
35 1.2.6.2 bouyer #include <sys/conf.h>
36 1.2.6.2 bouyer #include <sys/file.h>
37 1.2.6.2 bouyer #include <sys/uio.h>
38 1.2.6.2 bouyer #include <sys/kernel.h>
39 1.2.6.2 bouyer #include <sys/syslog.h>
40 1.2.6.2 bouyer #include <sys/types.h>
41 1.2.6.2 bouyer #include <sys/device.h>
42 1.2.6.2 bouyer
43 1.2.6.2 bouyer #include <machine/autoconf.h>
44 1.2.6.2 bouyer #include <machine/intr.h>
45 1.2.6.2 bouyer #include <machine/bus.h>
46 1.2.6.2 bouyer
47 1.2.6.2 bouyer #include <dev/ic/comreg.h>
48 1.2.6.2 bouyer #include <dev/ic/comvar.h>
49 1.2.6.2 bouyer
50 1.2.6.2 bouyer
51 1.2.6.2 bouyer struct com_mainbus_softc {
52 1.2.6.2 bouyer struct com_softc sc_com;
53 1.2.6.2 bouyer void *sc_ih;
54 1.2.6.2 bouyer };
55 1.2.6.2 bouyer
56 1.2.6.2 bouyer static int com_mainbus_probe(struct device *, struct cfdata *, void *);
57 1.2.6.2 bouyer static void com_mainbus_attach(struct device *, struct device *, void *);
58 1.2.6.2 bouyer
59 1.2.6.2 bouyer struct cfattach com_mainbus_ca = {
60 1.2.6.2 bouyer sizeof(struct com_mainbus_softc), com_mainbus_probe, com_mainbus_attach
61 1.2.6.2 bouyer };
62 1.2.6.2 bouyer
63 1.2.6.2 bouyer int
64 1.2.6.2 bouyer com_mainbus_probe(parent, match, aux)
65 1.2.6.2 bouyer struct device *parent;
66 1.2.6.2 bouyer struct cfdata *match;
67 1.2.6.2 bouyer void *aux;
68 1.2.6.2 bouyer {
69 1.2.6.2 bouyer /* XXX probe */
70 1.2.6.2 bouyer
71 1.2.6.2 bouyer return 1;
72 1.2.6.2 bouyer }
73 1.2.6.2 bouyer
74 1.2.6.2 bouyer struct com_softc *com0; /* XXX */
75 1.2.6.2 bouyer
76 1.2.6.2 bouyer void
77 1.2.6.2 bouyer com_mainbus_attach(parent, self, aux)
78 1.2.6.2 bouyer struct device *parent;
79 1.2.6.2 bouyer struct device *self;
80 1.2.6.2 bouyer void *aux;
81 1.2.6.2 bouyer {
82 1.2.6.2 bouyer struct com_mainbus_softc *msc = (void *)self;
83 1.2.6.2 bouyer struct com_softc *sc = &msc->sc_com;
84 1.2.6.2 bouyer struct mainbus_attach_args *maa = aux;
85 1.2.6.2 bouyer
86 1.2.6.2 bouyer sc->sc_ioh = maa->ma_ioh;
87 1.2.6.2 bouyer sc->sc_iot = maa->ma_iot;
88 1.2.6.2 bouyer sc->sc_iobase = maa->ma_addr;
89 1.2.6.2 bouyer
90 1.2.6.2 bouyer sc->sc_frequency = COM_FREQ * 10;
91 1.2.6.2 bouyer
92 1.2.6.2 bouyer /* XXX console check */
93 1.2.6.2 bouyer /* XXX map */
94 1.2.6.2 bouyer
95 1.2.6.2 bouyer com_attach_subr(sc);
96 1.2.6.2 bouyer
97 1.2.6.2 bouyer cpu_intr_establish(maa->ma_level, IPL_SERIAL, comintr, sc);
98 1.2.6.2 bouyer
99 1.2.6.2 bouyer return;
100 1.2.6.2 bouyer }
101