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