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