apecs.c revision 1.11 1 /* $NetBSD: apecs.c,v 1.11 1996/10/10 23:50:58 christos 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 (at) 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/param.h>
31 #include <sys/systm.h>
32 #include <sys/kernel.h>
33 #include <sys/malloc.h>
34 #include <sys/device.h>
35 #include <vm/vm.h>
36
37 #include <machine/autoconf.h>
38 #include <machine/rpb.h>
39
40 #include <dev/isa/isareg.h>
41 #include <dev/isa/isavar.h>
42
43 #include <dev/pci/pcireg.h>
44 #include <dev/pci/pcivar.h>
45 #include <alpha/pci/apecsreg.h>
46 #include <alpha/pci/apecsvar.h>
47 #if defined(DEC_2100_A50)
48 #include <alpha/pci/pci_2100_a50.h>
49 #endif
50
51 int apecsmatch __P((struct device *, void *, void *));
52 void apecsattach __P((struct device *, struct device *, void *));
53
54 struct cfattach apecs_ca = {
55 sizeof(struct apecs_softc), apecsmatch, apecsattach,
56 };
57
58 struct cfdriver apecs_cd = {
59 NULL, "apecs", DV_DULL,
60 };
61
62 static int apecsprint __P((void *, const char *pnp));
63
64 /* There can be only one. */
65 int apecsfound;
66 struct apecs_config apecs_configuration;
67
68 int
69 apecsmatch(parent, match, aux)
70 struct device *parent;
71 void *match, *aux;
72 {
73 struct confargs *ca = aux;
74
75 /* Make sure that we're looking for an APECS. */
76 if (strcmp(ca->ca_name, apecs_cd.cd_name) != 0)
77 return (0);
78
79 if (apecsfound)
80 return (0);
81
82 return (1);
83 }
84
85 /*
86 * Set up the chipset's function pointers.
87 */
88 void
89 apecs_init(acp)
90 struct apecs_config *acp;
91 {
92
93 acp->ac_comanche_pass2 =
94 (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
95 acp->ac_memwidth =
96 (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
97 acp->ac_epic_pass2 =
98 (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
99
100 /*
101 * Can't set up SGMAP data here; can be called before malloc().
102 */
103
104 apecs_lca_bus_io_init(&acp->ac_bc, acp);
105 apecs_lca_bus_mem_init(&acp->ac_bc, acp);
106 apecs_pci_init(&acp->ac_pc, acp);
107
108 /* Turn off DMA window enables in PCI Base Reg 1. */
109 REGVAL(EPIC_PCI_BASE_1) = 0;
110 alpha_mb();
111
112 /* XXX SGMAP? */
113 }
114
115 void
116 apecsattach(parent, self, aux)
117 struct device *parent, *self;
118 void *aux;
119 {
120 struct apecs_softc *sc = (struct apecs_softc *)self;
121 struct apecs_config *acp;
122 struct pcibus_attach_args pba;
123
124 /* note that we've attached the chipset; can't have 2 APECSes. */
125 apecsfound = 1;
126
127 /*
128 * set up the chipset's info; done once at console init time
129 * (maybe), but doesn't hurt to do twice.
130 */
131 acp = sc->sc_acp = &apecs_configuration;
132 apecs_init(acp);
133
134 /* XXX SGMAP FOO */
135
136 kprintf(": DECchip %s Core Logic chipset\n",
137 acp->ac_memwidth == 128 ? "21072" : "21071");
138 kprintf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
139 self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
140 kprintf("%s: DC21071-DA pass %d\n", self->dv_xname,
141 acp->ac_epic_pass2 ? 2 : 1);
142 /* XXX print bcache size */
143
144 if (!acp->ac_epic_pass2)
145 kprintf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
146
147 switch (hwrpb->rpb_type) {
148 #if defined(DEC_2100_A50)
149 case ST_DEC_2100_A50:
150 pci_2100_a50_pickintr(acp);
151 break;
152 #endif
153 default:
154 panic("apecsattach: shouldn't be here, really...");
155 }
156
157 pba.pba_busname = "pci";
158 pba.pba_bc = &acp->ac_bc;
159 pba.pba_pc = &acp->ac_pc;
160 pba.pba_bus = 0;
161 config_found(self, &pba, apecsprint);
162 }
163
164 static int
165 apecsprint(aux, pnp)
166 void *aux;
167 const char *pnp;
168 {
169 register struct pcibus_attach_args *pba = aux;
170
171 /* only PCIs can attach to APECSes; easy. */
172 if (pnp)
173 kprintf("%s at %s", pba->pba_busname, pnp);
174 kprintf(" bus %d", pba->pba_bus);
175 return (UNCONF);
176 }
177