1 /* $NetBSD: dec_3000_300.c,v 1.49 2024/03/31 19:06:30 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 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 /*
31 * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
32 */
33
34 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
35
36 __KERNEL_RCSID(0, "$NetBSD: dec_3000_300.c,v 1.49 2024/03/31 19:06:30 thorpej Exp $");
37
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/device.h>
41 #include <sys/termios.h>
42 #include <sys/conf.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_300.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_300_init(void);
62 static void dec_3000_300_cons_init(void);
63 static void dec_3000_300_device_register(device_t, 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(void)74 dec_3000_300_init(void)
75 {
76 uint64_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(void)93 dec_3000_300_cons_init(void)
94 {
95 struct ctb *ctb;
96
97 ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off);
98
99 switch (ctb->ctb_term_type) {
100 case CTB_GRAPHICS:
101 #if NWSDISPLAY > 0
102 /* display console ... */
103 if (zs_ioasic_lk201_cnattach(0x1a0000000, 0x00180000, 0) == 0 &&
104 tc_3000_300_fb_cnattach(
105 CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot)) == 0) {
106 break;
107 }
108 #endif
109 printf("consinit: Unable to init console on keyboard and ");
110 printf("TURBOchannel slot 0x%lx.\n", ctb->ctb_turboslot);
111 printf("Using serial console.\n");
112 /* FALLTHROUGH */
113
114 case CTB_PRINTERPORT:
115 /* serial console ... */
116 /*
117 * XXX This could stand some cleanup...
118 */
119 {
120 /*
121 * Delay to allow PROM putchars to complete.
122 * FIFO depth * character time.
123 * character time = (1000000 / (defaultrate / 10))
124 */
125 DELAY(160000000 / 9600); /* XXX */
126
127 /*
128 * Console is channel B of the first SCC.
129 * XXX Should use ctb_line_off to get the
130 * XXX line parameters.
131 */
132 zs_ioasic_cnattach(0x1a0000000, 0x00100000, 1);
133 break;
134 }
135
136 default:
137 printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
138 printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
139 panic("consinit: unknown console type %lu",
140 ctb->ctb_term_type);
141 /* NOTREACHED */
142 }
143 }
144
145 static void
dec_3000_300_device_register(device_t dev,void * aux)146 dec_3000_300_device_register(device_t dev, void *aux)
147 {
148 static int found, initted, scsiboot, netboot;
149 static device_t scsidev;
150 static device_t tcdsdev;
151 struct bootdev_data *b = bootdev_data;
152 device_t parent = device_parent(dev);
153
154 if (b == NULL || found)
155 return;
156
157 if (!initted) {
158 scsiboot = (strcmp(b->protocol, "SCSI") == 0);
159 netboot = (strcmp(b->protocol, "BOOTP") == 0) ||
160 (strcmp(b->protocol, "MOP") == 0);
161 #if 0
162 printf("scsiboot = %d, netboot = %d\n", scsiboot, netboot);
163 #endif
164 initted = 1;
165 }
166
167 /*
168 * for scsi boot, we look for "tcds", make sure it has the
169 * right slot number, then find the "asc" on this tcds that
170 * as the right channel. then we find the actual scsi
171 * device we came from. note: no SCSI LUN support (yet).
172 */
173 if (scsiboot && device_is_a(dev, "tcds")) {
174 struct tc_attach_args *tcargs = aux;
175
176 if (b->slot != tcargs->ta_slot)
177 return;
178
179 tcdsdev = dev;
180 #if 0
181 printf("\ntcdsdev = %s\n", device_xname(dev));
182 #endif
183 }
184 if (scsiboot && tcdsdev &&
185 device_is_a(dev, "asc")) {
186 struct tcdsdev_attach_args *ta = aux;
187
188 if (parent != tcdsdev)
189 return;
190
191 if (ta->tcdsda_chip != b->channel)
192 return;
193
194 scsidev = dev;
195 #if 0
196 printf("\nscsidev = %s\n", device_xname(dev));
197 #endif
198 }
199
200 if (scsiboot && scsidev &&
201 (device_is_a(dev, "sd") ||
202 device_is_a(dev, "st") ||
203 device_is_a(dev, "cd"))) {
204 struct scsipibus_attach_args *sa = aux;
205
206 if (device_parent(parent) != scsidev)
207 return;
208
209 if (b->unit / 100 != sa->sa_periph->periph_target)
210 return;
211
212 /* XXX LUN! */
213
214 switch (b->boot_dev_type) {
215 case 0:
216 if (!device_is_a(dev, "sd") &&
217 !device_is_a(dev, "cd"))
218 return;
219 break;
220 case 1:
221 if (!device_is_a(dev, "st"))
222 return;
223 break;
224 default:
225 return;
226 }
227
228 /* we've found it! */
229 booted_device = dev;
230 #if 0
231 printf("\nbooted_device = %s\n", device_xname(booted_device));
232 #endif
233 found = 1;
234 }
235
236 if (netboot) {
237 if (b->slot == 5 && device_is_a(dev, "le") &&
238 device_is_a(parent, "ioasic")) {
239 /*
240 * no need to check ioasic_attach_args, since only
241 * one le on ioasic.
242 */
243
244 booted_device = dev;
245 #if 0
246 printf("\nbooted_device = %s\n", device_xname(booted_device));
247 #endif
248 found = 1;
249 return;
250 }
251
252 /*
253 * XXX GENERIC SUPPORT FOR TC NETWORK BOARDS
254 */
255 }
256 }
257