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