Annotation of sys/arch/alpha/pci/irongate.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: irongate.c,v 1.9 2006/12/14 17:36:12 kettenis Exp $ */
2: /* $NetBSD: irongate.c,v 1.3 2000/11/29 06:29:10 thorpej Exp $ */
3:
4: /*-
5: * Copyright (c) 2000 The NetBSD Foundation, Inc.
6: * All rights reserved.
7: *
8: * This code is derived from software contributed to The NetBSD Foundation
9: * by Jason R. Thorpe.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: * 2. Redistributions in binary form must reproduce the above copyright
17: * notice, this list of conditions and the following disclaimer in the
18: * documentation and/or other materials provided with the distribution.
19: * 3. All advertising materials mentioning features or use of this software
20: * must display the following acknowledgement:
21: * This product includes software developed by the NetBSD
22: * Foundation, Inc. and its contributors.
23: * 4. Neither the name of The NetBSD Foundation nor the names of its
24: * contributors may be used to endorse or promote products derived
25: * from this software without specific prior written permission.
26: *
27: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37: * POSSIBILITY OF SUCH DAMAGE.
38: */
39:
40: #include <sys/param.h>
41: #include <sys/systm.h>
42: #include <sys/device.h>
43: #include <sys/malloc.h>
44:
45: #include <machine/autoconf.h>
46: #include <machine/rpb.h>
47:
48: #include <dev/isa/isareg.h>
49: #include <dev/isa/isavar.h>
50: #include <dev/pci/pcireg.h>
51: #include <dev/pci/pcivar.h>
52:
53: #include <alpha/pci/irongatereg.h>
54: #include <alpha/pci/irongatevar.h>
55:
56: #ifdef API_UP1000
57: #include <alpha/pci/pci_up1000.h>
58: #endif
59:
60: int irongate_match(struct device *, void *, void *);
61: void irongate_attach(struct device *, struct device *, void *);
62:
63: struct cfattach irongate_ca = {
64: sizeof(struct device), irongate_match, irongate_attach,
65: };
66:
67: int irongate_print(void *, const char *pnp);
68:
69: struct cfdriver irongate_cd = {
70: NULL, "irongate", DV_DULL,
71: };
72:
73: /* There can be only one. */
74: struct irongate_config irongate_configuration;
75: int irongate_found;
76:
77: #if 0
78: int irongate_bus_get_window(int, int,
79: struct alpha_bus_space_translation *);
80: #endif
81:
82: /*
83: * Set up the chipset's function pointers.
84: */
85: void
86: irongate_init(struct irongate_config *icp, int mallocsafe)
87: {
88: pcitag_t tag;
89: pcireg_t reg;
90:
91: icp->ic_mallocsafe = mallocsafe;
92:
93: /*
94: * Set up PCI configuration space; we can only read the
95: * revision info through configuration space.
96: */
97: irongate_pci_init(&icp->ic_pc, icp);
98: alpha_pci_chipset = &icp->ic_pc;
99: alpha_pci_chipset->pc_name = "irongate";
100: alpha_pci_chipset->pc_mem = IRONGATE_MEM_BASE;
101: alpha_pci_chipset->pc_mem = IRONGATE_MEM_BASE;
102: alpha_pci_chipset->pc_bwx = 1;
103:
104: tag = pci_make_tag(&icp->ic_pc, 0, IRONGATE_PCIHOST_DEV, 0);
105:
106: /* Read the revision. */
107: reg = irongate_conf_read0(icp, tag, PCI_CLASS_REG);
108: icp->ic_rev = PCI_REVISION(reg);
109:
110: if (icp->ic_initted == 0) {
111: /* Don't do these twice, since they set up extents. */
112: irongate_bus_io_init(&icp->ic_iot, icp);
113: irongate_bus_mem_init(&icp->ic_memt, icp);
114:
115: #if 0
116: /* Only one each PCI I/O and MEM window. */
117: alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 1;
118: alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 1;
119:
120: alpha_bus_get_window = irongate_bus_get_window;
121: #endif
122: }
123:
124: icp->ic_initted = 1;
125: }
126:
127: int
128: irongate_match(struct device *parent, void *match, void *aux)
129: {
130: struct mainbus_attach_args *ma = aux;
131:
132: /* Make sure we're looking for an Irongate. */
133: if (strcmp(ma->ma_name, irongate_cd.cd_name) != 0)
134: return (0);
135:
136: if (irongate_found)
137: return (0);
138:
139: return (1);
140: }
141:
142: void
143: irongate_attach(struct device *parent, struct device *self, void *aux)
144: {
145: struct irongate_config *icp;
146: struct pcibus_attach_args pba;
147:
148: /* Note that we've attached the chipset; can't have 2 Irongates. */
149: irongate_found = 1;
150:
151: /*
152: * Set up the chipset's info; done once at console init time
153: * (maybe), but we must do it here as well to take care of things
154: * that need to use memory allocation.
155: */
156: icp = &irongate_configuration;
157: irongate_init(icp, 1);
158:
159: printf(": rev. %d\n", icp->ic_rev);
160:
161: irongate_dma_init(icp);
162:
163: /*
164: * Do PCI memory initialization that needs to be deferred until
165: * malloc is safe.
166: */
167: irongate_bus_mem_init2(&icp->ic_memt, icp);
168:
169: switch (cputype) {
170: #ifdef API_UP1000
171: case ST_API_NAUTILUS:
172: pci_up1000_pickintr(icp);
173: break;
174: #endif
175:
176: default:
177: panic("irongate_attach: shouldn't be here, really...");
178: }
179:
180: pba.pba_busname = "pci";
181: pba.pba_iot = &icp->ic_iot;
182: pba.pba_memt = &icp->ic_memt;
183: pba.pba_dmat =
184: alphabus_dma_get_tag(&icp->ic_dmat_pci, ALPHA_BUS_PCI);
185: pba.pba_pc = &icp->ic_pc;
186: pba.pba_domain = pci_ndomains++;
187: pba.pba_bus = 0;
188: pba.pba_bridgetag = NULL;
189: #ifdef notyet
190: pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
191: PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
192: #endif
193: (void) config_found(self, &pba, irongate_print);
194: }
195:
196: int
197: irongate_print(void *aux, const char *pnp)
198: {
199: struct pcibus_attach_args *pba = aux;
200:
201: /* Only PCIs can attach to Irongates; easy. */
202: if (pnp != NULL)
203: printf("%s at %s", pba->pba_busname, pnp);
204: printf(" bus %d", pba->pba_bus);
205: return (UNCONF);
206: }
207:
208: #if 0
209: int
210: irongate_bus_get_window(int type, int window,
211: struct alpha_bus_space_translation *abst)
212: {
213: struct irongate_config *icp = &irongate_configuration;
214: bus_space_tag_t st;
215: int error;
216:
217: switch (type) {
218: case ALPHA_BUS_TYPE_PCI_IO:
219: st = &icp->ic_iot;
220: break;
221:
222: case ALPHA_BUS_TYPE_PCI_MEM:
223: st = &icp->ic_memt;
224: break;
225:
226: default:
227: panic("irongate_bus_get_window");
228: }
229:
230: error = alpha_bus_space_get_window(st, window, abst);
231: if (error)
232: return (error);
233:
234: abst->abst_sys_start = IRONGATE_PHYSADDR(abst->abst_sys_start);
235: abst->abst_sys_end = IRONGATE_PHYSADDR(abst->abst_sys_end);
236:
237: return (0);
238: }
239: #endif
CVSweb