vtpbc_mainbus.c revision 1.5.8.3 1 1.5.8.3 nathanw /* $NetBSD: vtpbc_mainbus.c,v 1.5.8.3 2002/10/18 02:33:51 nathanw Exp $ */
2 1.5.8.2 nathanw
3 1.5.8.2 nathanw /*-
4 1.5.8.2 nathanw * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.5.8.2 nathanw * All rights reserved.
6 1.5.8.2 nathanw *
7 1.5.8.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.5.8.2 nathanw * by Jason R. Thorpe.
9 1.5.8.2 nathanw *
10 1.5.8.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.5.8.2 nathanw * modification, are permitted provided that the following conditions
12 1.5.8.2 nathanw * are met:
13 1.5.8.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.5.8.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.5.8.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.5.8.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.5.8.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.5.8.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.5.8.2 nathanw * must display the following acknowledgement:
20 1.5.8.2 nathanw * This product includes software developed by the NetBSD
21 1.5.8.2 nathanw * Foundation, Inc. and its contributors.
22 1.5.8.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.5.8.2 nathanw * contributors may be used to endorse or promote products derived
24 1.5.8.2 nathanw * from this software without specific prior written permission.
25 1.5.8.2 nathanw *
26 1.5.8.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.5.8.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.5.8.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.5.8.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.5.8.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.5.8.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.5.8.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.5.8.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.5.8.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.5.8.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.5.8.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.5.8.2 nathanw */
38 1.5.8.2 nathanw
39 1.5.8.2 nathanw #include "opt_algor_p4032.h"
40 1.5.8.2 nathanw #include "opt_algor_p5064.h"
41 1.5.8.2 nathanw
42 1.5.8.2 nathanw #include <sys/param.h>
43 1.5.8.2 nathanw #include <sys/systm.h>
44 1.5.8.2 nathanw #include <sys/conf.h>
45 1.5.8.2 nathanw #include <sys/reboot.h>
46 1.5.8.2 nathanw #include <sys/device.h>
47 1.5.8.2 nathanw
48 1.5.8.2 nathanw #include <machine/bus.h>
49 1.5.8.2 nathanw #include <machine/autoconf.h>
50 1.5.8.2 nathanw
51 1.5.8.2 nathanw #include <algor/pci/vtpbcvar.h>
52 1.5.8.2 nathanw
53 1.5.8.2 nathanw #ifdef ALGOR_P4032
54 1.5.8.2 nathanw #include <algor/algor/algor_p4032var.h>
55 1.5.8.2 nathanw #endif
56 1.5.8.2 nathanw
57 1.5.8.2 nathanw #ifdef ALGOR_P5064
58 1.5.8.2 nathanw #include <algor/algor/algor_p5064var.h>
59 1.5.8.2 nathanw #endif
60 1.5.8.2 nathanw
61 1.5.8.2 nathanw struct vtpbc_softc {
62 1.5.8.2 nathanw struct device sc_dev;
63 1.5.8.2 nathanw struct vtpbc_config *sc_vtpbc;
64 1.5.8.2 nathanw };
65 1.5.8.2 nathanw
66 1.5.8.2 nathanw int vtpbc_mainbus_match(struct device *, struct cfdata *, void *);
67 1.5.8.2 nathanw void vtpbc_mainbus_attach(struct device *, struct device *, void *);
68 1.5.8.2 nathanw
69 1.5.8.3 nathanw CFATTACH_DECL(vtpbc_mainbus, sizeof(struct vtpbc_softc),
70 1.5.8.3 nathanw vtpbc_mainbus_match, vtpbc_mainbus_attach, NULL, NULL);
71 1.5.8.2 nathanw extern struct cfdriver vtpbc_cd;
72 1.5.8.2 nathanw
73 1.5.8.2 nathanw int vtpbc_mainbus_print(void *, const char *);
74 1.5.8.2 nathanw
75 1.5.8.2 nathanw int
76 1.5.8.2 nathanw vtpbc_mainbus_match(struct device *parent, struct cfdata *cf, void *aux)
77 1.5.8.2 nathanw {
78 1.5.8.2 nathanw struct mainbus_attach_args *ma = aux;
79 1.5.8.2 nathanw
80 1.5.8.2 nathanw if (strcmp(ma->ma_name, vtpbc_cd.cd_name) == 0)
81 1.5.8.2 nathanw return (1);
82 1.5.8.2 nathanw
83 1.5.8.2 nathanw return (0);
84 1.5.8.2 nathanw }
85 1.5.8.2 nathanw
86 1.5.8.2 nathanw void
87 1.5.8.2 nathanw vtpbc_mainbus_attach(struct device *parent, struct device *self, void *aux)
88 1.5.8.2 nathanw {
89 1.5.8.2 nathanw struct vtpbc_softc *sc = (void *) self;
90 1.5.8.2 nathanw struct pcibus_attach_args pba;
91 1.5.8.2 nathanw struct vtpbc_config *vt;
92 1.5.8.2 nathanw
93 1.5.8.2 nathanw /*
94 1.5.8.2 nathanw * There is only one PCI controller on an Algorithmics board.
95 1.5.8.2 nathanw */
96 1.5.8.2 nathanw vt = &vtpbc_configuration;
97 1.5.8.2 nathanw sc->sc_vtpbc = vt;
98 1.5.8.2 nathanw
99 1.5.8.2 nathanw if (vt->vt_rev < vtpbc_nrevs)
100 1.5.8.2 nathanw printf(": V3 V962, revision %s\n", vtpbc_revs[vt->vt_rev]);
101 1.5.8.2 nathanw else
102 1.5.8.2 nathanw printf(": V3 V962, unknown revision %d\n", vt->vt_rev);
103 1.5.8.2 nathanw
104 1.5.8.2 nathanw printf("%s: PCI memory space base: 0x%08lx\n", sc->sc_dev.dv_xname,
105 1.5.8.2 nathanw (u_long) vt->vt_pci_membase);
106 1.5.8.2 nathanw printf("%s: PCI DMA window base: 0x%08lx\n", sc->sc_dev.dv_xname,
107 1.5.8.2 nathanw (u_long) vt->vt_dma_winbase);
108 1.5.8.2 nathanw
109 1.5.8.2 nathanw pba.pba_busname = "pci";
110 1.5.8.2 nathanw pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
111 1.5.8.2 nathanw pba.pba_bus = 0;
112 1.5.8.2 nathanw pba.pba_bridgetag = NULL;
113 1.5.8.2 nathanw
114 1.5.8.2 nathanw if (vt->vt_pci_iobase == (bus_addr_t) -1)
115 1.5.8.2 nathanw pba.pba_flags &= ~PCI_FLAGS_IO_ENABLED;
116 1.5.8.2 nathanw
117 1.5.8.2 nathanw #if defined(ALGOR_P4032)
118 1.5.8.2 nathanw {
119 1.5.8.2 nathanw struct p4032_config *acp = &p4032_configuration;
120 1.5.8.2 nathanw
121 1.5.8.2 nathanw pba.pba_iot = &acp->ac_iot;
122 1.5.8.2 nathanw pba.pba_memt = &acp->ac_memt;
123 1.5.8.2 nathanw pba.pba_dmat = &acp->ac_pci_dmat;
124 1.5.8.2 nathanw pba.pba_pc = &acp->ac_pc;
125 1.5.8.2 nathanw }
126 1.5.8.2 nathanw #elif defined(ALGOR_P5064)
127 1.5.8.2 nathanw {
128 1.5.8.2 nathanw struct p5064_config *acp = &p5064_configuration;
129 1.5.8.2 nathanw
130 1.5.8.2 nathanw pba.pba_iot = &acp->ac_iot;
131 1.5.8.2 nathanw pba.pba_memt = &acp->ac_memt;
132 1.5.8.2 nathanw pba.pba_dmat = &acp->ac_pci_dmat;
133 1.5.8.2 nathanw pba.pba_pc = &acp->ac_pc;
134 1.5.8.2 nathanw }
135 1.5.8.2 nathanw #endif /* ALGOR_P4032 || ALGOR_P5064 */
136 1.5.8.2 nathanw
137 1.5.8.2 nathanw (void) config_found(self, &pba, vtpbc_mainbus_print);
138 1.5.8.2 nathanw }
139 1.5.8.2 nathanw
140 1.5.8.2 nathanw int
141 1.5.8.2 nathanw vtpbc_mainbus_print(void *aux, const char *pnp)
142 1.5.8.2 nathanw {
143 1.5.8.2 nathanw struct pcibus_attach_args *pba = aux;
144 1.5.8.2 nathanw
145 1.5.8.2 nathanw /* only PCIs can attach to VTPBCs; easy. */
146 1.5.8.2 nathanw if (pnp)
147 1.5.8.2 nathanw printf("%s at %s", pba->pba_busname, pnp);
148 1.5.8.2 nathanw printf(" bus %d", pba->pba_bus);
149 1.5.8.2 nathanw
150 1.5.8.2 nathanw return (UNCONF);
151 1.5.8.2 nathanw }
152