apecs.c revision 1.34.10.1 1 1.34.10.1 thorpej /* $NetBSD: apecs.c,v 1.34.10.1 1999/06/21 00:46:09 thorpej Exp $ */
2 1.1 cgd
3 1.1 cgd /*
4 1.7 cgd * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 1.1 cgd * All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Author: Chris G. Demetriou
8 1.1 cgd *
9 1.1 cgd * Permission to use, copy, modify and distribute this software and
10 1.1 cgd * its documentation is hereby granted, provided that both the copyright
11 1.1 cgd * notice and this permission notice appear in all copies of the
12 1.1 cgd * software, derivative works or modified versions, and any portions
13 1.1 cgd * thereof, and that both notices appear in supporting documentation.
14 1.1 cgd *
15 1.1 cgd * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 1.1 cgd * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 1.1 cgd * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 1.1 cgd *
19 1.1 cgd * Carnegie Mellon requests users of this software to return to
20 1.1 cgd *
21 1.1 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 1.1 cgd * School of Computer Science
23 1.1 cgd * Carnegie Mellon University
24 1.1 cgd * Pittsburgh PA 15213-3890
25 1.1 cgd *
26 1.1 cgd * any improvements or extensions that they make and grant Carnegie the
27 1.1 cgd * rights to redistribute these changes.
28 1.1 cgd */
29 1.20 cgd
30 1.27 thorpej #include "opt_dec_2100_a50.h"
31 1.27 thorpej #include "opt_dec_eb64plus.h"
32 1.34 ross #include "opt_dec_1000a.h"
33 1.34 ross #include "opt_dec_1000.h"
34 1.27 thorpej
35 1.21 cgd #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
36 1.21 cgd
37 1.34.10.1 thorpej __KERNEL_RCSID(0, "$NetBSD: apecs.c,v 1.34.10.1 1999/06/21 00:46:09 thorpej Exp $");
38 1.1 cgd
39 1.1 cgd #include <sys/param.h>
40 1.1 cgd #include <sys/systm.h>
41 1.1 cgd #include <sys/kernel.h>
42 1.1 cgd #include <sys/malloc.h>
43 1.1 cgd #include <sys/device.h>
44 1.1 cgd #include <vm/vm.h>
45 1.1 cgd
46 1.1 cgd #include <machine/autoconf.h>
47 1.1 cgd #include <machine/rpb.h>
48 1.1 cgd
49 1.1 cgd #include <dev/isa/isareg.h>
50 1.1 cgd #include <dev/isa/isavar.h>
51 1.1 cgd
52 1.1 cgd #include <dev/pci/pcireg.h>
53 1.1 cgd #include <dev/pci/pcivar.h>
54 1.1 cgd #include <alpha/pci/apecsreg.h>
55 1.4 cgd #include <alpha/pci/apecsvar.h>
56 1.18 cgd #ifdef DEC_2100_A50
57 1.6 cgd #include <alpha/pci/pci_2100_a50.h>
58 1.9 cgd #endif
59 1.30 thorpej #ifdef DEC_EB64PLUS
60 1.30 thorpej #include <alpha/pci/pci_eb64plus.h>
61 1.30 thorpej #endif
62 1.33 ross #ifdef DEC_1000A
63 1.33 ross #include <alpha/pci/pci_1000a.h>
64 1.33 ross #endif
65 1.34 ross #ifdef DEC_1000
66 1.34 ross #include <alpha/pci/pci_1000.h>
67 1.34 ross #endif
68 1.1 cgd
69 1.16 cgd int apecsmatch __P((struct device *, struct cfdata *, void *));
70 1.1 cgd void apecsattach __P((struct device *, struct device *, void *));
71 1.1 cgd
72 1.5 thorpej struct cfattach apecs_ca = {
73 1.6 cgd sizeof(struct apecs_softc), apecsmatch, apecsattach,
74 1.5 thorpej };
75 1.5 thorpej
76 1.28 thorpej extern struct cfdriver apecs_cd;
77 1.1 cgd
78 1.10 cgd static int apecsprint __P((void *, const char *pnp));
79 1.1 cgd
80 1.4 cgd /* There can be only one. */
81 1.4 cgd int apecsfound;
82 1.4 cgd struct apecs_config apecs_configuration;
83 1.1 cgd
84 1.1 cgd int
85 1.1 cgd apecsmatch(parent, match, aux)
86 1.1 cgd struct device *parent;
87 1.16 cgd struct cfdata *match;
88 1.16 cgd void *aux;
89 1.1 cgd {
90 1.31 thorpej struct mainbus_attach_args *ma = aux;
91 1.1 cgd
92 1.4 cgd /* Make sure that we're looking for an APECS. */
93 1.31 thorpej if (strcmp(ma->ma_name, apecs_cd.cd_name) != 0)
94 1.4 cgd return (0);
95 1.4 cgd
96 1.4 cgd if (apecsfound)
97 1.4 cgd return (0);
98 1.1 cgd
99 1.1 cgd return (1);
100 1.1 cgd }
101 1.1 cgd
102 1.2 cgd /*
103 1.2 cgd * Set up the chipset's function pointers.
104 1.2 cgd */
105 1.2 cgd void
106 1.15 cgd apecs_init(acp, mallocsafe)
107 1.4 cgd struct apecs_config *acp;
108 1.15 cgd int mallocsafe;
109 1.2 cgd {
110 1.4 cgd acp->ac_comanche_pass2 =
111 1.4 cgd (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
112 1.4 cgd acp->ac_memwidth =
113 1.4 cgd (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
114 1.4 cgd acp->ac_epic_pass2 =
115 1.4 cgd (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
116 1.4 cgd
117 1.15 cgd acp->ac_haxr1 = REGVAL(EPIC_HAXR1);
118 1.15 cgd acp->ac_haxr2 = REGVAL(EPIC_HAXR2);
119 1.15 cgd
120 1.15 cgd if (!acp->ac_initted) {
121 1.15 cgd /* don't do these twice since they set up extents */
122 1.23 thorpej apecs_bus_io_init(&acp->ac_iot, acp);
123 1.23 thorpej apecs_bus_mem_init(&acp->ac_memt, acp);
124 1.15 cgd }
125 1.15 cgd acp->ac_mallocsafe = mallocsafe;
126 1.15 cgd
127 1.6 cgd apecs_pci_init(&acp->ac_pc, acp);
128 1.4 cgd
129 1.15 cgd acp->ac_initted = 1;
130 1.2 cgd }
131 1.2 cgd
132 1.1 cgd void
133 1.1 cgd apecsattach(parent, self, aux)
134 1.1 cgd struct device *parent, *self;
135 1.1 cgd void *aux;
136 1.1 cgd {
137 1.4 cgd struct apecs_softc *sc = (struct apecs_softc *)self;
138 1.4 cgd struct apecs_config *acp;
139 1.6 cgd struct pcibus_attach_args pba;
140 1.4 cgd
141 1.4 cgd /* note that we've attached the chipset; can't have 2 APECSes. */
142 1.4 cgd apecsfound = 1;
143 1.4 cgd
144 1.4 cgd /*
145 1.4 cgd * set up the chipset's info; done once at console init time
146 1.4 cgd * (maybe), but doesn't hurt to do twice.
147 1.4 cgd */
148 1.4 cgd acp = sc->sc_acp = &apecs_configuration;
149 1.15 cgd apecs_init(acp, 1);
150 1.1 cgd
151 1.32 thorpej apecs_dma_init(acp);
152 1.1 cgd
153 1.12 christos printf(": DECchip %s Core Logic chipset\n",
154 1.4 cgd acp->ac_memwidth == 128 ? "21072" : "21071");
155 1.12 christos printf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
156 1.4 cgd self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
157 1.12 christos printf("%s: DC21071-DA pass %d\n", self->dv_xname,
158 1.4 cgd acp->ac_epic_pass2 ? 2 : 1);
159 1.1 cgd /* XXX print bcache size */
160 1.1 cgd
161 1.4 cgd if (!acp->ac_epic_pass2)
162 1.12 christos printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
163 1.1 cgd
164 1.34.10.1 thorpej switch (cputype) {
165 1.18 cgd #ifdef DEC_2100_A50
166 1.1 cgd case ST_DEC_2100_A50:
167 1.6 cgd pci_2100_a50_pickintr(acp);
168 1.30 thorpej break;
169 1.30 thorpej #endif
170 1.30 thorpej
171 1.30 thorpej #ifdef DEC_EB64PLUS
172 1.30 thorpej case ST_EB64P:
173 1.30 thorpej pci_eb64plus_pickintr(acp);
174 1.33 ross break;
175 1.33 ross #endif
176 1.33 ross
177 1.33 ross #ifdef DEC_1000A
178 1.33 ross case ST_DEC_1000A:
179 1.33 ross pci_1000a_pickintr(acp, &acp->ac_iot, &acp->ac_memt,
180 1.34 ross &acp->ac_pc);
181 1.34 ross break;
182 1.34 ross #endif
183 1.34 ross
184 1.34 ross #ifdef DEC_1000
185 1.34 ross case ST_DEC_1000:
186 1.34 ross pci_1000_pickintr(acp, &acp->ac_iot, &acp->ac_memt,
187 1.33 ross &acp->ac_pc);
188 1.1 cgd break;
189 1.1 cgd #endif
190 1.14 cgd
191 1.1 cgd default:
192 1.1 cgd panic("apecsattach: shouldn't be here, really...");
193 1.1 cgd }
194 1.1 cgd
195 1.6 cgd pba.pba_busname = "pci";
196 1.25 thorpej pba.pba_iot = &acp->ac_iot;
197 1.25 thorpej pba.pba_memt = &acp->ac_memt;
198 1.29 thorpej pba.pba_dmat =
199 1.29 thorpej alphabus_dma_get_tag(&acp->ac_dmat_direct, ALPHA_BUS_PCI);
200 1.6 cgd pba.pba_pc = &acp->ac_pc;
201 1.6 cgd pba.pba_bus = 0;
202 1.22 cgd pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
203 1.6 cgd config_found(self, &pba, apecsprint);
204 1.1 cgd }
205 1.1 cgd
206 1.1 cgd static int
207 1.1 cgd apecsprint(aux, pnp)
208 1.1 cgd void *aux;
209 1.10 cgd const char *pnp;
210 1.1 cgd {
211 1.15 cgd register struct pcibus_attach_args *pba = aux;
212 1.1 cgd
213 1.4 cgd /* only PCIs can attach to APECSes; easy. */
214 1.4 cgd if (pnp)
215 1.12 christos printf("%s at %s", pba->pba_busname, pnp);
216 1.12 christos printf(" bus %d", pba->pba_bus);
217 1.4 cgd return (UNCONF);
218 1.1 cgd }
219