pci_machdep.c revision 1.4 1 /* $NetBSD: pci_machdep.c,v 1.4 2000/12/28 22:59:10 sommerfeld 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 <uvm/uvm_extern.h>
43
44 #define _SGIMIPS_BUS_DMA_PRIVATE
45 #include <machine/bus.h>
46 #include <machine/intr.h>
47
48 #include <dev/pci/pcivar.h>
49 #include <dev/pci/pcireg.h>
50 #include <dev/pci/pcidevs.h>
51
52 /*
53 * PCI doesn't have any special needs; just use
54 * the generic versions of these functions.
55 */
56 struct sgimips_bus_dma_tag pci_bus_dma_tag = {
57 _bus_dmamap_create,
58 _bus_dmamap_destroy,
59 _bus_dmamap_load,
60 _bus_dmamap_load_mbuf,
61 _bus_dmamap_load_uio,
62 _bus_dmamap_load_raw,
63 _bus_dmamap_unload,
64 _bus_dmamap_sync,
65 _bus_dmamem_alloc,
66 _bus_dmamem_free,
67 _bus_dmamem_map,
68 _bus_dmamem_unmap,
69 _bus_dmamem_mmap,
70 };
71
72 void
73 pci_attach_hook(parent, self, pba)
74 struct device *parent, *self;
75 struct pcibus_attach_args *pba;
76 {
77 /* XXX */
78
79 return;
80 }
81
82 int
83 pci_bus_maxdevs(pc, busno)
84 pci_chipset_tag_t pc;
85 int busno;
86 {
87 #if 0
88 return 32;
89 #else
90 return 4; /* XXX O2 master aborts.. */
91 #endif
92 }
93
94 pcitag_t
95 pci_make_tag(pc, bus, device, function)
96 pci_chipset_tag_t pc;
97 int bus, device, function;
98 {
99 return (bus << 16) | (device << 11) | (function << 8);
100 }
101
102 void
103 pci_decompose_tag(pc, tag, bp, dp, fp)
104 pci_chipset_tag_t pc;
105 pcitag_t tag;
106 int *bp, *dp, *fp;
107 {
108 if (bp != NULL)
109 *bp = (tag >> 16) & 0xff;
110 if (dp != NULL)
111 *dp = (tag >> 11) & 0x1f;
112 if (fp != NULL)
113 *fp = (tag >> 8) & 0x07;
114 }
115
116 pcireg_t
117 pci_conf_read(pc, tag, reg)
118 pci_chipset_tag_t pc;
119 pcitag_t tag;
120 int reg;
121 {
122 return (*pc->pc_conf_read)(pc, tag, reg);
123 }
124
125 void
126 pci_conf_write(pc, tag, reg, data)
127 pci_chipset_tag_t pc;
128 pcitag_t tag;
129 int reg;
130 pcireg_t data;
131 {
132 (*pc->pc_conf_write)(pc, tag, reg, data);
133 }
134
135 int
136 pci_intr_map(pa, ihp)
137 struct pci_attach_args *pa;
138 pci_intr_handle_t *ihp;
139 {
140 int line = pa->pa_intrline;
141 #if 0
142 pci_chipset_tag_t pc = pa->pa_pc;
143 pcitag_t intrtag = pa->pa_intrtag;
144 int pin = pa->pa_intrpin;
145 int bus, dev, func;
146
147 pci_decompose_tag(pc, intrtag, &bus, &dev, &func);
148 #endif
149
150 *ihp = line;
151
152 return 0;
153 }
154
155 const char *
156 pci_intr_string(pc, ih)
157 pci_chipset_tag_t pc;
158 pci_intr_handle_t ih;
159 {
160 static char irqstr[8];
161
162 #if 0
163 sprintf(irqstr, "mace %d", ih);
164 #else
165 sprintf(irqstr, "mace");
166 #endif
167
168 return irqstr;
169 }
170
171 const struct evcnt *
172 pci_intr_evcnt(pc, ih)
173 pci_chipset_tag_t pc;
174 pci_intr_handle_t ih;
175 {
176
177 /* XXX for now, no evcnt parent reported */
178 return NULL;
179 }
180
181 extern void * crime_intr_establish(int, int, int, int (*)(void *), void *);
182
183 void *
184 pci_intr_establish(pc, ih, level, func, arg)
185 pci_chipset_tag_t pc;
186 pci_intr_handle_t ih;
187 int level, (*func)(void *);
188 void *arg;
189 {
190 crime_intr_establish(0, 0, 0, func, arg);
191
192 return (void *)-1; /* XXX */
193 }
194
195 void
196 pci_intr_disestablish(pc, cookie)
197 pci_chipset_tag_t pc;
198 void *cookie;
199 {
200 panic("pci_intr_disestablish: not implemented");
201
202 return;
203 }
204