lca.c revision 1.11 1 /* $NetBSD: lca.c,v 1.11 1996/10/23 04:12:25 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Authors: Jeffrey Hsu and 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/lcareg.h>
46 #include <alpha/pci/lcavar.h>
47 #if defined(DEC_AXPPCI_33)
48 #include <alpha/pci/pci_axppci_33.h>
49 #endif
50
51 int lcamatch __P((struct device *, void *, void *));
52 void lcaattach __P((struct device *, struct device *, void *));
53
54 struct cfattach lca_ca = {
55 sizeof(struct lca_softc), lcamatch, lcaattach,
56 };
57
58 struct cfdriver lca_cd = {
59 NULL, "lca", DV_DULL,
60 };
61
62 static int lcaprint __P((void *, const char *pnp));
63
64 /* There can be only one. */
65 int lcafound;
66 struct lca_config lca_configuration;
67
68 int
69 lcamatch(parent, match, aux)
70 struct device *parent;
71 void *match, *aux;
72 {
73 struct confargs *ca = aux;
74
75 /* Make sure that we're looking for a LCA. */
76 if (strcmp(ca->ca_name, lca_cd.cd_name) != 0)
77 return (0);
78
79 if (lcafound)
80 return (0);
81
82 return (1);
83 }
84
85 /*
86 * Set up the chipset's function pointers.
87 */
88 void
89 lca_init(lcp)
90 struct lca_config *lcp;
91 {
92
93 /*
94 * Can't set up SGMAP data here; can be called before malloc().
95 */
96
97 lcp->lc_iot = apecs_lca_bus_io_init(lcp);
98 lcp->lc_memt = apecs_lca_bus_mem_init(lcp);
99 lca_pci_init(&lcp->lc_pc, lcp);
100
101 /*
102 * Refer to ``DECchip 21066 and DECchip 21068 Alpha AXP Microprocessors
103 * Hardware Reference Manual''.
104 * ...
105 */
106
107 /*
108 * According to section 6.4.1, all bits of the IOC_HAE register are
109 * undefined after reset. Bits <31:27> are write-only. However, we
110 * cannot blindly set it to zero. The serial ROM code that initializes
111 * the PCI devices' address spaces, allocates sparse memory blocks in
112 * the range that must use the IOC_HAE register for address translation,
113 * and sets this register accordingly (see section 6.4.14).
114 *
115 * IOC_HAE left AS IS.
116 */
117
118 /* According to section 6.4.2, all bits of the IOC_CONF register are
119 * undefined after reset. Bits <1:0> are write-only. Set them to
120 * 0x00 for PCI Type 0 configuration access.
121 *
122 * IOC_CONF set to ZERO.
123 */
124 REGVAL(LCA_IOC_CONF) = 0;
125
126 /* Turn off DMA window enables in Window Base Registers */
127 /* REGVAL(LCA_IOC_W_BASE0) = 0;
128 REGVAL(LCA_IOC_W_BASE1) = 0; */
129 alpha_mb();
130
131 /* XXX XXX BEGIN XXX XXX */
132 { /* XXX */
133 extern vm_offset_t alpha_XXX_dmamap_or; /* XXX */
134 alpha_XXX_dmamap_or = 0x40000000; /* XXX */
135 } /* XXX */
136 /* XXX XXX END XXX XXX */
137 }
138
139 #ifdef notdef
140 void
141 lca_init_sgmap(lcp)
142 struct lca_config *lcp;
143 {
144
145 /* XXX */
146 lcp->lc_sgmap = malloc(1024 * 8, M_DEVBUF, M_WAITOK);
147 bzero(lcp->lc_sgmap, 1024 * 8); /* clear all entries. */
148
149 REGVAL(LCA_IOC_W_BASE0) = 0;
150 alpha_mb();
151
152 /* Set up Translated Base Register 1; translate to sybBus addr 0. */
153 /* check size against APEC XXX JH */
154 REGVAL(LCA_IOC_T_BASE_0) = vtophys(lcp->lc_sgmap) >> 1;
155
156 /* Set up PCI mask register 1; map 8MB space. */
157 REGVAL(LCA_IOC_W_MASK0) = 0x00700000;
158
159 /* Enable window 1; from PCI address 8MB, direct mapped. */
160 REGVAL(LCA_IOC_W_BASE0) = 0x300800000;
161 alpha_mb();
162 }
163 #endif
164
165 void
166 lcaattach(parent, self, aux)
167 struct device *parent, *self;
168 void *aux;
169 {
170 struct lca_softc *sc = (struct lca_softc *)self;
171 struct lca_config *lcp;
172 struct pcibus_attach_args pba;
173
174 /* note that we've attached the chipset; can't have 2 LCAs. */
175 /* Um, not sure about this. XXX JH */
176 lcafound = 1;
177
178 /*
179 * set up the chipset's info; done once at console init time
180 * (maybe), but doesn't hurt to do twice.
181 */
182 lcp = sc->sc_lcp = &lca_configuration;
183 lca_init(lcp);
184 #ifdef notdef
185 lca_init_sgmap(lcp);
186 #endif
187
188 /* XXX print chipset information */
189 printf("\n");
190
191 switch (hwrpb->rpb_type) {
192 #if defined(DEC_AXPPCI_33)
193 case ST_DEC_AXPPCI_33:
194 pci_axppci_33_pickintr(lcp);
195 break;
196 #endif
197 default:
198 panic("lcaattach: shouldn't be here, really...");
199 }
200
201 pba.pba_busname = "pci";
202 pba.pba_iot = lcp->lc_iot;
203 pba.pba_memt = lcp->lc_memt;
204 pba.pba_pc = &lcp->lc_pc;
205 pba.pba_bus = 0;
206 config_found(self, &pba, lcaprint);
207 }
208
209 static int
210 lcaprint(aux, pnp)
211 void *aux;
212 const char *pnp;
213 {
214 register struct pcibus_attach_args *pba = aux;
215
216 /* only PCIs can attach to LCAes; easy. */
217 if (pnp)
218 printf("%s at %s", pba->pba_busname, pnp);
219 printf(" bus %d", pba->pba_bus);
220 return (UNCONF);
221 }
222