xref: /netbsd-src/sys/arch/arc/arc/c_jazz_eisa.c (revision 4be6ce2eeb47bb13dbded0b07924791f50e40794)
1 /*	$NetBSD: c_jazz_eisa.c,v 1.14 2012/10/13 17:58:53 jdc Exp $	*/
2 
3 /*
4  * Copyright (c) 1998
5  *	Matthias Drochner.  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  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
29 /*
30  * for Magnum derived machines like Microsoft-Jazz and PICA-61,
31  * and NEC EISA generation machines.
32  */
33 
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: c_jazz_eisa.c,v 1.14 2012/10/13 17:58:53 jdc Exp $");
36 
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kcore.h>
40 #include <sys/device.h>
41 
42 #include <machine/autoconf.h>
43 #include <sys/bus.h>
44 #include <machine/pio.h>
45 #include <machine/platform.h>
46 
47 #include <dev/clock_subr.h>
48 #include <dev/ic/mc146818var.h>
49 
50 #include <arc/arc/arcbios.h>
51 #include <arc/jazz/pica.h>
52 #include <arc/jazz/jazziovar.h>
53 #include <arc/jazz/mcclock_jazziovar.h>
54 
55 #include "pc.h"
56 #if NPC_JAZZIO > 0
57 #include <arc/jazz/pccons_jazziovar.h>
58 #endif
59 
60 #include "vga_isa.h"
61 #if NVGA_ISA > 0
62 #include <dev/isa/vga_isavar.h>
63 #endif
64 
65 #include "vga_jazzio.h"
66 #if NVGA_JAZZIO > 0
67 #include <arc/jazz/vga_jazziovar.h>
68 #endif
69 
70 #include "rasdisplay_jazzio.h"
71 #if NRASDISPLAY_JAZZIO > 0
72 #include <arc/jazz/rasdisplay_jazziovar.h>
73 #endif
74 
75 #include "pckbc_jazzio.h"
76 #if NPCKBC_JAZZIO > 0
77 #include <arc/jazz/pckbc_jazzioreg.h>
78 #include <dev/ic/pckbcvar.h>
79 #endif
80 
81 #include "com.h"
82 #if NCOM > 0
83 #include <sys/termios.h>
84 #include <dev/ic/comreg.h>
85 #include <dev/ic/comvar.h>
86 #endif
87 
88 const char *c_jazz_eisa_mainbusdevs[] = {
89 	"jazzio",
90 	"jazzisabr",
91 	NULL,
92 };
93 
94 /*
95  * chipset-dependent mcclock routines.
96  */
97 static u_int mc_jazz_eisa_read(struct mc146818_softc *, u_int);
98 static void mc_jazz_eisa_write(struct mc146818_softc *, u_int, u_int);
99 
100 struct mcclock_jazzio_config mcclock_jazz_eisa_conf = {
101 	0x80004000,		/* I/O base */
102 	1,			/* I/O size */
103 	mc_jazz_eisa_read,	/* read function */
104 	mc_jazz_eisa_write	/* write function */
105 };
106 
107 static u_int
mc_jazz_eisa_read(struct mc146818_softc * sc,u_int reg)108 mc_jazz_eisa_read(struct mc146818_softc *sc, u_int reg)
109 {
110 	u_int i, as;
111 
112 	as = in32(arc_bus_io.bs_vbase + C_JAZZ_EISA_TODCLOCK_AS) & 0x80;
113 	out32(arc_bus_io.bs_vbase + C_JAZZ_EISA_TODCLOCK_AS, as | reg);
114 	i = bus_space_read_1(sc->sc_bst, sc->sc_bsh, 0);
115 	return i;
116 }
117 
118 static void
mc_jazz_eisa_write(struct mc146818_softc * sc,u_int reg,u_int datum)119 mc_jazz_eisa_write(struct mc146818_softc *sc, u_int reg, u_int datum)
120 {
121 	u_int as;
122 
123 	as = in32(arc_bus_io.bs_vbase + C_JAZZ_EISA_TODCLOCK_AS) & 0x80;
124 	out32(arc_bus_io.bs_vbase + C_JAZZ_EISA_TODCLOCK_AS, as | reg);
125 	bus_space_write_1(sc->sc_bst, sc->sc_bsh, 0, datum);
126 }
127 
128 /*
129  * common configuration for Magnum derived and NEC EISA generation machines.
130  */
131 void
c_jazz_eisa_init(void)132 c_jazz_eisa_init(void)
133 {
134 
135 	/* chipset-dependent mcclock configuration */
136         mcclock_jazzio_conf = &mcclock_jazz_eisa_conf;
137 }
138 
139 /*
140  * console initialization
141  */
142 void
c_jazz_eisa_cons_init(void)143 c_jazz_eisa_cons_init(void)
144 {
145 
146 	if (!com_console) {
147 
148 #if NRASDISPLAY_JAZZIO > 0
149 		if (rasdisplay_jazzio_cnattach(arc_displayc_id) == 0) {
150 #if NPCKBC_JAZZIO > 0
151 			pckbc_cnattach(&jazzio_bus, PICA_SYS_KBD,
152 			    JAZZIO_KBCMDP, PCKBC_KBD_SLOT, 0);
153 #endif
154 			return;
155 		}
156 #endif
157 
158 #if NVGA_JAZZIO > 0
159 		if (vga_jazzio_cnattach(arc_displayc_id) == 0) {
160 #if NPCKBC_JAZZIO > 0
161 			pckbc_cnattach(&jazzio_bus, PICA_SYS_KBD,
162 			    JAZZIO_KBCMDP, PCKBC_KBD_SLOT, 0);
163 #endif
164 			return;
165 		}
166 #endif
167 
168 #if NVGA_ISA > 0
169 		if (strcmp(arc_displayc_id, "necvdfrb") == 0
170 			/* NEC RISCserver 2200 R4400 EISA [NEC-R96] */
171 			/* NEC Express5800/240 R4400 EISA [NEC-J96A] */
172 		    ) {
173 			if (vga_isa_cnattach(&arc_bus_io, &arc_bus_mem) == 0) {
174 #if NPCKBC_JAZZIO > 0
175 				pckbc_cnattach(&jazzio_bus, PICA_SYS_KBD,
176 				    JAZZIO_KBCMDP, PCKBC_KBD_SLOT, 0);
177 #endif
178 				return;
179 			}
180 		}
181 #endif
182 
183 #if NPC_JAZZIO > 0
184 		if (pccons_jazzio_cnattach(arc_displayc_id, &jazzio_bus) == 0)
185 			return;
186 #endif
187 		printf("jazz: display controller [%s] is not configured\n",
188 		    arc_displayc_id);
189 	}
190 
191 #if NCOM > 0
192 	if (com_console_address == 0) {
193 		/*
194 		 * XXX
195 		 * the following is either PICA_SYS_COM1 or RD94_SYS_COM1.
196 		 */
197 		com_console_address = jazzio_bus.bs_start + 0x6000;
198 	}
199 	comcnattach(&jazzio_bus, com_console_address,
200 	    com_console_speed, com_freq, COM_TYPE_NORMAL, com_console_mode);
201 #endif
202 }
203