xref: /netbsd/sys/arch/alpha/alpha/dec_3000_500.c (revision c4a72b64)
1 /* $NetBSD: dec_3000_500.c,v 1.38 2002/09/27 15:35:34 provos Exp $ */
2 
3 /*
4  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 /*
30  * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
31  */
32 
33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
34 
35 __KERNEL_RCSID(0, "$NetBSD: dec_3000_500.c,v 1.38 2002/09/27 15:35:34 provos Exp $");
36 
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/device.h>
40 #include <sys/termios.h>
41 #include <sys/conf.h>
42 #include <dev/cons.h>
43 
44 #include <machine/rpb.h>
45 #include <machine/autoconf.h>
46 #include <machine/cpuconf.h>
47 
48 #include <dev/tc/tcvar.h>
49 #include <dev/tc/tcdsvar.h>
50 #include <alpha/tc/tc_3000_500.h>
51 
52 #include <machine/z8530var.h>
53 #include <dev/tc/zs_ioasicvar.h>
54 
55 #include <dev/scsipi/scsi_all.h>
56 #include <dev/scsipi/scsipi_all.h>
57 #include <dev/scsipi/scsiconf.h>
58 
59 #include "wsdisplay.h"
60 
61 void dec_3000_500_init __P((void));
62 static void dec_3000_500_cons_init __P((void));
63 static void dec_3000_500_device_register __P((struct device *, void *));
64 
65 static const char dec_3000_500_sp[] = "DEC 3000/400 (\"Sandpiper\")";
66 static const char dec_3000_500_sf[] = "DEC 3000/500 (\"Flamingo\")";
67 
68 const struct alpha_variation_table dec_3000_500_variations[] = {
69 	{ SV_ST_SANDPIPER, dec_3000_500_sp },
70 	{ SV_ST_FLAMINGO, dec_3000_500_sf },
71 	{ SV_ST_HOTPINK, "DEC 3000/500X (\"Hot Pink\")" },
72 	{ SV_ST_FLAMINGOPLUS, "DEC 3000/800 (\"Flamingo+\")" },
73 	{ SV_ST_SANDPLUS, "DEC 3000/600 (\"Sandpiper+\")" },
74 	{ SV_ST_SANDPIPER45, "DEC 3000/700 (\"Sandpiper45\")" },
75 	{ SV_ST_FLAMINGO45, "DEC 3000/900 (\"Flamingo45\")" },
76 	{ 0, NULL },
77 };
78 
79 void
80 dec_3000_500_init()
81 {
82 	u_int64_t variation;
83 
84 	platform.family = "DEC 3000/500 (\"Flamingo\")";
85 
86 	if ((platform.model = alpha_dsr_sysname()) == NULL) {
87 		variation = hwrpb->rpb_variation & SV_ST_MASK;
88 		if (variation == SV_ST_ULTRA) {
89 			/* These are really the same. */
90 			variation = SV_ST_FLAMINGOPLUS;
91 		}
92 		if ((platform.model = alpha_variation_name(variation,
93 		    dec_3000_500_variations)) == NULL) {
94 			/*
95 			 * This is how things used to be done.
96 			 */
97 			if (variation == SV_ST_RESERVED) {
98 				if (hwrpb->rpb_variation & SV_GRAPHICS)
99 					platform.model = dec_3000_500_sf;
100 				else
101 					platform.model = dec_3000_500_sp;
102 			} else
103 				platform.model = alpha_unknown_sysname();
104 		}
105 	}
106 
107 	platform.iobus = "tcasic";
108 	platform.cons_init = dec_3000_500_cons_init;
109 	platform.device_register = dec_3000_500_device_register;
110 }
111 
112 static void
113 dec_3000_500_cons_init()
114 {
115 	struct ctb *ctb;
116 
117 	ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
118 
119 	switch (ctb->ctb_term_type) {
120 	case CTB_GRAPHICS:
121 #if NWSDISPLAY > 0
122 		/* display console ... */
123 		if (zs_ioasic_lk201_cnattach(0x1e0000000, 0x00180000, 0) == 0 &&
124 		    tc_3000_500_fb_cnattach(
125 		     CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot)) == 0) {
126 			break;
127 		}
128 #endif
129 		printf("consinit: Unable to init console on keyboard and ");
130 		printf("TURBOchannel slot 0x%lx.\n", ctb->ctb_turboslot);
131 		printf("Using serial console.\n");
132 		/* FALLTHROUGH */
133 
134 	case CTB_PRINTERPORT:
135 		/* serial console ... */
136 		/*
137 		 * XXX This could stand some cleanup...
138 		 */
139 		{
140 			/*
141 			 * Delay to allow PROM putchars to complete.
142 			 * FIFO depth * character time,
143 			 * character time = (1000000 / (defaultrate / 10))
144 			 */
145 			DELAY(160000000 / 9600);	/* XXX */
146 
147 			/*
148 			 * Console is channel B of the second SCC.
149 			 * XXX Should use ctb_line_off to get the
150 			 * XXX line parameters--these are the defaults.
151 			 */
152 			zs_ioasic_cnattach(0x1e0000000, 0x00180000, 1);
153 			break;
154 		}
155 
156 	default:
157 		printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
158 		printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
159 		panic("consinit: unknown console type %lu",
160 		    ctb->ctb_term_type);
161 		/* NOTREACHED */
162 	}
163 }
164 
165 static void
166 dec_3000_500_device_register(dev, aux)
167 	struct device *dev;
168 	void *aux;
169 {
170 	static int found, initted, scsiboot, netboot;
171 	static struct device *scsidev;
172 	static struct device *tcdsdev;
173 	struct bootdev_data *b = bootdev_data;
174 	struct device *parent = dev->dv_parent;
175 	struct cfdata *cf = dev->dv_cfdata;
176 	const char *name = cf->cf_name;
177 
178 	if (found)
179 		return;
180 
181 	if (!initted) {
182 		scsiboot = (strcmp(b->protocol, "SCSI") == 0);
183 		netboot = (strcmp(b->protocol, "BOOTP") == 0) ||
184 		    (strcmp(b->protocol, "MOP") == 0);
185 #if 0
186 		printf("scsiboot = %d, netboot = %d\n", scsiboot, netboot);
187 #endif
188 		initted = 1;
189 	}
190 
191 	/*
192 	 * for scsi boot, we look for "tcds", make sure it has the
193 	 * right slot number, then find the "asc" on this tcds that
194 	 * as the right channel.  then we find the actual scsi
195 	 * device we came from.  note: no SCSI LUN support (yet).
196 	 */
197 	if (scsiboot && (strcmp(name, "tcds") == 0)) {
198 		struct tc_attach_args *tcargs = aux;
199 
200 		if (b->slot != tcargs->ta_slot)
201 			return;
202 
203 		tcdsdev = dev;
204 #if 0
205 		printf("\ntcdsdev = %s\n", dev->dv_xname);
206 #endif
207 	}
208 	if (scsiboot && tcdsdev &&
209 	    (strcmp(name, "asc") == 0)) {
210 		struct tcdsdev_attach_args *ta = aux;
211 
212 		if (parent != (struct device *)tcdsdev)
213 			return;
214 
215 		if (ta->tcdsda_chip != b->channel)
216 			return;
217 
218 		scsidev = dev;
219 #if 0
220 		printf("\nscsidev = %s\n", dev->dv_xname);
221 #endif
222 	}
223 
224 	if (scsiboot && scsidev &&
225 	    (strcmp(name, "sd") == 0 ||
226 	     strcmp(name, "st") == 0 ||
227 	     strcmp(name, "cd") == 0)) {
228 		struct scsipibus_attach_args *sa = aux;
229 
230 		if (parent->dv_parent != scsidev)
231 			return;
232 
233 		if (b->unit / 100 != sa->sa_periph->periph_target)
234 			return;
235 
236 		/* XXX LUN! */
237 
238 		switch (b->boot_dev_type) {
239 		case 0:
240 			if (strcmp(name, "sd") &&
241 			    strcmp(name, "cd"))
242 				return;
243 			break;
244 		case 1:
245 			if (strcmp(name, "st"))
246 				return;
247 			break;
248 		default:
249 			return;
250 		}
251 
252 		/* we've found it! */
253 		booted_device = dev;
254 #if 0
255 		printf("\nbooted_device = %s\n", booted_device->dv_xname);
256 #endif
257 		found = 1;
258 	}
259 
260 	if (netboot) {
261                 if (b->slot == 7 && strcmp(name, "le") == 0 &&
262 		    strcmp(parent->dv_cfdata->cf_name, "ioasic")
263 		     == 0) {
264 			/*
265 			 * no need to check ioasic_attach_args, since only
266 			 * one le on ioasic.
267 			 */
268 
269 			booted_device = dev;
270 #if 0
271 			printf("\nbooted_device = %s\n", booted_device->dv_xname);
272 #endif
273 			found = 1;
274 			return;
275 		}
276 
277 		/*
278 		 * XXX GENERIC SUPPORT FOR TC NETWORK BOARDS
279 		 */
280         }
281 }
282