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