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