cia.c revision 1.18 1 /* $NetBSD: cia.c,v 1.18 1997/04/07 02:01:16 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 <machine/options.h> /* Pull in config options headers */
31
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/kernel.h>
35 #include <sys/malloc.h>
36 #include <sys/device.h>
37 #include <vm/vm.h>
38
39 #include <machine/autoconf.h>
40 #include <machine/rpb.h>
41
42 #include <dev/isa/isareg.h>
43 #include <dev/isa/isavar.h>
44
45 #include <dev/pci/pcireg.h>
46 #include <dev/pci/pcivar.h>
47 #include <alpha/pci/ciareg.h>
48 #include <alpha/pci/ciavar.h>
49 #ifdef DEC_KN20AA
50 #include <alpha/pci/pci_kn20aa.h>
51 #endif
52 #ifdef DEC_EB164
53 #include <alpha/pci/pci_eb164.h>
54 #endif
55
56 int ciamatch __P((struct device *, struct cfdata *, void *));
57 void ciaattach __P((struct device *, struct device *, void *));
58
59 struct cfattach cia_ca = {
60 sizeof(struct cia_softc), ciamatch, ciaattach,
61 };
62
63 struct cfdriver cia_cd = {
64 NULL, "cia", DV_DULL,
65 };
66
67 static int ciaprint __P((void *, const char *pnp));
68
69 /* There can be only one. */
70 int ciafound;
71 struct cia_config cia_configuration;
72
73 int
74 ciamatch(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 a CIA. */
82 if (strcmp(ca->ca_name, cia_cd.cd_name) != 0)
83 return (0);
84
85 if (ciafound)
86 return (0);
87
88 return (1);
89 }
90
91 /*
92 * Set up the chipset's function pointers.
93 */
94 void
95 cia_init(ccp, mallocsafe)
96 struct cia_config *ccp;
97 int mallocsafe;
98 {
99
100 /*
101 * Can't set up SGMAP data here; can be called before malloc().
102 * XXX THIS COMMENT NO LONGER MAKES SENSE.
103 */
104
105 ccp->cc_hae_mem = REGVAL(CIA_CSR_HAE_MEM);
106 ccp->cc_hae_io = REGVAL(CIA_CSR_HAE_IO);
107
108 if (!ccp->cc_initted) {
109 /* don't do these twice since they set up extents */
110 ccp->cc_iot = cia_bus_io_init(ccp);
111 ccp->cc_memt = cia_bus_mem_init(ccp);
112 }
113 ccp->cc_mallocsafe = mallocsafe;
114
115 cia_pci_init(&ccp->cc_pc, ccp);
116
117 /* XXX XXX BEGIN XXX XXX */
118 { /* XXX */
119 extern vm_offset_t alpha_XXX_dmamap_or; /* XXX */
120 alpha_XXX_dmamap_or = 0x40000000; /* XXX */
121 } /* XXX */
122 /* XXX XXX END XXX XXX */
123
124 ccp->cc_initted = 1;
125 }
126
127 void
128 ciaattach(parent, self, aux)
129 struct device *parent, *self;
130 void *aux;
131 {
132 struct cia_softc *sc = (struct cia_softc *)self;
133 struct cia_config *ccp;
134 struct pcibus_attach_args pba;
135
136 /* note that we've attached the chipset; can't have 2 CIAs. */
137 ciafound = 1;
138
139 /*
140 * set up the chipset's info; done once at console init time
141 * (maybe), but doesn't hurt to do twice.
142 */
143 ccp = sc->sc_ccp = &cia_configuration;
144 cia_init(ccp, 1);
145
146 /* XXX print chipset information */
147 printf("\n");
148
149 switch (hwrpb->rpb_type) {
150 #ifdef DEC_KN20AA
151 case ST_DEC_KN20AA:
152 pci_kn20aa_pickintr(ccp);
153 #ifdef EVCNT_COUNTERS
154 evcnt_attach(self, "intr", &kn20aa_intr_evcnt);
155 #endif
156 break;
157 #endif
158
159 #ifdef DEC_EB164
160 case ST_EB164:
161 pci_eb164_pickintr(ccp);
162 #ifdef EVCNT_COUNTERS
163 evcnt_attach(self, "intr", &eb164_intr_evcnt);
164 #endif
165 break;
166 #endif
167
168 default:
169 panic("ciaattach: shouldn't be here, really...");
170 }
171
172 pba.pba_busname = "pci";
173 pba.pba_iot = ccp->cc_iot;
174 pba.pba_memt = ccp->cc_memt;
175 pba.pba_pc = &ccp->cc_pc;
176 pba.pba_bus = 0;
177 config_found(self, &pba, ciaprint);
178 }
179
180 static int
181 ciaprint(aux, pnp)
182 void *aux;
183 const char *pnp;
184 {
185 register struct pcibus_attach_args *pba = aux;
186
187 /* only PCIs can attach to CIAs; easy. */
188 if (pnp)
189 printf("%s at %s", pba->pba_busname, pnp);
190 printf(" bus %d", pba->pba_bus);
191 return (UNCONF);
192 }
193