Annotation of sys/arch/alpha/alpha/dec_6600.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: dec_6600.c,v 1.9 2006/11/28 16:56:50 dlg Exp $ */
2: /* $NetBSD: dec_6600.c,v 1.7 2000/06/20 03:48:54 matt Exp $ */
3:
4: /*
5: * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
6: * All rights reserved.
7: *
8: * Author: Chris G. Demetriou
9: *
10: * Permission to use, copy, modify and distribute this software and
11: * its documentation is hereby granted, provided that both the copyright
12: * notice and this permission notice appear in all copies of the
13: * software, derivative works or modified versions, and any portions
14: * thereof, and that both notices appear in supporting documentation.
15: *
16: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18: * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19: *
20: * Carnegie Mellon requests users of this software to return to
21: *
22: * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23: * School of Computer Science
24: * Carnegie Mellon University
25: * Pittsburgh PA 15213-3890
26: *
27: * any improvements or extensions that they make and grant Carnegie the
28: * rights to redistribute these changes.
29: */
30:
31: #include <sys/param.h>
32: #include <sys/systm.h>
33: #include <sys/device.h>
34: #include <sys/termios.h>
35: #include <dev/cons.h>
36:
37: #include <machine/rpb.h>
38: #include <machine/autoconf.h>
39: #include <machine/cpuconf.h>
40: #include <machine/bus.h>
41:
42: #include <dev/ic/comreg.h>
43: #include <dev/ic/comvar.h>
44:
45: #include <dev/isa/isareg.h>
46: #include <dev/isa/isavar.h>
47: #include <dev/ic/i8042reg.h>
48: #include <dev/ic/pckbcvar.h>
49: #include <dev/pci/pcireg.h>
50: #include <dev/pci/pcivar.h>
51:
52: #include <alpha/pci/tsreg.h>
53: #include <alpha/pci/tsvar.h>
54:
55: #include <scsi/scsi_all.h>
56: #include <scsi/scsiconf.h>
57: #include <dev/ata/atavar.h>
58:
59: #include "pckbd.h"
60:
61: #ifndef CONSPEED
62: #define CONSPEED TTYDEF_SPEED
63: #endif
64:
65: #define DR_VERBOSE(f) while (0)
66:
67: static int comcnrate __attribute__((unused)) = CONSPEED;
68:
69: void dec_6600_init(void);
70: static void dec_6600_cons_init(void);
71: static void dec_6600_device_register(struct device *, void *);
72:
73: void
74: dec_6600_init()
75: {
76:
77: platform.family = "6600";
78:
79: if ((platform.model = alpha_dsr_sysname()) == NULL) {
80: /* XXX Don't know the system variations, yet. */
81: platform.model = alpha_unknown_sysname();
82: }
83:
84: platform.iobus = "tsc";
85: platform.cons_init = dec_6600_cons_init;
86: platform.device_register = dec_6600_device_register;
87: STQP(TS_C_DIM0) = 0UL;
88: STQP(TS_C_DIM1) = 0UL;
89: }
90:
91: static void
92: dec_6600_cons_init()
93: {
94: struct ctb *ctb;
95: u_int64_t ctbslot;
96: struct tsp_config *tsp;
97:
98: ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
99: ctbslot = ctb->ctb_turboslot;
100:
101: /* Console hose defaults to hose 0. */
102: tsp_console_hose = 0;
103:
104: tsp = tsp_init(0, tsp_console_hose);
105:
106: switch (ctb->ctb_term_type) {
107: case CTB_PRINTERPORT:
108: /* serial console ... */
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 CTB_GRAPHICS:
127: #if NPCKBD > 0
128: /* display console ... */
129: /* XXX */
130: (void) pckbc_cnattach(&tsp->pc_iot, IO_KBD, KBCMDP,
131: 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_console_hose = CTB_TURBOSLOT_HOSE(ctbslot);
139: tsp = tsp_init(0, tsp_console_hose);
140: pci_display_console(&tsp->pc_iot, &tsp->pc_memt,
141: &tsp->pc_pc, CTB_TURBOSLOT_BUS(ctbslot),
142: CTB_TURBOSLOT_SLOT(ctbslot), 0);
143: }
144: #else
145: panic("not configured to use display && keyboard console");
146: #endif
147: break;
148:
149: default:
150: printf("ctb_term_type = 0x%lx ctb_turboslot = 0x%lx"
151: " hose = %ld\n", ctb->ctb_term_type, ctbslot,
152: CTB_TURBOSLOT_HOSE(ctbslot));
153:
154: panic("consinit: unknown console type %ld",
155: ctb->ctb_term_type);
156: }
157: }
158:
159: static void
160: dec_6600_device_register(dev, aux)
161: struct device *dev;
162: void *aux;
163: {
164: static int found, initted, diskboot, netboot;
165: static struct device *primarydev, *pcidev, *ctrlrdev;
166: struct bootdev_data *b = bootdev_data;
167: struct device *parent = dev->dv_parent;
168: struct cfdata *cf = dev->dv_cfdata;
169: struct cfdriver *cd = cf->cf_driver;
170:
171: if (found)
172: return;
173:
174: if (!initted) {
175: diskboot = (strncasecmp(b->protocol, "SCSI", 4) == 0) ||
176: (strncasecmp(b->protocol, "IDE", 3) == 0);
177: netboot = (strncasecmp(b->protocol, "BOOTP", 5) == 0) ||
178: (strncasecmp(b->protocol, "MOP", 3) == 0);
179: DR_VERBOSE(printf("diskboot = %d, netboot = %d\n", diskboot,
180: netboot));
181: initted = 1;
182: }
183:
184: if (primarydev == NULL) {
185: if (strcmp(cd->cd_name, "tsp"))
186: return;
187: else {
188: struct tsp_attach_args *tsp = aux;
189:
190: if (b->bus != tsp->tsp_slot)
191: return;
192: primarydev = dev;
193: DR_VERBOSE(printf("\nprimarydev = %s\n",
194: dev->dv_xname));
195: return;
196: }
197: }
198:
199: if (pcidev == NULL) {
200: if (strcmp(cd->cd_name, "pci"))
201: return;
202: /*
203: * Try to find primarydev anywhere in the ancestry. This is
204: * necessary if the PCI bus is hidden behind a bridge.
205: */
206: while (parent) {
207: if (parent == primarydev)
208: break;
209: parent = parent->dv_parent;
210: }
211: if (!parent)
212: return;
213: else {
214: struct pcibus_attach_args *pba = aux;
215:
216: if ((b->slot / 1000) != pba->pba_bus)
217: return;
218:
219: pcidev = dev;
220: DR_VERBOSE(printf("\npcidev = %s\n", dev->dv_xname));
221: return;
222: }
223: }
224:
225: if (ctrlrdev == NULL) {
226: if (parent != pcidev)
227: return;
228: else {
229: struct pci_attach_args *pa = aux;
230: int slot;
231:
232: slot = pa->pa_bus * 1000 + pa->pa_function * 100 +
233: pa->pa_device;
234: if (b->slot != slot)
235: return;
236:
237: if (netboot) {
238: booted_device = dev;
239: DR_VERBOSE(printf("\nbooted_device = %s\n",
240: dev->dv_xname));
241: found = 1;
242: } else {
243: ctrlrdev = dev;
244: DR_VERBOSE(printf("\nctrlrdev = %s\n",
245: dev->dv_xname));
246: }
247: return;
248: }
249: }
250:
251: if (!diskboot)
252: return;
253:
254: if (!strcmp(cd->cd_name, "sd") || !strcmp(cd->cd_name, "st") ||
255: !strcmp(cd->cd_name, "cd")) {
256: struct scsi_attach_args *sa = aux;
257: struct scsi_link *periph = sa->sa_sc_link;
258: int unit;
259:
260: if (parent->dv_parent != ctrlrdev)
261: return;
262:
263: unit = periph->target * 100 + periph->lun;
264: if (b->unit != unit)
265: return;
266:
267: /* we've found it! */
268: booted_device = dev;
269: DR_VERBOSE(printf("\nbooted_device = %s\n", dev->dv_xname));
270: found = 1;
271: }
272:
273: /*
274: * Support to boot from IDE drives.
275: */
276: if (!strcmp(cd->cd_name, "wd")) {
277: struct ata_atapi_attach *aa_link = aux;
278:
279: if ((strncmp("pciide", parent->dv_xname, 6) != 0))
280: return;
281: if (parent != ctrlrdev)
282: return;
283:
284: DR_VERBOSE(printf("\nAtapi info: drive: %d, channel %d\n",
285: aa_link->aa_drv_data->drive, aa_link->aa_channel));
286: DR_VERBOSE(printf("Bootdev info: unit: %d, channel: %d\n",
287: b->unit, b->channel));
288: if (b->unit != aa_link->aa_drv_data->drive ||
289: b->channel != aa_link->aa_channel)
290: return;
291:
292: /* we've found it! */
293: booted_device = dev;
294: DR_VERBOSE(printf("booted_device = %s\n", dev->dv_xname));
295: found = 1;
296: }
297: }
CVSweb