xref: /netbsd/sys/arch/arc/arc/c_isa.c (revision 6550d01e)
1 /*	$NetBSD: c_isa.c,v 1.9 2005/11/20 04:38:11 tsutsui Exp $	*/
2 /*	$OpenBSD: isabus.c,v 1.15 1998/03/16 09:38:46 pefo Exp $	*/
3 
4 /*-
5  * Copyright (c) 1990 The Regents of the University of California.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * William Jolitz and Don Ahn.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *	@(#)isa.c	7.2 (Berkeley) 5/12/91
36  */
37 /*-
38  * Copyright (c) 1995 Per Fogelstrom
39  * Copyright (c) 1993, 1994 Charles M. Hannum.
40  *
41  * This code is derived from software contributed to Berkeley by
42  * William Jolitz and Don Ahn.
43  *
44  * Redistribution and use in source and binary forms, with or without
45  * modification, are permitted provided that the following conditions
46  * are met:
47  * 1. Redistributions of source code must retain the above copyright
48  *    notice, this list of conditions and the following disclaimer.
49  * 2. Redistributions in binary form must reproduce the above copyright
50  *    notice, this list of conditions and the following disclaimer in the
51  *    documentation and/or other materials provided with the distribution.
52  * 3. All advertising materials mentioning features or use of this software
53  *    must display the following acknowledgement:
54  *	This product includes software developed by the University of
55  *	California, Berkeley and its contributors.
56  * 4. Neither the name of the University nor the names of its contributors
57  *    may be used to endorse or promote products derived from this software
58  *    without specific prior written permission.
59  *
60  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70  * SUCH DAMAGE.
71  *
72  *	@(#)isa.c	7.2 (Berkeley) 5/12/91
73  */
74 /*
75  * Mach Operating System
76  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
77  * All Rights Reserved.
78  *
79  * Permission to use, copy, modify and distribute this software and its
80  * documentation is hereby granted, provided that both the copyright
81  * notice and this permission notice appear in all copies of the
82  * software, derivative works or modified versions, and any portions
83  * thereof, and that both notices appear in supporting documentation.
84  *
85  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
86  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
87  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
88  *
89  * Carnegie Mellon requests users of this software to return to
90  *
91  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
92  *  School of Computer Science
93  *  Carnegie Mellon University
94  *  Pittsburgh PA 15213-3890
95  *
96  * any improvements or extensions that they make and grant Carnegie Mellon
97  * the rights to redistribute these changes.
98  */
99 /*
100   Copyright 1988, 1989 by Intel Corporation, Santa Clara, California.
101 
102 		All Rights Reserved
103 
104 Permission to use, copy, modify, and distribute this software and
105 its documentation for any purpose and without fee is hereby
106 granted, provided that the above copyright notice appears in all
107 copies and that both the copyright notice and this permission notice
108 appear in supporting documentation, and that the name of Intel
109 not be used in advertising or publicity pertaining to distribution
110 of the software without specific, written prior permission.
111 
112 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
113 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
114 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
115 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
116 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
117 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
118 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
119 */
120 
121 /*
122  * for "DESKTECH-ARCStation I" and DESKTECH-TYNE
123  */
124 
125 #include <sys/cdefs.h>
126 __KERNEL_RCSID(0, "$NetBSD: c_isa.c,v 1.9 2005/11/20 04:38:11 tsutsui Exp $");
127 
128 #include <sys/param.h>
129 #include <sys/systm.h>
130 #include <sys/device.h>
131 
132 #include <machine/autoconf.h>
133 #include <machine/pio.h>
134 #include <machine/platform.h>
135 
136 #include <dev/isa/isareg.h>
137 #include <dev/isa/isavar.h>
138 
139 #include <arc/isa/mcclock_isavar.h>
140 #include <arc/isa/timer_isavar.h>
141 #include <arc/isa/isabrvar.h>
142 
143 #include "pc.h"
144 #if NPC_ISA > 0
145 #include <arc/isa/pccons_isavar.h>
146 #endif
147 
148 #include "vga_isa.h"
149 #if NVGA_ISA > 0
150 #include <dev/ic/mc6845reg.h>
151 #include <dev/ic/pcdisplayvar.h>
152 #include <dev/isa/vga_isavar.h>
153 #endif
154 
155 #include "pckbc.h"
156 #if NPCKBC > 0
157 #include <dev/ic/pckbcvar.h>
158 #include <dev/ic/i8042reg.h>
159 #endif
160 
161 #include "com.h"
162 #if NCOM > 0
163 #include <sys/termios.h>
164 #include <dev/ic/comreg.h>
165 #include <dev/ic/comvar.h>
166 #endif
167 
168 /*
169  * chipset-dependent isa bus configuration
170  */
171 
172 int isabr_dti_intr_status(void);
173 
174 struct isabr_config isabr_dti_conf = {
175 	isabr_dti_intr_status,
176 };
177 
178 int
179 isabr_dti_intr_status(void)
180 {
181 	int isa_vector;
182 	char vector;
183 
184 	isa_outb(IO_ICU1, 0x0f);	/* Poll */
185 	vector = isa_inb(IO_ICU1);
186 	isa_vector = vector & 7;
187 	if (vector > 0 || isa_vector == 2) {
188 		isa_outb(IO_ICU2, 0x0f);
189 		vector = isa_inb(IO_ICU2);
190 		if (vector > 0) {
191 			printf("isabr_dti_intr_status: spurious interrupt\n");
192 			return -1;
193 		}
194 		isa_vector = (vector & 7) | 8;
195 	}
196 	return isa_vector;
197 }
198 
199 /*
200  * common configuration for DTI platforms
201  */
202 void
203 c_isa_init(void)
204 {
205 
206 	/* chipset-dependent mcclock configuration */
207 	mcclock_isa_conf = 1;
208 
209 	/* chipset-dependent timer configuration */
210 	timer_isa_conf = 1;
211 
212 	/* chipset-dependent isa bus configuration */
213 	isabr_conf = &isabr_dti_conf;
214 }
215 
216 /*
217  * console initialization
218  */
219 void
220 c_isa_cons_init(void)
221 {
222 
223 	if (!com_console) {
224 #if NVGA_ISA > 0
225 		if (vga_isa_cnattach(&arc_bus_io, &arc_bus_mem) == 0) {
226 #if NPCKBC > 0
227 			pckbc_cnattach(&arc_bus_io, IO_KBD, KBCMDP,
228 			    PCKBC_KBD_SLOT);
229 			return;
230 #endif
231 		}
232 #endif
233 #if NPC_ISA > 0
234 		if (pccons_isa_cnattach(&arc_bus_io, &arc_bus_mem) == 0)
235 			return;
236 #endif
237 	}
238 
239 #if NCOM > 0
240 	if (com_console_address == 0)
241 		com_console_address = IO_COM1;
242 	comcnattach(&arc_bus_io, com_console_address,
243 	    com_console_speed, com_freq, COM_TYPE_NORMAL, com_console_mode);
244 #endif
245 }
246