Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / sgimips / pci / pci_machdep.c
blobff36ae26b086c5307a24b0002319805f8c595520
1 /* $NetBSD: pci_machdep.c,v 1.19 2006/08/30 23:35:10 rumble Exp $ */
3 /*
4 * Copyright (c) 2000 Soren S. Jorvang
5 * All rights reserved.
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.
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.
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.19 2006/08/30 23:35:10 rumble Exp $");
38 #include "opt_pci.h"
39 #include "pci.h"
41 #include <sys/types.h>
42 #include <sys/param.h>
43 #include <sys/time.h>
44 #include <sys/systm.h>
45 #include <sys/errno.h>
46 #include <sys/device.h>
48 #include <uvm/uvm_extern.h>
50 #define _SGIMIPS_BUS_DMA_PRIVATE
51 #include <machine/bus.h>
52 #include <machine/intr.h>
53 #include <machine/sysconf.h>
55 #include <dev/pci/pcivar.h>
56 #include <dev/pci/pcireg.h>
57 #include <dev/pci/pcidevs.h>
58 #include <dev/pci/pciconf.h>
60 struct sgimips_bus_dma_tag pci_bus_dma_tag;
62 void
63 pci_attach_hook(struct device *parent, struct device *self, struct pcibus_attach_args *pba)
66 * PCI doesn't have any special needs; just use
67 * the generic versions of these functions as
68 * established in sgimips_bus_dma_init().
70 pci_bus_dma_tag = sgimips_default_bus_dma_tag; /* struct copy */
72 /* XXX */
74 return;
77 int
78 pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
81 return (*pc->pc_bus_maxdevs)(pc, busno);
84 pcitag_t
85 pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
88 return (bus << 16) | (device << 11) | (function << 8);
91 void
92 pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp, int *dp, int *fp)
95 if (bp != NULL)
96 *bp = (tag >> 16) & 0xff;
97 if (dp != NULL)
98 *dp = (tag >> 11) & 0x1f;
99 if (fp != NULL)
100 *fp = (tag >> 8) & 0x07;
103 pcireg_t
104 pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
107 return (*pc->pc_conf_read)(pc, tag, reg);
110 void
111 pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
114 (*pc->pc_conf_write)(pc, tag, reg, data);
118 pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
120 return (*pa->pa_pc->pc_intr_map)(pa, ihp);
123 const char *
124 pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih)
126 return (*pc->pc_intr_string)(pc, ih);
129 const struct evcnt *
130 pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih)
133 /* XXX for now, no evcnt parent reported */
134 return NULL;
138 pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ih,
139 int attr, uint64_t data)
142 switch (attr) {
143 case PCI_INTR_MPSAFE:
144 return 0;
145 default:
146 return ENODEV;
150 void *
151 pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
152 int (*func)(void *), void *arg)
155 return (void *)(*pc->intr_establish)(ih, 0, func, arg);
158 void
159 pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
162 (*pc->intr_disestablish)(cookie);
165 #ifdef PCI_NETBSD_CONFIGURE
167 pci_conf_hook(pci_chipset_tag_t pc, int bus, int device, int function,
168 pcireg_t id)
171 if (pc->pc_conf_hook)
172 return (*pc->pc_conf_hook)(pc, bus, device, function, id);
173 else
174 return (PCI_CONF_DEFAULT);
177 void
178 pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int pin, int swiz,
179 int *iline)
182 return;
184 #endif