dec_6600.c revision 1.2
1/* $NetBSD: dec_6600.c,v 1.2 1999/12/03 22:48:22 thorpej Exp $ */ 2 3/* 4 * Copyright (c) 1995, 1996, 1997 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#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 31 32__KERNEL_RCSID(0, "$NetBSD: dec_6600.c,v 1.2 1999/12/03 22:48:22 thorpej Exp $"); 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/device.h> 37#include <sys/termios.h> 38#include <dev/cons.h> 39 40#include <machine/rpb.h> 41#include <machine/autoconf.h> 42#include <machine/conf.h> 43#include <machine/bus.h> 44 45#include <dev/ic/comreg.h> 46#include <dev/ic/comvar.h> 47 48#include <dev/isa/isareg.h> 49#include <dev/isa/isavar.h> 50#include <dev/ic/pckbcvar.h> 51#include <dev/pci/pcireg.h> 52#include <dev/pci/pcivar.h> 53 54#include <alpha/pci/tsreg.h> 55#include <alpha/pci/tsvar.h> 56 57#include <dev/scsipi/scsi_all.h> 58#include <dev/scsipi/scsipi_all.h> 59#include <dev/scsipi/scsiconf.h> 60 61#include "pckbd.h" 62 63#ifndef CONSPEED 64#define CONSPEED TTYDEF_SPEED 65#endif 66 67#define DR_VERBOSE(f) while (0) 68 69static int comcnrate __attribute__((unused)) = CONSPEED; 70 71void dec_6600_init __P((void)); 72static void dec_6600_cons_init __P((void)); 73static void dec_6600_device_register __P((struct device *, void *)); 74 75void 76dec_6600_init() 77{ 78 79 platform.family = "6600"; 80 81 if ((platform.model = alpha_dsr_sysname()) == NULL) { 82 /* XXX Don't know the system variations, yet. */ 83 platform.model = alpha_unknown_sysname(); 84 } 85 86 platform.iobus = "tsc"; 87 platform.cons_init = dec_6600_cons_init; 88 platform.device_register = dec_6600_device_register; 89 STQP(TS_C_DIM0) = 0UL; 90 STQP(TS_C_DIM1) = 0UL; 91} 92 93static void 94dec_6600_cons_init() 95{ 96 struct ctb *ctb; 97 u_int64_t ctbslot; 98 struct tsp_config *tsp; 99 100 ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); 101 ctbslot = ctb->ctb_turboslot; 102 103 tsp = tsp_init(0, 0); 104 105 switch (ctb->ctb_term_type) { 106 case 2: 107 /* serial console ... */ 108 assert(CTB_TURBOSLOT_HOSE(ctbslot) == 0); 109 /* XXX */ 110 { 111 /* 112 * Delay to allow PROM putchars to complete. 113 * FIFO depth * character time, 114 * character time = (1000000 / (defaultrate / 10)) 115 */ 116 DELAY(160000000 / comcnrate); 117 118 if(comcnattach(&tsp->pc_iot, 0x3f8, comcnrate, 119 COM_FREQ, 120 (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) 121 panic("can't init serial console"); 122 123 break; 124 } 125 126 case 3: 127#if NPCKBD > 0 128 /* display console ... */ 129 /* XXX */ 130 (void) pckbc_cnattach(&tsp->pc_iot, IO_KBD, PCKBC_KBD_SLOT); 131 132 if (CTB_TURBOSLOT_TYPE(ctbslot) == 133 CTB_TURBOSLOT_TYPE_ISA) 134 isa_display_console(&tsp->pc_iot, &tsp->pc_memt); 135 else { 136 /* The display PCI might be different */ 137 tsp = tsp_init(0, CTB_TURBOSLOT_HOSE(ctbslot)); 138 pci_display_console(&tsp->pc_iot, &tsp->pc_memt, 139 &tsp->pc_pc, CTB_TURBOSLOT_BUS(ctbslot), 140 CTB_TURBOSLOT_SLOT(ctbslot), 0); 141 } 142#else 143 panic("not configured to use display && keyboard console"); 144#endif 145 break; 146 147 default: 148 printf("ctb_term_type = 0x%lx ctb_turboslot = 0x%lx" 149 " hose = %ld\n", ctb->ctb_term_type, ctbslot, 150 CTB_TURBOSLOT_HOSE(ctbslot)); 151 152 panic("consinit: unknown console type %ld\n", 153 ctb->ctb_term_type); 154 } 155} 156 157static void 158dec_6600_device_register(dev, aux) 159 struct device *dev; 160 void *aux; 161{ 162 static int found, initted, scsiboot, ideboot, netboot; 163 static struct device *primarydev, *pcidev, *scsipidev; 164 struct bootdev_data *b = bootdev_data; 165 struct device *parent = dev->dv_parent; 166 struct cfdata *cf = dev->dv_cfdata; 167 struct cfdriver *cd = cf->cf_driver; 168 169 if (found) 170 return; 171 172 if (!initted) { 173 scsiboot = (strcmp(b->protocol, "SCSI") == 0); 174 netboot = (strcmp(b->protocol, "BOOTP") == 0); 175 /* 176 * Add an extra check to boot from ide drives: 177 * Newer SRM firmware use the protocol identifier IDE, 178 * older SRM firmware use the protocol identifier SCSI. 179 */ 180 ideboot = (strcmp(b->protocol, "IDE") == 0); 181 DR_VERBOSE(printf("scsiboot = %d, ideboot = %d, netboot = %d\n", 182 scsiboot, ideboot, netboot)); 183 initted = 1; 184 } 185 if (primarydev == NULL) { 186 if (strcmp(cd->cd_name, "tsp")) 187 return; 188 else { 189 struct tsp_attach_args *tsp = aux; 190 191 if (b->bus != tsp->tsp_slot) 192 return; 193 primarydev = dev; 194 DR_VERBOSE(printf("\nprimarydev = %s\n", 195 primarydev->dv_xname)); 196 return; 197 } 198 } 199 if (pcidev == NULL) { 200 if (parent != primarydev) 201 return; 202 if (strcmp(cd->cd_name, "pci")) 203 return; 204 else { 205 struct pcibus_attach_args *pba = aux; 206 207 if ((b->slot / 1000) != pba->pba_bus) 208 return; 209 210 pcidev = dev; 211 DR_VERBOSE(printf("\npcidev = %s\n", pcidev->dv_xname)); 212 return; 213 } 214 } 215 if ((ideboot || scsiboot) && scsipidev == NULL) { 216 if (parent != pcidev) 217 return; 218 else { 219 struct pci_attach_args *pa = aux; 220 221 if (b->slot % 1000 / 100 != pa->pa_function) 222 return; 223 if (b->slot % 100 != pa->pa_device) 224 return; 225 226 scsipidev = dev; 227 DR_VERBOSE(printf("\nscsipidev = %s\n", 228 scsipidev->dv_xname)); 229 return; 230 } 231 } 232 if ((scsiboot || ideboot) && 233 (!strcmp(cd->cd_name, "sd") || 234 !strcmp(cd->cd_name, "st") || 235 !strcmp(cd->cd_name, "cd"))) { 236 struct scsipibus_attach_args *sa = aux; 237 238 if (parent->dv_parent != scsipidev) 239 return; 240 241 if (b->unit / 100 != sa->sa_sc_link->scsipi_scsi.target) 242 return; 243 244 /* XXX LUN! */ 245 246 switch (b->boot_dev_type) { 247 case 0: 248 if (strcmp(cd->cd_name, "sd") && 249 strcmp(cd->cd_name, "cd")) 250 return; 251 break; 252 case 1: 253 if (strcmp(cd->cd_name, "st")) 254 return; 255 break; 256 default: 257 return; 258 } 259 260 /* we've found it! */ 261 booted_device = dev; 262 DR_VERBOSE(printf("\nbooted_device = %s\n", 263 booted_device->dv_xname)); 264 found = 1; 265 } 266 267 /* 268 * Support to boot from IDE drives. 269 * Should work with all SRM firmware versions, but is at the 270 * moment limited to hard disks. Support for IDE CD ROM is 271 * included above, under the theory that it will always be 272 * via the pci ide controller. 273 */ 274 if ((ideboot || scsiboot) && !strcmp(cd->cd_name, "wd")) { 275 if ((strncmp("pciide", parent->dv_xname, 6) != 0)) { 276 return; 277 } else { 278 if (parent != scsipidev) 279 return; 280 } 281 282 /* we've found it! */ 283 booted_device = dev; 284 DR_VERBOSE(printf("\nbooted_device = %s\n", 285 booted_device->dv_xname)); 286 found = 1; 287 } 288 if (netboot) { 289 if (parent != pcidev) 290 return; 291 else { 292 struct pci_attach_args *pa = aux; 293 294 if (b->slot % 1000 / 100 != pa->pa_function) 295 return; 296 if ((b->slot % 100) != pa->pa_device) 297 return; 298 299 booted_device = dev; 300 DR_VERBOSE(printf("\nbooted_device = %s\n", 301 booted_device->dv_xname)); 302 found = 1; 303 return; 304 } 305 } 306} 307