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