1 /* $NetBSD: dec_3000_300.c,v 1.34 2001/04/25 17:53:04 bouyer 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.34 2001/04/25 17:53:04 bouyer Exp $"); 37 38 #include "opt_new_scc_driver.h" 39 40 #include <sys/param.h> 41 #include <sys/systm.h> 42 #include <sys/device.h> 43 #include <sys/termios.h> 44 45 #include <machine/rpb.h> 46 #include <machine/autoconf.h> 47 #include <machine/conf.h> 48 49 #include <dev/tc/tcvar.h> 50 #include <dev/tc/tcdsvar.h> 51 #include <alpha/tc/tc_3000_300.h> 52 #ifndef NEW_SCC_DRIVER 53 #include <alpha/tc/sccvar.h> 54 #endif 55 56 #include <machine/z8530var.h> 57 #include <dev/tc/zs_ioasicvar.h> 58 59 #include <dev/scsipi/scsi_all.h> 60 #include <dev/scsipi/scsipi_all.h> 61 #include <dev/scsipi/scsiconf.h> 62 63 #include "wsdisplay.h" 64 65 void dec_3000_300_init __P((void)); 66 static void dec_3000_300_cons_init __P((void)); 67 static void dec_3000_300_device_register __P((struct device *, void *)); 68 69 const struct alpha_variation_table dec_3000_300_variations[] = { 70 { SV_ST_PELICAN, "DEC 3000/300 (\"Pelican\")" }, 71 { SV_ST_PELICA, "DEC 3000/300L (\"Pelica\")" }, 72 { SV_ST_PELICANPLUS, "DEC 3000/300X (\"Pelican+\")" }, 73 { SV_ST_PELICAPLUS, "DEC 3000/300LX (\"Pelica+\")" }, 74 { 0, NULL }, 75 }; 76 77 void 78 dec_3000_300_init() 79 { 80 u_int64_t variation; 81 82 platform.family = "DEC 3000/300 (\"Pelican\")"; 83 84 if ((platform.model = alpha_dsr_sysname()) == NULL) { 85 variation = hwrpb->rpb_variation & SV_ST_MASK; 86 if ((platform.model = alpha_variation_name(variation, 87 dec_3000_300_variations)) == NULL) 88 platform.model = alpha_unknown_sysname(); 89 } 90 91 platform.iobus = "tcasic"; 92 platform.cons_init = dec_3000_300_cons_init; 93 platform.device_register = dec_3000_300_device_register; 94 } 95 96 static void 97 dec_3000_300_cons_init() 98 { 99 struct ctb *ctb; 100 101 ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); 102 103 #ifndef NEW_SCC_DRIVER 104 switch (ctb->ctb_term_type) { 105 case CTB_GRAPHICS: 106 alpha_donot_kludge_scc = 1; 107 return; 108 case CTB_PRINTERPORT: 109 return; 110 default: 111 goto badconsole; 112 } 113 #else 114 switch (ctb->ctb_term_type) { 115 case CTB_GRAPHICS: 116 #if NWSDISPLAY > 0 117 /* display console ... */ 118 if (zs_ioasic_lk201_cnattach(0x1a0000000, 0x00180000, 0) == 0 && 119 tc_3000_300_fb_cnattach( 120 CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot)) == 0) { 121 break; 122 } 123 #endif 124 printf("consinit: Unable to init console on keyboard and "); 125 printf("TURBOchannel slot 0x%lx.\n", ctb->ctb_turboslot); 126 printf("Using serial console.\n"); 127 /* FALLTHROUGH */ 128 129 case CTB_PRINTERPORT: 130 /* serial console ... */ 131 /* 132 * XXX This could stand some cleanup... 133 */ 134 { 135 /* 136 * Delay to allow PROM putchars to complete. 137 * FIFO depth * character time. 138 * character time = (1000000 / (defaultrate / 10)) 139 */ 140 DELAY(160000000 / 9600); /* XXX */ 141 142 /* 143 * Console is channel B of the first SCC. 144 * XXX Should use ctb_line_off to get the 145 * XXX line parameters. 146 */ 147 zs_ioasic_cnattach(0x1a0000000, 0x00100000, 1); 148 break; 149 } 150 151 default: 152 goto badconsole; 153 } 154 #endif 155 return; 156 badconsole: 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 160 panic("consinit: unknown console type %lu\n", 161 ctb->ctb_term_type); 162 } 163 164 static void 165 dec_3000_300_device_register(dev, aux) 166 struct device *dev; 167 void *aux; 168 { 169 static int found, initted, scsiboot, netboot; 170 static struct device *scsidev; 171 static struct device *tcdsdev; 172 struct bootdev_data *b = bootdev_data; 173 struct device *parent = dev->dv_parent; 174 struct cfdata *cf = dev->dv_cfdata; 175 struct cfdriver *cd = cf->cf_driver; 176 177 if (found) 178 return; 179 180 if (!initted) { 181 scsiboot = (strcmp(b->protocol, "SCSI") == 0); 182 netboot = (strcmp(b->protocol, "BOOTP") == 0) || 183 (strcmp(b->protocol, "MOP") == 0); 184 #if 0 185 printf("scsiboot = %d, netboot = %d\n", scsiboot, netboot); 186 #endif 187 initted = 1; 188 } 189 190 /* 191 * for scsi boot, we look for "tcds", make sure it has the 192 * right slot number, then find the "asc" on this tcds that 193 * as the right channel. then we find the actual scsi 194 * device we came from. note: no SCSI LUN support (yet). 195 */ 196 if (scsiboot && (strcmp(cd->cd_name, "tcds") == 0)) { 197 struct tc_attach_args *tcargs = aux; 198 199 if (b->slot != tcargs->ta_slot) 200 return; 201 202 tcdsdev = dev; 203 #if 0 204 printf("\ntcdsdev = %s\n", dev->dv_xname); 205 #endif 206 } 207 if (scsiboot && tcdsdev && 208 (strcmp(cd->cd_name, "asc") == 0)) { 209 struct tcdsdev_attach_args *ta = aux; 210 211 if (parent != (struct device *)tcdsdev) 212 return; 213 214 if (ta->tcdsda_chip != b->channel) 215 return; 216 217 scsidev = dev; 218 #if 0 219 printf("\nscsidev = %s\n", dev->dv_xname); 220 #endif 221 } 222 223 if (scsiboot && scsidev && 224 (strcmp(cd->cd_name, "sd") == 0 || 225 strcmp(cd->cd_name, "st") == 0 || 226 strcmp(cd->cd_name, "cd") == 0)) { 227 struct scsipibus_attach_args *sa = aux; 228 229 if (parent->dv_parent != scsidev) 230 return; 231 232 if (b->unit / 100 != sa->sa_periph->periph_target) 233 return; 234 235 /* XXX LUN! */ 236 237 switch (b->boot_dev_type) { 238 case 0: 239 if (strcmp(cd->cd_name, "sd") && 240 strcmp(cd->cd_name, "cd")) 241 return; 242 break; 243 case 1: 244 if (strcmp(cd->cd_name, "st")) 245 return; 246 break; 247 default: 248 return; 249 } 250 251 /* we've found it! */ 252 booted_device = dev; 253 #if 0 254 printf("\nbooted_device = %s\n", booted_device->dv_xname); 255 #endif 256 found = 1; 257 } 258 259 if (netboot) { 260 if (b->slot == 5 && strcmp(cd->cd_name, "le") == 0 && 261 strcmp(parent->dv_cfdata->cf_driver->cd_name, "ioasic") 262 == 0) { 263 /* 264 * no need to check ioasic_attach_args, since only 265 * one le on ioasic. 266 */ 267 268 booted_device = dev; 269 #if 0 270 printf("\nbooted_device = %s\n", booted_device->dv_xname); 271 #endif 272 found = 1; 273 return; 274 } 275 276 /* 277 * XXX GENERIC SUPPORT FOR TC NETWORK BOARDS 278 */ 279 } 280 } 281