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