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