1 /* $NetBSD: dec_3000_300.c,v 1.39 2002/09/27 15:35:34 provos 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.39 2002/09/27 15:35:34 provos 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 __P((void)); 62 static void dec_3000_300_cons_init __P((void)); 63 static void dec_3000_300_device_register __P((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 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 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 /* 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 146 dec_3000_300_device_register(dev, aux) 147 struct device *dev; 148 void *aux; 149 { 150 static int found, initted, scsiboot, netboot; 151 static struct device *scsidev; 152 static struct device *tcdsdev; 153 struct bootdev_data *b = bootdev_data; 154 struct device *parent = dev->dv_parent; 155 struct cfdata *cf = dev->dv_cfdata; 156 const char *name = cf->cf_name; 157 158 if (found) 159 return; 160 161 if (!initted) { 162 scsiboot = (strcmp(b->protocol, "SCSI") == 0); 163 netboot = (strcmp(b->protocol, "BOOTP") == 0) || 164 (strcmp(b->protocol, "MOP") == 0); 165 #if 0 166 printf("scsiboot = %d, netboot = %d\n", scsiboot, netboot); 167 #endif 168 initted = 1; 169 } 170 171 /* 172 * for scsi boot, we look for "tcds", make sure it has the 173 * right slot number, then find the "asc" on this tcds that 174 * as the right channel. then we find the actual scsi 175 * device we came from. note: no SCSI LUN support (yet). 176 */ 177 if (scsiboot && (strcmp(name, "tcds") == 0)) { 178 struct tc_attach_args *tcargs = aux; 179 180 if (b->slot != tcargs->ta_slot) 181 return; 182 183 tcdsdev = dev; 184 #if 0 185 printf("\ntcdsdev = %s\n", dev->dv_xname); 186 #endif 187 } 188 if (scsiboot && tcdsdev && 189 (strcmp(name, "asc") == 0)) { 190 struct tcdsdev_attach_args *ta = aux; 191 192 if (parent != (struct device *)tcdsdev) 193 return; 194 195 if (ta->tcdsda_chip != b->channel) 196 return; 197 198 scsidev = dev; 199 #if 0 200 printf("\nscsidev = %s\n", dev->dv_xname); 201 #endif 202 } 203 204 if (scsiboot && scsidev && 205 (strcmp(name, "sd") == 0 || 206 strcmp(name, "st") == 0 || 207 strcmp(name, "cd") == 0)) { 208 struct scsipibus_attach_args *sa = aux; 209 210 if (parent->dv_parent != scsidev) 211 return; 212 213 if (b->unit / 100 != sa->sa_periph->periph_target) 214 return; 215 216 /* XXX LUN! */ 217 218 switch (b->boot_dev_type) { 219 case 0: 220 if (strcmp(name, "sd") && 221 strcmp(name, "cd")) 222 return; 223 break; 224 case 1: 225 if (strcmp(name, "st")) 226 return; 227 break; 228 default: 229 return; 230 } 231 232 /* we've found it! */ 233 booted_device = dev; 234 #if 0 235 printf("\nbooted_device = %s\n", booted_device->dv_xname); 236 #endif 237 found = 1; 238 } 239 240 if (netboot) { 241 if (b->slot == 5 && strcmp(name, "le") == 0 && 242 strcmp(parent->dv_cfdata->cf_name, "ioasic") 243 == 0) { 244 /* 245 * no need to check ioasic_attach_args, since only 246 * one le on ioasic. 247 */ 248 249 booted_device = dev; 250 #if 0 251 printf("\nbooted_device = %s\n", booted_device->dv_xname); 252 #endif 253 found = 1; 254 return; 255 } 256 257 /* 258 * XXX GENERIC SUPPORT FOR TC NETWORK BOARDS 259 */ 260 } 261 } 262