apecs.c revision 1.4 1 /* $NetBSD: apecs.c,v 1.4 1995/11/23 02:37:11 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1995 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
48 int apecsmatch __P((struct device *, void *, void *));
49 void apecsattach __P((struct device *, struct device *, void *));
50
51 struct cfdriver apecscd = {
52 NULL, "apecs", apecsmatch, apecsattach, DV_DULL,
53 sizeof(struct apecs_softc)
54 };
55
56 static int apecsprint __P((void *, char *pnp));
57
58 #define REGVAL(r) (*(int32_t *)phystok0seg(r))
59
60 /* There can be only one. */
61 int apecsfound;
62 struct apecs_config apecs_configuration;
63
64 int
65 apecsmatch(parent, match, aux)
66 struct device *parent;
67 void *match, *aux;
68 {
69 struct cfdata *cf = match;
70 struct confargs *ca = aux;
71
72 /* Make sure that we're looking for an APECS. */
73 if (strcmp(ca->ca_name, apecscd.cd_name) != 0)
74 return (0);
75
76 if (apecsfound)
77 return (0);
78
79 return (1);
80 }
81
82 /*
83 * Set up the chipset's function pointers.
84 */
85 void
86 apecs_init(acp)
87 struct apecs_config *acp;
88 {
89
90 acp->ac_comanche_pass2 =
91 (REGVAL(COMANCHE_ED) & COMANCHE_ED_PASS2) != 0;
92 acp->ac_memwidth =
93 (REGVAL(COMANCHE_GCR) & COMANCHE_GCR_WIDEMEM) != 0 ? 128 : 64;
94 acp->ac_epic_pass2 =
95 (REGVAL(EPIC_DCSR) & EPIC_DCSR_PASS2) != 0;
96
97 /*
98 * Can't set up SGMAP data here; can be called before malloc().
99 */
100
101 acp->ac_conffns = &apecs_conf_fns;
102 acp->ac_confarg = acp;
103 acp->ac_dmafns = &apecs_dma_fns;
104 acp->ac_dmaarg = acp;
105 /* Interrupt routines set up in 'attach' */
106 acp->ac_memfns = &apecs_mem_fns;
107 acp->ac_memarg = acp;
108 acp->ac_piofns = &apecs_pio_fns;
109 acp->ac_pioarg = acp;
110
111 /* Turn off DMA window enables in PCI Base Reg 1. */
112 REGVAL(EPIC_PCI_BASE_1) = 0;
113 wbflush();
114
115 /* XXX SGMAP? */
116 }
117
118 void
119 apecsattach(parent, self, aux)
120 struct device *parent, *self;
121 void *aux;
122 {
123 struct confargs *ca = aux;
124 struct apecs_softc *sc = (struct apecs_softc *)self;
125 struct apecs_config *acp;
126 struct pci_attach_args pa;
127
128 /* note that we've attached the chipset; can't have 2 APECSes. */
129 apecsfound = 1;
130
131 /*
132 * set up the chipset's info; done once at console init time
133 * (maybe), but doesn't hurt to do twice.
134 */
135 acp = sc->sc_acp = &apecs_configuration;
136 apecs_init(acp);
137
138 /* XXX SGMAP FOO */
139
140 printf(": DECchip %s Core Logic chipset\n",
141 acp->ac_memwidth == 128 ? "21072" : "21071");
142 printf("%s: DC21071-CA pass %d, %d-bit memory bus\n",
143 self->dv_xname, acp->ac_comanche_pass2 ? 2 : 1, acp->ac_memwidth);
144 printf("%s: DC21071-DA pass %d\n", self->dv_xname,
145 acp->ac_epic_pass2 ? 2 : 1);
146 /* XXX print bcache size */
147
148 if (!acp->ac_epic_pass2)
149 printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
150
151 switch (hwrpb->rpb_type) {
152 #if defined(DEC_2100_A50)
153 case ST_DEC_2100_A50:
154 pci_2100_a50_pickintr(acp->ac_conffns, acp->ac_confarg,
155 acp->ac_piofns, acp->ac_pioarg,
156 &acp->ac_intrfns, &acp->ac_intrarg);
157 break;
158 #endif
159 default:
160 panic("apecsattach: shouldn't be here, really...");
161 }
162
163 pa.pa_bus = 0;
164 pa.pa_maxdev = 32;
165 pa.pa_burstlog2 = 8;
166
167 pa.pa_conffns = acp->ac_conffns;
168 pa.pa_confarg = acp->ac_confarg;
169 pa.pa_dmafns = acp->ac_dmafns;
170 pa.pa_dmaarg = acp->ac_dmaarg;
171 pa.pa_intrfns = acp->ac_intrfns;
172 pa.pa_intrarg = acp->ac_intrarg;
173 pa.pa_memfns = acp->ac_memfns;
174 pa.pa_memarg = acp->ac_memarg;
175 pa.pa_piofns = acp->ac_piofns;
176 pa.pa_pioarg = acp->ac_pioarg;
177
178 config_found(self, &pa, apecsprint);
179 }
180
181 static int
182 apecsprint(aux, pnp)
183 void *aux;
184 char *pnp;
185 {
186 register struct pci_attach_args *pa = aux;
187
188 /* only PCIs can attach to APECSes; easy. */
189 if (pnp)
190 printf("pci at %s", pnp);
191 printf(" bus %d", pa->pa_bus);
192 return (UNCONF);
193 }
194