pciconf_ofmethod.c revision 1.1.10.2 1 1.1.10.2 ad /* $NetBSD: pciconf_ofmethod.c,v 1.1.10.2 2007/12/03 19:04:04 ad Exp $ */
2 1.1.10.2 ad
3 1.1.10.2 ad /*-
4 1.1.10.2 ad * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 1.1.10.2 ad * All rights reserved.
6 1.1.10.2 ad *
7 1.1.10.2 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1.10.2 ad * by Jochen Kunz and Tim Rightnour
9 1.1.10.2 ad *
10 1.1.10.2 ad * Redistribution and use in source and binary forms, with or without
11 1.1.10.2 ad * modification, are permitted provided that the following conditions
12 1.1.10.2 ad * are met:
13 1.1.10.2 ad * 1. Redistributions of source code must retain the above copyright
14 1.1.10.2 ad * notice, this list of conditions and the following disclaimer.
15 1.1.10.2 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.10.2 ad * notice, this list of conditions and the following disclaimer in the
17 1.1.10.2 ad * documentation and/or other materials provided with the distribution.
18 1.1.10.2 ad * 3. All advertising materials mentioning features or use of this software
19 1.1.10.2 ad * must display the following acknowledgement:
20 1.1.10.2 ad * This product includes software developed by the NetBSD
21 1.1.10.2 ad * Foundation, Inc. and its contributors.
22 1.1.10.2 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.10.2 ad * contributors may be used to endorse or promote products derived
24 1.1.10.2 ad * from this software without specific prior written permission.
25 1.1.10.2 ad *
26 1.1.10.2 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.10.2 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.10.2 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.10.2 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.10.2 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.10.2 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.10.2 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.10.2 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.10.2 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.10.2 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.10.2 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.1.10.2 ad */
38 1.1.10.2 ad
39 1.1.10.2 ad /*
40 1.1.10.2 ad * Generic PowerPC functions for talking to a PCI Bridge via the RTAS or
41 1.1.10.2 ad * OF methods of the device.
42 1.1.10.2 ad */
43 1.1.10.2 ad
44 1.1.10.2 ad #include <sys/cdefs.h>
45 1.1.10.2 ad __KERNEL_RCSID(0, "$NetBSD: pciconf_ofmethod.c,v 1.1.10.2 2007/12/03 19:04:04 ad Exp $");
46 1.1.10.2 ad
47 1.1.10.2 ad #include <sys/types.h>
48 1.1.10.2 ad #include <sys/param.h>
49 1.1.10.2 ad #include <sys/time.h>
50 1.1.10.2 ad #include <sys/systm.h>
51 1.1.10.2 ad #include <sys/errno.h>
52 1.1.10.2 ad #include <sys/device.h>
53 1.1.10.2 ad
54 1.1.10.2 ad #include <uvm/uvm_extern.h>
55 1.1.10.2 ad
56 1.1.10.2 ad #define _POWERPC_BUS_DMA_PRIVATE
57 1.1.10.2 ad #include <machine/bus.h>
58 1.1.10.2 ad #include <machine/intr.h>
59 1.1.10.2 ad #include <machine/pio.h>
60 1.1.10.2 ad #include <dev/ofw/openfirm.h>
61 1.1.10.2 ad #include <dev/ofw/ofw_pci.h>
62 1.1.10.2 ad
63 1.1.10.2 ad #if NISA > 0
64 1.1.10.2 ad #include <dev/isa/isavar.h>
65 1.1.10.2 ad #endif
66 1.1.10.2 ad
67 1.1.10.2 ad #include <dev/pci/pcivar.h>
68 1.1.10.2 ad #include <dev/pci/pcireg.h>
69 1.1.10.2 ad #include <dev/pci/pcidevs.h>
70 1.1.10.2 ad
71 1.1.10.2 ad void
72 1.1.10.2 ad genppc_pci_ofmethod_attach_hook(struct device *parent, struct device *self,
73 1.1.10.2 ad struct pcibus_attach_args *pba)
74 1.1.10.2 ad {
75 1.1.10.2 ad
76 1.1.10.2 ad if (pba->pba_bus != 0)
77 1.1.10.2 ad return;
78 1.1.10.2 ad
79 1.1.10.2 ad aprint_normal(": OFW method configuration space access");
80 1.1.10.2 ad }
81 1.1.10.2 ad
82 1.1.10.2 ad pcitag_t
83 1.1.10.2 ad genppc_pci_ofmethod_make_tag(void *v, int bus, int dev, int func)
84 1.1.10.2 ad {
85 1.1.10.2 ad return ((bus << OFW_PCI_PHYS_HI_BUSSHIFT) & OFW_PCI_PHYS_HI_BUSMASK) |
86 1.1.10.2 ad ((dev << OFW_PCI_PHYS_HI_DEVICESHIFT) & OFW_PCI_PHYS_HI_DEVICEMASK)|
87 1.1.10.2 ad ((func << OFW_PCI_PHYS_HI_FUNCTIONSHIFT) &
88 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK);
89 1.1.10.2 ad }
90 1.1.10.2 ad
91 1.1.10.2 ad void
92 1.1.10.2 ad genppc_pci_ofmethod_decompose_tag(void *v, pcitag_t tag, int *bp, int *dp,
93 1.1.10.2 ad int *fp)
94 1.1.10.2 ad {
95 1.1.10.2 ad
96 1.1.10.2 ad if (bp != NULL)
97 1.1.10.2 ad *bp = OFW_PCI_PHYS_HI_BUS(tag);
98 1.1.10.2 ad if (dp != NULL)
99 1.1.10.2 ad *dp = OFW_PCI_PHYS_HI_DEVICE(tag);
100 1.1.10.2 ad if (fp != NULL)
101 1.1.10.2 ad *fp = OFW_PCI_PHYS_HI_FUNCTION(tag);
102 1.1.10.2 ad return;
103 1.1.10.2 ad }
104 1.1.10.2 ad
105 1.1.10.2 ad pcireg_t
106 1.1.10.2 ad genppc_pci_ofmethod_conf_read(void *v, pcitag_t tag, int reg)
107 1.1.10.2 ad {
108 1.1.10.2 ad pci_chipset_tag_t pc = (pci_chipset_tag_t)v;
109 1.1.10.2 ad pcireg_t data;
110 1.1.10.2 ad
111 1.1.10.2 ad tag &= OFW_PCI_PHYS_HI_BUSMASK | OFW_PCI_PHYS_HI_DEVICEMASK |
112 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK;
113 1.1.10.2 ad tag |= reg & OFW_PCI_PHYS_HI_REGISTERMASK;
114 1.1.10.2 ad if (OF_call_method("config-l@", pc->pc_ihandle, 1, 1, tag, &data) < 0)
115 1.1.10.2 ad return (pcireg_t) -1;
116 1.1.10.2 ad /*printf("data=0x%x\n", data); */
117 1.1.10.2 ad return data;
118 1.1.10.2 ad }
119 1.1.10.2 ad
120 1.1.10.2 ad void
121 1.1.10.2 ad genppc_pci_ofmethod_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data)
122 1.1.10.2 ad {
123 1.1.10.2 ad pci_chipset_tag_t pc = (pci_chipset_tag_t)v;
124 1.1.10.2 ad
125 1.1.10.2 ad tag &= OFW_PCI_PHYS_HI_BUSMASK | OFW_PCI_PHYS_HI_DEVICEMASK |
126 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK;
127 1.1.10.2 ad tag |= reg & OFW_PCI_PHYS_HI_REGISTERMASK;
128 1.1.10.2 ad OF_call_method("config-l!", pc->pc_ihandle, 2, 0, data, tag);
129 1.1.10.2 ad }
130 1.1.10.2 ad /* $NetBSD: pciconf_ofmethod.c,v 1.1.10.2 2007/12/03 19:04:04 ad Exp $ */
131 1.1.10.2 ad
132 1.1.10.2 ad /*-
133 1.1.10.2 ad * Copyright (c) 2007 The NetBSD Foundation, Inc.
134 1.1.10.2 ad * All rights reserved.
135 1.1.10.2 ad *
136 1.1.10.2 ad * This code is derived from software contributed to The NetBSD Foundation
137 1.1.10.2 ad * by Jochen Kunz and Tim Rightnour
138 1.1.10.2 ad *
139 1.1.10.2 ad * Redistribution and use in source and binary forms, with or without
140 1.1.10.2 ad * modification, are permitted provided that the following conditions
141 1.1.10.2 ad * are met:
142 1.1.10.2 ad * 1. Redistributions of source code must retain the above copyright
143 1.1.10.2 ad * notice, this list of conditions and the following disclaimer.
144 1.1.10.2 ad * 2. Redistributions in binary form must reproduce the above copyright
145 1.1.10.2 ad * notice, this list of conditions and the following disclaimer in the
146 1.1.10.2 ad * documentation and/or other materials provided with the distribution.
147 1.1.10.2 ad * 3. All advertising materials mentioning features or use of this software
148 1.1.10.2 ad * must display the following acknowledgement:
149 1.1.10.2 ad * This product includes software developed by the NetBSD
150 1.1.10.2 ad * Foundation, Inc. and its contributors.
151 1.1.10.2 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
152 1.1.10.2 ad * contributors may be used to endorse or promote products derived
153 1.1.10.2 ad * from this software without specific prior written permission.
154 1.1.10.2 ad *
155 1.1.10.2 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
156 1.1.10.2 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
157 1.1.10.2 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
158 1.1.10.2 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
159 1.1.10.2 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
160 1.1.10.2 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
161 1.1.10.2 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
162 1.1.10.2 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
163 1.1.10.2 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
164 1.1.10.2 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
165 1.1.10.2 ad * POSSIBILITY OF SUCH DAMAGE.
166 1.1.10.2 ad */
167 1.1.10.2 ad
168 1.1.10.2 ad /*
169 1.1.10.2 ad * Generic PowerPC functions for talking to a PCI Bridge via the RTAS or
170 1.1.10.2 ad * OF methods of the device.
171 1.1.10.2 ad */
172 1.1.10.2 ad
173 1.1.10.2 ad #include <sys/cdefs.h>
174 1.1.10.2 ad __KERNEL_RCSID(0, "$NetBSD: pciconf_ofmethod.c,v 1.1.10.2 2007/12/03 19:04:04 ad Exp $");
175 1.1.10.2 ad
176 1.1.10.2 ad #include <sys/types.h>
177 1.1.10.2 ad #include <sys/param.h>
178 1.1.10.2 ad #include <sys/time.h>
179 1.1.10.2 ad #include <sys/systm.h>
180 1.1.10.2 ad #include <sys/errno.h>
181 1.1.10.2 ad #include <sys/device.h>
182 1.1.10.2 ad
183 1.1.10.2 ad #include <uvm/uvm_extern.h>
184 1.1.10.2 ad
185 1.1.10.2 ad #define _POWERPC_BUS_DMA_PRIVATE
186 1.1.10.2 ad #include <machine/bus.h>
187 1.1.10.2 ad #include <machine/intr.h>
188 1.1.10.2 ad #include <machine/pio.h>
189 1.1.10.2 ad #include <dev/ofw/openfirm.h>
190 1.1.10.2 ad #include <dev/ofw/ofw_pci.h>
191 1.1.10.2 ad
192 1.1.10.2 ad #if NISA > 0
193 1.1.10.2 ad #include <dev/isa/isavar.h>
194 1.1.10.2 ad #endif
195 1.1.10.2 ad
196 1.1.10.2 ad #include <dev/pci/pcivar.h>
197 1.1.10.2 ad #include <dev/pci/pcireg.h>
198 1.1.10.2 ad #include <dev/pci/pcidevs.h>
199 1.1.10.2 ad
200 1.1.10.2 ad void
201 1.1.10.2 ad genppc_pci_ofmethod_attach_hook(struct device *parent, struct device *self,
202 1.1.10.2 ad struct pcibus_attach_args *pba)
203 1.1.10.2 ad {
204 1.1.10.2 ad
205 1.1.10.2 ad if (pba->pba_bus != 0)
206 1.1.10.2 ad return;
207 1.1.10.2 ad
208 1.1.10.2 ad aprint_normal(": OFW method configuration space access");
209 1.1.10.2 ad }
210 1.1.10.2 ad
211 1.1.10.2 ad pcitag_t
212 1.1.10.2 ad genppc_pci_ofmethod_make_tag(void *v, int bus, int dev, int func)
213 1.1.10.2 ad {
214 1.1.10.2 ad return ((bus << OFW_PCI_PHYS_HI_BUSSHIFT) & OFW_PCI_PHYS_HI_BUSMASK) |
215 1.1.10.2 ad ((dev << OFW_PCI_PHYS_HI_DEVICESHIFT) & OFW_PCI_PHYS_HI_DEVICEMASK)|
216 1.1.10.2 ad ((func << OFW_PCI_PHYS_HI_FUNCTIONSHIFT) &
217 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK);
218 1.1.10.2 ad }
219 1.1.10.2 ad
220 1.1.10.2 ad void
221 1.1.10.2 ad genppc_pci_ofmethod_decompose_tag(void *v, pcitag_t tag, int *bp, int *dp,
222 1.1.10.2 ad int *fp)
223 1.1.10.2 ad {
224 1.1.10.2 ad
225 1.1.10.2 ad if (bp != NULL)
226 1.1.10.2 ad *bp = OFW_PCI_PHYS_HI_BUS(tag);
227 1.1.10.2 ad if (dp != NULL)
228 1.1.10.2 ad *dp = OFW_PCI_PHYS_HI_DEVICE(tag);
229 1.1.10.2 ad if (fp != NULL)
230 1.1.10.2 ad *fp = OFW_PCI_PHYS_HI_FUNCTION(tag);
231 1.1.10.2 ad return;
232 1.1.10.2 ad }
233 1.1.10.2 ad
234 1.1.10.2 ad pcireg_t
235 1.1.10.2 ad genppc_pci_ofmethod_conf_read(void *v, pcitag_t tag, int reg)
236 1.1.10.2 ad {
237 1.1.10.2 ad pci_chipset_tag_t pc = (pci_chipset_tag_t)v;
238 1.1.10.2 ad pcireg_t data;
239 1.1.10.2 ad
240 1.1.10.2 ad tag &= OFW_PCI_PHYS_HI_BUSMASK | OFW_PCI_PHYS_HI_DEVICEMASK |
241 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK;
242 1.1.10.2 ad tag |= reg & OFW_PCI_PHYS_HI_REGISTERMASK;
243 1.1.10.2 ad if (OF_call_method("config-l@", pc->pc_ihandle, 1, 1, tag, &data) < 0)
244 1.1.10.2 ad return (pcireg_t) -1;
245 1.1.10.2 ad /*printf("data=0x%x\n", data); */
246 1.1.10.2 ad return data;
247 1.1.10.2 ad }
248 1.1.10.2 ad
249 1.1.10.2 ad void
250 1.1.10.2 ad genppc_pci_ofmethod_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data)
251 1.1.10.2 ad {
252 1.1.10.2 ad pci_chipset_tag_t pc = (pci_chipset_tag_t)v;
253 1.1.10.2 ad
254 1.1.10.2 ad tag &= OFW_PCI_PHYS_HI_BUSMASK | OFW_PCI_PHYS_HI_DEVICEMASK |
255 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK;
256 1.1.10.2 ad tag |= reg & OFW_PCI_PHYS_HI_REGISTERMASK;
257 1.1.10.2 ad OF_call_method("config-l!", pc->pc_ihandle, 2, 0, data, tag);
258 1.1.10.2 ad }
259 1.1.10.2 ad /* $NetBSD: pciconf_ofmethod.c,v 1.1.10.2 2007/12/03 19:04:04 ad Exp $ */
260 1.1.10.2 ad
261 1.1.10.2 ad /*-
262 1.1.10.2 ad * Copyright (c) 2007 The NetBSD Foundation, Inc.
263 1.1.10.2 ad * All rights reserved.
264 1.1.10.2 ad *
265 1.1.10.2 ad * This code is derived from software contributed to The NetBSD Foundation
266 1.1.10.2 ad * by Jochen Kunz and Tim Rightnour
267 1.1.10.2 ad *
268 1.1.10.2 ad * Redistribution and use in source and binary forms, with or without
269 1.1.10.2 ad * modification, are permitted provided that the following conditions
270 1.1.10.2 ad * are met:
271 1.1.10.2 ad * 1. Redistributions of source code must retain the above copyright
272 1.1.10.2 ad * notice, this list of conditions and the following disclaimer.
273 1.1.10.2 ad * 2. Redistributions in binary form must reproduce the above copyright
274 1.1.10.2 ad * notice, this list of conditions and the following disclaimer in the
275 1.1.10.2 ad * documentation and/or other materials provided with the distribution.
276 1.1.10.2 ad * 3. All advertising materials mentioning features or use of this software
277 1.1.10.2 ad * must display the following acknowledgement:
278 1.1.10.2 ad * This product includes software developed by the NetBSD
279 1.1.10.2 ad * Foundation, Inc. and its contributors.
280 1.1.10.2 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
281 1.1.10.2 ad * contributors may be used to endorse or promote products derived
282 1.1.10.2 ad * from this software without specific prior written permission.
283 1.1.10.2 ad *
284 1.1.10.2 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
285 1.1.10.2 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
286 1.1.10.2 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
287 1.1.10.2 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
288 1.1.10.2 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
289 1.1.10.2 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
290 1.1.10.2 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
291 1.1.10.2 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
292 1.1.10.2 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
293 1.1.10.2 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
294 1.1.10.2 ad * POSSIBILITY OF SUCH DAMAGE.
295 1.1.10.2 ad */
296 1.1.10.2 ad
297 1.1.10.2 ad /*
298 1.1.10.2 ad * Generic PowerPC functions for talking to a PCI Bridge via the RTAS or
299 1.1.10.2 ad * OF methods of the device.
300 1.1.10.2 ad */
301 1.1.10.2 ad
302 1.1.10.2 ad #include <sys/cdefs.h>
303 1.1.10.2 ad __KERNEL_RCSID(0, "$NetBSD: pciconf_ofmethod.c,v 1.1.10.2 2007/12/03 19:04:04 ad Exp $");
304 1.1.10.2 ad
305 1.1.10.2 ad #include <sys/types.h>
306 1.1.10.2 ad #include <sys/param.h>
307 1.1.10.2 ad #include <sys/time.h>
308 1.1.10.2 ad #include <sys/systm.h>
309 1.1.10.2 ad #include <sys/errno.h>
310 1.1.10.2 ad #include <sys/device.h>
311 1.1.10.2 ad
312 1.1.10.2 ad #include <uvm/uvm_extern.h>
313 1.1.10.2 ad
314 1.1.10.2 ad #define _POWERPC_BUS_DMA_PRIVATE
315 1.1.10.2 ad #include <machine/bus.h>
316 1.1.10.2 ad #include <machine/intr.h>
317 1.1.10.2 ad #include <machine/pio.h>
318 1.1.10.2 ad #include <dev/ofw/openfirm.h>
319 1.1.10.2 ad #include <dev/ofw/ofw_pci.h>
320 1.1.10.2 ad
321 1.1.10.2 ad #if NISA > 0
322 1.1.10.2 ad #include <dev/isa/isavar.h>
323 1.1.10.2 ad #endif
324 1.1.10.2 ad
325 1.1.10.2 ad #include <dev/pci/pcivar.h>
326 1.1.10.2 ad #include <dev/pci/pcireg.h>
327 1.1.10.2 ad #include <dev/pci/pcidevs.h>
328 1.1.10.2 ad
329 1.1.10.2 ad void
330 1.1.10.2 ad genppc_pci_ofmethod_attach_hook(struct device *parent, struct device *self,
331 1.1.10.2 ad struct pcibus_attach_args *pba)
332 1.1.10.2 ad {
333 1.1.10.2 ad
334 1.1.10.2 ad if (pba->pba_bus != 0)
335 1.1.10.2 ad return;
336 1.1.10.2 ad
337 1.1.10.2 ad aprint_normal(": OFW method configuration space access");
338 1.1.10.2 ad }
339 1.1.10.2 ad
340 1.1.10.2 ad pcitag_t
341 1.1.10.2 ad genppc_pci_ofmethod_make_tag(void *v, int bus, int dev, int func)
342 1.1.10.2 ad {
343 1.1.10.2 ad return ((bus << OFW_PCI_PHYS_HI_BUSSHIFT) & OFW_PCI_PHYS_HI_BUSMASK) |
344 1.1.10.2 ad ((dev << OFW_PCI_PHYS_HI_DEVICESHIFT) & OFW_PCI_PHYS_HI_DEVICEMASK)|
345 1.1.10.2 ad ((func << OFW_PCI_PHYS_HI_FUNCTIONSHIFT) &
346 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK);
347 1.1.10.2 ad }
348 1.1.10.2 ad
349 1.1.10.2 ad void
350 1.1.10.2 ad genppc_pci_ofmethod_decompose_tag(void *v, pcitag_t tag, int *bp, int *dp,
351 1.1.10.2 ad int *fp)
352 1.1.10.2 ad {
353 1.1.10.2 ad
354 1.1.10.2 ad if (bp != NULL)
355 1.1.10.2 ad *bp = OFW_PCI_PHYS_HI_BUS(tag);
356 1.1.10.2 ad if (dp != NULL)
357 1.1.10.2 ad *dp = OFW_PCI_PHYS_HI_DEVICE(tag);
358 1.1.10.2 ad if (fp != NULL)
359 1.1.10.2 ad *fp = OFW_PCI_PHYS_HI_FUNCTION(tag);
360 1.1.10.2 ad return;
361 1.1.10.2 ad }
362 1.1.10.2 ad
363 1.1.10.2 ad pcireg_t
364 1.1.10.2 ad genppc_pci_ofmethod_conf_read(void *v, pcitag_t tag, int reg)
365 1.1.10.2 ad {
366 1.1.10.2 ad pci_chipset_tag_t pc = (pci_chipset_tag_t)v;
367 1.1.10.2 ad pcireg_t data;
368 1.1.10.2 ad
369 1.1.10.2 ad tag &= OFW_PCI_PHYS_HI_BUSMASK | OFW_PCI_PHYS_HI_DEVICEMASK |
370 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK;
371 1.1.10.2 ad tag |= reg & OFW_PCI_PHYS_HI_REGISTERMASK;
372 1.1.10.2 ad if (OF_call_method("config-l@", pc->pc_ihandle, 1, 1, tag, &data) < 0)
373 1.1.10.2 ad return (pcireg_t) -1;
374 1.1.10.2 ad /*printf("data=0x%x\n", data); */
375 1.1.10.2 ad return data;
376 1.1.10.2 ad }
377 1.1.10.2 ad
378 1.1.10.2 ad void
379 1.1.10.2 ad genppc_pci_ofmethod_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data)
380 1.1.10.2 ad {
381 1.1.10.2 ad pci_chipset_tag_t pc = (pci_chipset_tag_t)v;
382 1.1.10.2 ad
383 1.1.10.2 ad tag &= OFW_PCI_PHYS_HI_BUSMASK | OFW_PCI_PHYS_HI_DEVICEMASK |
384 1.1.10.2 ad OFW_PCI_PHYS_HI_FUNCTIONMASK;
385 1.1.10.2 ad tag |= reg & OFW_PCI_PHYS_HI_REGISTERMASK;
386 1.1.10.2 ad OF_call_method("config-l!", pc->pc_ihandle, 2, 0, data, tag);
387 1.1.10.2 ad }
388