lca.c revision 1.2 1 /* $NetBSD: lca.c,v 1.2 1996/03/17 01:06:33 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1995 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Jeffrey Hsu
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/lcareg.h>
46 #include <alpha/pci/lcavar.h>
47
48 int lcamatch __P((struct device *, void *, void *));
49 void lcaattach __P((struct device *, struct device *, void *));
50
51 struct cfattach lca_ca = {
52 sizeof(struct lca_softc), lcamatch, lcaattach
53 };
54
55 struct cfdriver lca_cd = {
56 NULL, "lca", DV_DULL
57 };
58
59 static int lcaprint __P((void *, char *pnp));
60
61 /* There can be only one. */
62 int lcafound;
63 struct lca_config lca_configuration;
64
65 int
66 lcamatch(parent, match, aux)
67 struct device *parent;
68 void *match, *aux;
69 {
70 struct cfdata *cf = match;
71 struct confargs *ca = aux;
72
73 /* Make sure that we're looking for a LCA. */
74 if (strcmp(ca->ca_name, lca_cd.cd_name) != 0)
75 return (0);
76
77 if (lcafound)
78 return (0);
79
80 return (1);
81 }
82
83 /*
84 * Set up the chipset's function pointers.
85 */
86 void
87 lca_init(lcp)
88 struct lca_config *lcp;
89 {
90
91 /*
92 * Can't set up SGMAP data here; can be called before malloc().
93 */
94
95 lcp->lc_conffns = &lca_conf_fns;
96 lcp->lc_confarg = lcp;
97 lcp->lc_dmafns = &lca_dma_fns;
98 lcp->lc_dmaarg = lcp;
99 /* Interrupt routines set up in 'attach' */
100 lcp->lc_memfns = &lca_mem_fns;
101 lcp->lc_memarg = lcp;
102 lcp->lc_piofns = &lca_pio_fns;
103 lcp->lc_pioarg = lcp;
104
105 /*
106 printf("lca_init: before IOC_HAE=0x%x\n", REGVAL(LCA_IOC_HAE));
107 REGVAL(LCA_IOC_HAE) = 0; */
108
109 REGVAL(LCA_IOC_CONF) = 0;
110
111 /* Turn off DMA window enables in Window Base Registers */
112 /* REGVAL(LCA_IOC_W_BASE0) = 0;
113 REGVAL(LCA_IOC_W_BASE1) = 0; */
114 wbflush();
115 }
116
117 #ifdef notdef
118 void
119 lca_init_sgmap(lcp)
120 struct lca_config *lcp;
121 {
122
123 /* XXX */
124 lcp->lc_sgmap = malloc(1024 * 8, M_DEVBUF, M_WAITOK);
125 bzero(lcp->lc_sgmap, 1024 * 8); /* clear all entries. */
126
127 REGVAL(LCA_IOC_W_BASE0) = 0;
128 wbflush();
129
130 /* Set up Translated Base Register 1; translate to sybBus addr 0. */
131 /* check size against APEC XXX JH */
132 REGVAL(LCA_IOC_T_BASE_0) = vtophys(lcp->lc_sgmap) >> 1;
133
134 /* Set up PCI mask register 1; map 8MB space. */
135 REGVAL(LCA_IOC_W_MASK0) = 0x00700000;
136
137 /* Enable window 1; from PCI address 8MB, direct mapped. */
138 REGVAL(LCA_IOC_W_BASE0) = 0x300800000;
139 wbflush();
140 }
141 #endif
142
143 void
144 lcaattach(parent, self, aux)
145 struct device *parent, *self;
146 void *aux;
147 {
148 struct confargs *ca = aux;
149 struct lca_softc *sc = (struct lca_softc *)self;
150 struct lca_config *lcp;
151 struct pci_attach_args pa;
152
153 /* note that we've attached the chipset; can't have 2 LCAs. */
154 /* Um, not sure about this. XXX JH */
155 lcafound = 1;
156
157 /*
158 * set up the chipset's info; done once at console init time
159 * (maybe), but doesn't hurt to do twice.
160 */
161 lcp = sc->sc_lcp = &lca_configuration;
162 lca_init(lcp);
163 #ifdef notdef
164 lca_init_sgmap(lcp);
165 #endif
166
167 /* XXX print chipset information */
168 printf("\n");
169
170 switch (hwrpb->rpb_type) {
171 #if defined(DEC_AXPPCI_33)
172 case ST_DEC_AXPPCI_33:
173 pci_axppci_33_pickintr(lcp->lc_conffns, lcp->lc_confarg,
174 lcp->lc_piofns, lcp->lc_pioarg,
175 &lcp->lc_intrfns, &lcp->lc_intrarg);
176 break;
177 #endif
178 default:
179 panic("lcaattach: shouldn't be here, really...");
180 }
181
182 pa.pa_bus = 0;
183 pa.pa_maxdev = 13;
184 pa.pa_burstlog2 = 8;
185
186 pa.pa_conffns = lcp->lc_conffns;
187 pa.pa_confarg = lcp->lc_confarg;
188 pa.pa_dmafns = lcp->lc_dmafns;
189 pa.pa_dmaarg = lcp->lc_dmaarg;
190 pa.pa_intrfns = lcp->lc_intrfns;
191 pa.pa_intrarg = lcp->lc_intrarg;
192 pa.pa_memfns = lcp->lc_memfns;
193 pa.pa_memarg = lcp->lc_memarg;
194 pa.pa_piofns = lcp->lc_piofns;
195 pa.pa_pioarg = lcp->lc_pioarg;
196
197 config_found(self, &pa, lcaprint);
198 }
199
200 static int
201 lcaprint(aux, pnp)
202 void *aux;
203 char *pnp;
204 {
205 register struct pci_attach_args *pa = aux;
206
207 /* what does this do? XXX JH */
208 /* only PCIs can attach to LCAes; easy. */
209 if (pnp)
210 printf("pci at %s", pnp);
211 printf(" bus %d", pa->pa_bus);
212 return (UNCONF);
213 }
214