1 /* $NetBSD: pci_machdep.c,v 1.19 2006/08/30 23:35:10 rumble Exp $ */
4 * Copyright (c) 2000 Soren S. Jorvang
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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 $");
41 #include <sys/types.h>
42 #include <sys/param.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
;
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 */
78 pci_bus_maxdevs(pci_chipset_tag_t pc
, int busno
)
81 return (*pc
->pc_bus_maxdevs
)(pc
, busno
);
85 pci_make_tag(pci_chipset_tag_t pc
, int bus
, int device
, int function
)
88 return (bus
<< 16) | (device
<< 11) | (function
<< 8);
92 pci_decompose_tag(pci_chipset_tag_t pc
, pcitag_t tag
, int *bp
, int *dp
, int *fp
)
96 *bp
= (tag
>> 16) & 0xff;
98 *dp
= (tag
>> 11) & 0x1f;
100 *fp
= (tag
>> 8) & 0x07;
104 pci_conf_read(pci_chipset_tag_t pc
, pcitag_t tag
, int reg
)
107 return (*pc
->pc_conf_read
)(pc
, tag
, reg
);
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
);
124 pci_intr_string(pci_chipset_tag_t pc
, pci_intr_handle_t ih
)
126 return (*pc
->pc_intr_string
)(pc
, ih
);
130 pci_intr_evcnt(pci_chipset_tag_t pc
, pci_intr_handle_t ih
)
133 /* XXX for now, no evcnt parent reported */
138 pci_intr_setattr(pci_chipset_tag_t pc
, pci_intr_handle_t
*ih
,
139 int attr
, uint64_t data
)
143 case PCI_INTR_MPSAFE
:
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
);
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
,
171 if (pc
->pc_conf_hook
)
172 return (*pc
->pc_conf_hook
)(pc
, bus
, device
, function
, id
);
174 return (PCI_CONF_DEFAULT
);
178 pci_conf_interrupt(pci_chipset_tag_t pc
, int bus
, int dev
, int pin
, int swiz
,