Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / alpha / pci / ttwoga.c
blobee64d671ffe5e40587051470fe11593854014186
1 /* $NetBSD: ttwoga.c,v 1.10 2005/12/11 12:16:17 christos Exp $ */
3 /*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include "opt_dec_2100_a500.h"
33 #include "opt_dec_2100a_a500.h"
35 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
37 __KERNEL_RCSID(0, "$NetBSD: ttwoga.c,v 1.10 2005/12/11 12:16:17 christos Exp $");
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/malloc.h>
43 #include <sys/device.h>
45 #include <machine/autoconf.h>
46 #include <machine/rpb.h>
48 #include <dev/isa/isareg.h>
49 #include <dev/isa/isavar.h>
51 #include <dev/eisa/eisavar.h>
53 #include <dev/pci/pcireg.h>
54 #include <dev/pci/pcivar.h>
56 #include <alpha/pci/ttwogareg.h>
57 #include <alpha/pci/ttwogavar.h>
59 #if defined(DEC_2100_A500) || defined(DEC_2100A_A500)
60 #include <alpha/pci/pci_2100_a500.h>
61 #endif
63 #include "locators.h"
65 int ttwogamatch(struct device *, struct cfdata *, void *);
66 void ttwogaattach(struct device *, struct device *, void *);
68 CFATTACH_DECL(ttwoga, sizeof(struct device),
69 ttwogamatch, ttwogaattach, NULL, NULL);
71 int ttwogaprint(void *, const char *);
73 int ttwopcimatch(struct device *, struct cfdata *, void *);
74 void ttwopciattach(struct device *, struct device *, void *);
76 CFATTACH_DECL(ttwopci, sizeof(struct device),
77 ttwopcimatch, ttwopciattach, NULL, NULL);
79 int ttwosableioprint(void *, const char *);
82 * There can be only one, but it might have 2 primary PCI busses.
84 int ttwogafound;
85 struct ttwoga_config ttwoga_configuration[2];
87 /* CBUS address bias for Gamma systems. */
88 bus_addr_t ttwoga_gamma_cbus_bias;
90 #define GIGABYTE (1024UL * 1024UL * 1024UL)
91 #define MEGABYTE (1024UL * 1024UL)
93 const struct ttwoga_sysmap ttwoga_sysmap[2] = {
94 /* Base System size Bus size */
95 { T2_PCI0_SIO_BASE, 256UL * MEGABYTE, 8UL * MEGABYTE,
96 T2_PCI0_SMEM_BASE, 4UL * GIGABYTE, 128UL * MEGABYTE,
97 T2_PCI0_DMEM_BASE, 1UL * GIGABYTE, 1UL * GIGABYTE,
98 T2_PCI0_CONF_BASE,
100 { T2_PCI1_SIO_BASE, 256UL * MEGABYTE, 8UL * MEGABYTE,
101 T2_PCI1_SMEM_BASE, 2UL * GIGABYTE, 64UL * MEGABYTE,
102 T2_PCI1_DMEM_BASE, 2UL * GIGABYTE, 2UL * GIGABYTE,
103 T2_PCI1_CONF_BASE,
107 #undef GIGABYTE
108 #undef MEGABYTE
111 ttwogamatch(struct device *parent, struct cfdata *match, void *aux)
113 struct mainbus_attach_args *ma = aux;
115 /* Make sure that we're looking for a T2 Gate Array. */
116 if (strcmp(ma->ma_name, match->cf_name) != 0)
117 return (0);
119 if (ttwogafound)
120 return (0);
122 return (1);
125 void
126 ttwogaattach(struct device *parent, struct device *self, void *aux)
128 struct pcibus_attach_args pba;
129 int hose;
131 printf("\n");
133 /* note that we've attached the chipset; can't have 2 T2s */
134 ttwogafound = 1;
137 * Don't do much here; real work is deferred to the ttwopci
138 * layer.
140 for (hose = 0; hose < 1 /* XXX */; hose++) {
141 #if 0 /* XXX */
142 if (badaddr(_T2GA(hose, T2_IOCSR), sizeof(u_int64_t)))
143 continue;
144 #endif
145 memset(&pba, 0, sizeof(pba));
146 pba.pba_bus = hose;
148 (void) config_found_ia(self, "ttwoga", &pba, ttwogaprint);
153 ttwogaprint(void *aux, const char *pnp)
155 struct pcibus_attach_args *pba = aux;
157 if (pnp)
158 aprint_normal("ttwopci at %s", pnp);
159 aprint_normal(" hose %d", pba->pba_bus);
160 return (UNCONF);
164 * Set up the chipset's function pointers.
166 struct ttwoga_config *
167 ttwoga_init(int hose, int mallocsafe)
169 struct ttwoga_config *tcp;
171 if (hose < 0 || hose > 1)
172 panic("ttwoga_init: bad hose # %d", hose);
174 tcp = &ttwoga_configuration[hose];
175 tcp->tc_hose = hose;
177 tcp->tc_sysmap = &ttwoga_sysmap[hose];
180 * Sable-Gamma has a CBUS address bias.
182 ttwoga_gamma_cbus_bias = (alpha_implver() == ALPHA_IMPLVER_EV5) ?
183 T2_GAMMA_CBUS_BIAS : 0;
185 alpha_mb();
187 tcp->tc_io_bus_start = (T2GA(tcp, T2_HAE0_2) & HAE0_2_PUA2) << 23;
188 tcp->tc_d_mem_bus_start = (T2GA(tcp, T2_HAE0_4) & HAE0_4_PUA1) << 30;
189 tcp->tc_s_mem_bus_start = (T2GA(tcp, T2_HAE0_1) & HAE0_1_PUA1) << 27;
191 tcp->tc_rev = (T2GA(tcp, T2_IOCSR) & IOCSR_TRN) >> IOCSR_TRN_SHIFT;
193 if (tcp->tc_initted == 0) {
194 /* don't do these twice since they set up extents */
195 ttwoga_bus_io_init(&tcp->tc_iot, tcp);
196 ttwoga_bus_mem_init(&tcp->tc_memt, tcp);
198 tcp->tc_mallocsafe = mallocsafe;
200 ttwoga_pci_init(&tcp->tc_pc, tcp);
202 tcp->tc_initted = 1;
204 return (tcp);
208 ttwopcimatch(struct device *parent, struct cfdata *match, void *aux)
210 struct pcibus_attach_args *pba = aux;
212 if (match->cf_loc[PCIBUSCF_BUS] != PCIBUSCF_BUS_DEFAULT &&
213 match->cf_loc[PCIBUSCF_BUS] != pba->pba_bus)
214 return (0);
216 return (1);
219 void
220 ttwopciattach(struct device *parent, struct device *self, void *aux)
222 struct pcibus_attach_args *pba = aux, npba;
223 struct ttwoga_config *tcp;
226 * set up the chipset's info; done one at console init time
227 * (maybe), but doesn't hurt to do it twice.
229 tcp = ttwoga_init(pba->pba_bus, 1);
231 ttwoga_dma_init(tcp);
233 if (tcp->tc_rev < TRN_T3)
234 printf(": T2 Gate Array rev. %d\n", tcp->tc_rev);
235 else
236 printf(": T3 or T4 Gate Array rev. %d\n", tcp->tc_rev);
238 if (tcp->tc_rev < 1)
239 printf("%s: WARNING: T2 NOT PASS2... NO BETS...\n",
240 self->dv_xname);
242 switch (cputype) {
243 #if defined(DEC_2100_A500) || defined(DEC_2100A_A500)
244 case ST_DEC_2100_A500:
245 case ST_DEC_2100A_A500:
246 pci_2100_a500_pickintr(tcp);
247 break;
248 #endif
250 default:
251 panic("ttwogaattach: shouldn't be here, really...");
254 npba.pba_iot = &tcp->tc_iot;
255 npba.pba_memt = &tcp->tc_memt;
256 npba.pba_dmat =
257 alphabus_dma_get_tag(&tcp->tc_dmat_direct, ALPHA_BUS_PCI);
258 npba.pba_dmat64 = NULL;
259 npba.pba_pc = &tcp->tc_pc;
260 npba.pba_bus = 0;
261 npba.pba_bridgetag = NULL;
262 npba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
265 * Hose 0 has the STDIO module.
267 if (pba->pba_bus == 0) {
268 (void) config_found_ia(self, "sableiobus", &npba,
269 ttwosableioprint);
272 (void) config_found_ia(self, "pcibus", &npba, pcibusprint);
276 ttwosableioprint(void *aux, const char *pnp)
278 struct pcibus_attach_args *pba = aux;
280 if (pnp)
281 aprint_normal("sableio at %s", pnp);
282 aprint_normal(" bus %d", pba->pba_bus);
283 return (UNCONF);