apecs.c revision 1.29 1 /* $NetBSD: apecs.c,v 1.29 1998/01/17 03:39:51 thorpej 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 "opt_dec_2100_a50.h"
31 #include "opt_dec_eb64plus.h"
32
33 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34
35 __KERNEL_RCSID(0, "$NetBSD: apecs.c,v 1.29 1998/01/17 03:39:51 thorpej Exp $");
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
40 #include <sys/malloc.h>
41 #include <sys/device.h>
42 #include <vm/vm.h>
43
44 #include <machine/autoconf.h>
45 #include <machine/rpb.h>
46
47 #include <dev/isa/isareg.h>
48 #include <dev/isa/isavar.h>
49
50 #include <dev/pci/pcireg.h>
51 #include <dev/pci/pcivar.h>
52 #include <alpha/pci/apecsreg.h>
53 #include <alpha/pci/apecsvar.h>
54 #ifdef DEC_2100_A50
55 #include <alpha/pci/pci_2100_a50.h>
56 #endif
57
58 int apecsmatch __P((struct device *, struct cfdata *, void *));
59 void apecsattach __P((struct device *, struct device *, void *));
60
61 struct cfattach apecs_ca = {
62 sizeof(struct apecs_softc), apecsmatch, apecsattach,
63 };
64
65 extern struct cfdriver apecs_cd;
66
67 static int apecsprint __P((void *, const char *pnp));
68
69 /* There can be only one. */
70 int apecsfound;
71 struct apecs_config apecs_configuration;
72
73 int
74 apecsmatch(parent, match, aux)
75 struct device *parent;
76 struct cfdata *match;
77 void *aux;
78 {
79 struct confargs *ca = aux;
80
81 /* Make sure that we're looking for an APECS. */
82 if (strcmp(ca->ca_name, apecs_cd.cd_name) != 0)
83 return (0);
84
85 if (apecsfound)
86 return (0);
87
88 return (1);
89 }
90
91 /*
92 * Set up the chipset's function pointers.
93 */
94 void
95 apecs_init(acp, mallocsafe)
96 struct apecs_config *acp;
97 int mallocsafe;
98 {
99 acp->ac_comanche_pass2 =
100 (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
101 acp->ac_memwidth =
102 (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
103 acp->ac_epic_pass2 =
104 (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
105
106 acp->ac_haxr1 = REGVAL(EPIC_HAXR1);
107 acp->ac_haxr2 = REGVAL(EPIC_HAXR2);
108
109 if (!acp->ac_initted) {
110 /* don't do these twice since they set up extents */
111 apecs_bus_io_init(&acp->ac_iot, acp);
112 apecs_bus_mem_init(&acp->ac_memt, acp);
113 }
114 acp->ac_mallocsafe = mallocsafe;
115
116 apecs_pci_init(&acp->ac_pc, acp);
117
118 apecs_dma_init(acp);
119
120 acp->ac_initted = 1;
121 }
122
123 void
124 apecsattach(parent, self, aux)
125 struct device *parent, *self;
126 void *aux;
127 {
128 struct apecs_softc *sc = (struct apecs_softc *)self;
129 struct apecs_config *acp;
130 struct pcibus_attach_args pba;
131
132 /* note that we've attached the chipset; can't have 2 APECSes. */
133 apecsfound = 1;
134
135 /*
136 * set up the chipset's info; done once at console init time
137 * (maybe), but doesn't hurt to do twice.
138 */
139 acp = sc->sc_acp = &apecs_configuration;
140 apecs_init(acp, 1);
141
142 /* XXX SGMAP FOO */
143
144 printf(": DECchip %s Core Logic chipset\n",
145 acp->ac_memwidth == 128 ? "21072" : "21071");
146 printf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
147 self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
148 printf("%s: DC21071-DA pass %d\n", self->dv_xname,
149 acp->ac_epic_pass2 ? 2 : 1);
150 /* XXX print bcache size */
151
152 if (!acp->ac_epic_pass2)
153 printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
154
155 switch (hwrpb->rpb_type) {
156 #ifdef DEC_2100_A50
157 case ST_DEC_2100_A50:
158 pci_2100_a50_pickintr(acp);
159 break;
160 #endif
161
162 default:
163 panic("apecsattach: shouldn't be here, really...");
164 }
165
166 pba.pba_busname = "pci";
167 pba.pba_iot = &acp->ac_iot;
168 pba.pba_memt = &acp->ac_memt;
169 pba.pba_dmat =
170 alphabus_dma_get_tag(&acp->ac_dmat_direct, ALPHA_BUS_PCI);
171 pba.pba_pc = &acp->ac_pc;
172 pba.pba_bus = 0;
173 pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
174 config_found(self, &pba, apecsprint);
175 }
176
177 static int
178 apecsprint(aux, pnp)
179 void *aux;
180 const char *pnp;
181 {
182 register struct pcibus_attach_args *pba = aux;
183
184 /* only PCIs can attach to APECSes; easy. */
185 if (pnp)
186 printf("%s at %s", pba->pba_busname, pnp);
187 printf(" bus %d", pba->pba_bus);
188 return (UNCONF);
189 }
190