apecs.c revision 1.18 1 /* $NetBSD: apecs.c,v 1.18 1997/04/06 23:32:18 cgd 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 #ifdef DEC_2100_A50
48 #include <alpha/pci/pci_2100_a50.h>
49 #endif
50
51 int apecsmatch __P((struct device *, struct cfdata *, 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 struct cfdata *match;
72 void *aux;
73 {
74 struct confargs *ca = aux;
75
76 /* Make sure that we're looking for an APECS. */
77 if (strcmp(ca->ca_name, apecs_cd.cd_name) != 0)
78 return (0);
79
80 if (apecsfound)
81 return (0);
82
83 return (1);
84 }
85
86 /*
87 * Set up the chipset's function pointers.
88 */
89 void
90 apecs_init(acp, mallocsafe)
91 struct apecs_config *acp;
92 int mallocsafe;
93 {
94 acp->ac_comanche_pass2 =
95 (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
96 acp->ac_memwidth =
97 (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
98 acp->ac_epic_pass2 =
99 (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
100
101 acp->ac_haxr1 = REGVAL(EPIC_HAXR1);
102 acp->ac_haxr2 = REGVAL(EPIC_HAXR2);
103
104 /*
105 * Can't set up SGMAP data here; can be called before malloc().
106 * XXX THIS COMMENT NO LONGER MAKES SENSE.
107 */
108
109 if (!acp->ac_initted) {
110 /* don't do these twice since they set up extents */
111 acp->ac_iot = apecs_bus_io_init(acp);
112 acp->ac_memt = apecs_bus_mem_init(acp);
113 }
114 acp->ac_mallocsafe = mallocsafe;
115
116 apecs_pci_init(&acp->ac_pc, acp);
117
118 /* Turn off DMA window enables in PCI Base Reg 1. */
119 REGVAL(EPIC_PCI_BASE_1) = 0;
120 alpha_mb();
121
122 /* XXX SGMAP? */
123
124 /* XXX XXX BEGIN XXX XXX */
125 { /* XXX */
126 extern vm_offset_t alpha_XXX_dmamap_or; /* XXX */
127 alpha_XXX_dmamap_or = 0x40000000; /* XXX */
128 } /* XXX */
129 /* XXX XXX END XXX XXX */
130
131 acp->ac_initted = 1;
132 }
133
134 void
135 apecsattach(parent, self, aux)
136 struct device *parent, *self;
137 void *aux;
138 {
139 struct apecs_softc *sc = (struct apecs_softc *)self;
140 struct apecs_config *acp;
141 struct pcibus_attach_args pba;
142
143 /* note that we've attached the chipset; can't have 2 APECSes. */
144 apecsfound = 1;
145
146 /*
147 * set up the chipset's info; done once at console init time
148 * (maybe), but doesn't hurt to do twice.
149 */
150 acp = sc->sc_acp = &apecs_configuration;
151 apecs_init(acp, 1);
152
153 /* XXX SGMAP FOO */
154
155 printf(": DECchip %s Core Logic chipset\n",
156 acp->ac_memwidth == 128 ? "21072" : "21071");
157 printf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
158 self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
159 printf("%s: DC21071-DA pass %d\n", self->dv_xname,
160 acp->ac_epic_pass2 ? 2 : 1);
161 /* XXX print bcache size */
162
163 if (!acp->ac_epic_pass2)
164 printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
165
166 switch (hwrpb->rpb_type) {
167 #ifdef DEC_2100_A50
168 case ST_DEC_2100_A50:
169 pci_2100_a50_pickintr(acp);
170 break;
171 #endif
172
173 default:
174 panic("apecsattach: shouldn't be here, really...");
175 }
176
177 pba.pba_busname = "pci";
178 pba.pba_iot = acp->ac_iot;
179 pba.pba_memt = acp->ac_memt;
180 pba.pba_pc = &acp->ac_pc;
181 pba.pba_bus = 0;
182 config_found(self, &pba, apecsprint);
183 }
184
185 static int
186 apecsprint(aux, pnp)
187 void *aux;
188 const char *pnp;
189 {
190 register struct pcibus_attach_args *pba = aux;
191
192 /* only PCIs can attach to APECSes; easy. */
193 if (pnp)
194 printf("%s at %s", pba->pba_busname, pnp);
195 printf(" bus %d", pba->pba_bus);
196 return (UNCONF);
197 }
198