drsupio.c revision 1.1 1 /* $NetBSD: drsupio.c,v 1.1 1997/08/27 19:32:53 is Exp $ */
2
3 /*
4 * Copyright (c) 1997 Ignatios Souvatzis
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Ignatios Souvatzis
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * DraCo multi-io chip bus space stuff
36 */
37
38 #include <sys/types.h>
39
40 #include <sys/conf.h>
41 #include <sys/device.h>
42 #include <sys/systm.h>
43 #include <sys/param.h>
44
45 #include <machine/bus.h>
46 #include <machine/conf.h>
47
48 #include <amiga/include/cpu.h>
49
50 #include <amiga/amiga/device.h>
51 #include <amiga/amiga/drcustom.h>
52
53 #include <amiga/dev/supio.h>
54
55
56 struct drsupio_softc {
57 struct device sc_dev;
58 struct bus_space_tag sc_bst;
59 };
60
61 int drsupiomatch __P((struct device *, struct cfdata *, void *));
62 void drsupioattach __P((struct device *, struct device *, void *));
63 int drsupprint __P((void *auxp, const char *));
64
65 struct cfattach drsupio_ca = {
66 sizeof(struct drsupio_softc), drsupiomatch, drsupioattach
67 };
68
69 struct cfdriver drsupio_cd = {
70 NULL, "drsupio", DV_DULL
71 };
72
73 int
74 drsupiomatch(parent, cfp, auxp)
75 struct device *parent;
76 struct cfdata *cfp;
77 void *auxp;
78 {
79
80 /* Exactly one of us lives on the DraCo */
81
82 if (is_draco() && matchname(auxp, "drsupio") && (cfp->cf_unit == 0))
83 return 1;
84
85 return 0;
86 }
87
88 struct drsupio_devs {
89 char *name;
90 int off;
91 } drsupiodevs[] = {
92 { "com", 0x3f8 },
93 { "com", 0x2f8 },
94 { "lpt", 0x378 },
95 { "fdc", 0x3f0 },
96 /* WD port? */
97 { 0 }
98 };
99
100 void
101 drsupioattach(parent, self, auxp)
102 struct device *parent, *self;
103 void *auxp;
104 {
105 struct drsupio_softc *drsc;
106 struct drsupio_devs *drsd;
107 struct supio_attach_args supa;
108
109 drsc = (struct drsupio_softc *)self;
110 drsd = drsupiodevs;
111
112 if (parent)
113 printf("\n");
114
115 drsc->sc_bst.base = DRCCADDR + NBPG * DRSUPIOPG + 1;
116 drsc->sc_bst.stride = 2;
117
118 supa.supio_iot = &drsc->sc_bst;
119
120 while (drsd->name) {
121 supa.supio_name = drsd->name;
122 supa.supio_iobase = drsd->off;
123 config_found(self, &supa, drsupprint); /* XXX */
124 ++drsd;
125 }
126 }
127
128 int
129 drsupprint(auxp, pnp)
130 void *auxp;
131 const char *pnp;
132 {
133 struct supio_attach_args *supa;
134 supa = auxp;
135
136 if (pnp == NULL)
137 return(QUIET);
138
139 printf("%s at %s port 0x%02x",
140 supa->supio_name, pnp, supa->supio_iobase);
141
142 return(UNCONF);
143 }
144