pci_machdep.c revision 1.1 1 /* $NetBSD: pci_machdep.c,v 1.1 2000/06/14 16:06:59 soren Exp $ */
2
3 /*
4 * Copyright (c) 2000 Soren S. Jorvang
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the
18 * NetBSD Project. See http://www.netbsd.org/ for
19 * information about NetBSD.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/time.h>
38 #include <sys/systm.h>
39 #include <sys/errno.h>
40 #include <sys/device.h>
41
42 #include <vm/vm.h>
43 #include <vm/vm_kern.h>
44
45 #define _SGIMIPS_BUS_DMA_PRIVATE
46 #include <machine/bus.h>
47 #include <machine/intr.h>
48
49 #include <dev/pci/pcivar.h>
50 #include <dev/pci/pcireg.h>
51 #include <dev/pci/pcidevs.h>
52
53 /*
54 * PCI doesn't have any special needs; just use
55 * the generic versions of these functions.
56 */
57 struct sgimips_bus_dma_tag pci_bus_dma_tag = {
58 _bus_dmamap_create,
59 _bus_dmamap_destroy,
60 _bus_dmamap_load,
61 _bus_dmamap_load_mbuf,
62 _bus_dmamap_load_uio,
63 _bus_dmamap_load_raw,
64 _bus_dmamap_unload,
65 _bus_dmamap_sync,
66 _bus_dmamem_alloc,
67 _bus_dmamem_free,
68 _bus_dmamem_map,
69 _bus_dmamem_unmap,
70 _bus_dmamem_mmap,
71 };
72
73 void
74 pci_attach_hook(parent, self, pba)
75 struct device *parent, *self;
76 struct pcibus_attach_args *pba;
77 {
78 /* XXX */
79
80 return;
81 }
82
83 int
84 pci_bus_maxdevs(pc, busno)
85 pci_chipset_tag_t pc;
86 int busno;
87 {
88 #if 0
89 return 32;
90 #else
91 return 4; /* XXX O2 master aborts.. */
92 #endif
93 }
94
95 pcitag_t
96 pci_make_tag(pc, bus, device, function)
97 pci_chipset_tag_t pc;
98 int bus, device, function;
99 {
100 return (bus << 16) | (device << 11) | (function << 8);
101 }
102
103 void
104 pci_decompose_tag(pc, tag, bp, dp, fp)
105 pci_chipset_tag_t pc;
106 pcitag_t tag;
107 int *bp, *dp, *fp;
108 {
109 if (bp != NULL)
110 *bp = (tag >> 16) & 0xff;
111 if (dp != NULL)
112 *dp = (tag >> 11) & 0x1f;
113 if (fp != NULL)
114 *fp = (tag >> 8) & 0x07;
115 }
116
117 pcireg_t
118 pci_conf_read(pc, tag, reg)
119 pci_chipset_tag_t pc;
120 pcitag_t tag;
121 int reg;
122 {
123 return (*pc->pc_conf_read)(pc, tag, reg);
124 }
125
126 void
127 pci_conf_write(pc, tag, reg, data)
128 pci_chipset_tag_t pc;
129 pcitag_t tag;
130 int reg;
131 pcireg_t data;
132 {
133 (*pc->pc_conf_write)(pc, tag, reg, data);
134 }
135
136 int
137 pci_intr_map(pc, intrtag, pin, line, ihp)
138 pci_chipset_tag_t pc;
139 pcitag_t intrtag;
140 int pin, line;
141 pci_intr_handle_t *ihp;
142 {
143 int bus, dev, func;
144
145 pci_decompose_tag(pc, intrtag, &bus, &dev, &func);
146
147 *ihp = line;
148
149 return 0;
150 }
151
152 const char *
153 pci_intr_string(pc, ih)
154 pci_chipset_tag_t pc;
155 pci_intr_handle_t ih;
156 {
157 static char irqstr[8];
158
159 #if 0
160 sprintf(irqstr, "mace %d", ih);
161 #else
162 sprintf(irqstr, "mace");
163 #endif
164
165 return irqstr;
166 }
167
168 const struct evcnt *
169 pci_intr_evcnt(pc, ih)
170 pci_chipset_tag_t pc;
171 pci_intr_handle_t ih;
172 {
173
174 /* XXX for now, no evcnt parent reported */
175 return NULL;
176 }
177
178 extern void * crime_intr_establish(int, int, int, int (*)(void *), void *);
179
180 void *
181 pci_intr_establish(pc, ih, level, func, arg)
182 pci_chipset_tag_t pc;
183 pci_intr_handle_t ih;
184 int level, (*func)(void *);
185 void *arg;
186 {
187 crime_intr_establish(0, 0, 0, func, arg);
188
189 return (void *)-1; /* XXX */
190 }
191
192 void
193 pci_intr_disestablish(pc, cookie)
194 pci_chipset_tag_t pc;
195 void *cookie;
196 {
197 panic("pci_intr_disestablish: not implemented");
198
199 return;
200 }
201