pcivar.h revision 1.43 1 /* $NetBSD: pcivar.h,v 1.43 2000/06/28 16:08:50 mrg Exp $ */
2
3 /*
4 * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
5 * Copyright (c) 1994 Charles M. Hannum. 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 by Charles M. Hannum.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef _DEV_PCI_PCIVAR_H_
34 #define _DEV_PCI_PCIVAR_H_
35
36 /*
37 * Definitions for PCI autoconfiguration.
38 *
39 * This file describes types and functions which are used for PCI
40 * configuration. Some of this information is machine-specific, and is
41 * provided by pci_machdep.h.
42 */
43
44 #include <machine/bus.h>
45 #include <dev/pci/pcireg.h>
46
47 /*
48 * Structures and definitions needed by the machine-dependent header.
49 */
50 typedef u_int32_t pcireg_t; /* configuration space register XXX */
51 struct pcibus_attach_args;
52
53 /*
54 * Machine-dependent definitions.
55 */
56 #include <machine/pci_machdep.h>
57
58 /*
59 * PCI bus attach arguments.
60 */
61 struct pcibus_attach_args {
62 char *pba_busname; /* XXX should be common */
63 bus_space_tag_t pba_iot; /* pci i/o space tag */
64 bus_space_tag_t pba_memt; /* pci mem space tag */
65 bus_dma_tag_t pba_dmat; /* DMA tag */
66 pci_chipset_tag_t pba_pc;
67 int pba_flags; /* flags; see below */
68
69 int pba_bus; /* PCI bus number */
70
71 #ifdef __PCI_OFW_BINDING
72 int pba_node; /* OFW node */
73 #endif
74
75 /*
76 * Interrupt swizzling information. These fields
77 * are only used by secondary busses.
78 */
79 u_int pba_intrswiz; /* how to swizzle pins */
80 pcitag_t pba_intrtag; /* intr. appears to come from here */
81 };
82
83 /*
84 * PCI device attach arguments.
85 */
86 struct pci_attach_args {
87 bus_space_tag_t pa_iot; /* pci i/o space tag */
88 bus_space_tag_t pa_memt; /* pci mem space tag */
89 bus_dma_tag_t pa_dmat; /* DMA tag */
90 pci_chipset_tag_t pa_pc;
91 int pa_flags; /* flags; see below */
92
93 u_int pa_device;
94 u_int pa_function;
95 pcitag_t pa_tag;
96 pcireg_t pa_id, pa_class;
97
98 #ifdef __PCI_OFW_BINDING
99 int pa_node; /* OFW node */
100 #endif
101
102 /*
103 * Interrupt information.
104 *
105 * "Intrline" is used on systems whose firmware puts
106 * the right routing data into the line register in
107 * configuration space. The rest are used on systems
108 * that do not.
109 */
110 u_int pa_intrswiz; /* how to swizzle pins if ppb */
111 pcitag_t pa_intrtag; /* intr. appears to come from here */
112 pci_intr_pin_t pa_intrpin; /* intr. appears on this pin */
113 pci_intr_line_t pa_intrline; /* intr. routing information */
114 };
115
116 /*
117 * Flags given in the bus and device attachment args.
118 */
119 #define PCI_FLAGS_IO_ENABLED 0x01 /* I/O space is enabled */
120 #define PCI_FLAGS_MEM_ENABLED 0x02 /* memory space is enabled */
121 #define PCI_FLAGS_MRL_OKAY 0x04 /* Memory Read Line okay */
122 #define PCI_FLAGS_MRM_OKAY 0x08 /* Memory Read Multiple okay */
123 #define PCI_FLAGS_MWI_OKAY 0x10 /* Memory Write and Invalidate
124 okay */
125
126 /*
127 * PCI device 'quirks'.
128 *
129 * In general strange behaviour which can be handled by a driver (e.g.
130 * a bridge's inability to pass a type of access correctly) should be.
131 * The quirks table should only contain information which impacts
132 * the operation of the MI PCI code and which can't be pushed lower
133 * (e.g. because it's unacceptable to require a driver to be present
134 * for the information to be known).
135 */
136 struct pci_quirkdata {
137 pci_vendor_id_t vendor; /* Vendor ID */
138 pci_product_id_t product; /* Product ID */
139 int quirks; /* quirks; see below */
140 };
141 #define PCI_QUIRK_MULTIFUNCTION 1
142
143 #include "locators.h"
144
145 /*
146 * Locators devices that attach to 'pcibus', as specified to config.
147 */
148 #define pcibuscf_bus cf_loc[PCIBUSCF_BUS]
149 #define PCIBUS_UNK_BUS PCIBUSCF_BUS_DEFAULT /* wildcarded 'bus' */
150
151 /*
152 * Locators for PCI devices, as specified to config.
153 */
154 #define pcicf_dev cf_loc[PCICF_DEV]
155 #define PCI_UNK_DEV PCICF_DEV_DEFAULT /* wildcarded 'dev' */
156
157 #define pcicf_function cf_loc[PCICF_FUNCTION]
158 #define PCI_UNK_FUNCTION PCICF_FUNCTION_DEFAULT /* wildcarded 'function' */
159
160 /*
161 * Configuration space access and utility functions. (Note that most,
162 * e.g. make_tag, conf_read, conf_write are declared by pci_machdep.h.)
163 */
164 pcireg_t pci_mapreg_type __P((pci_chipset_tag_t, pcitag_t, int));
165 int pci_mapreg_info __P((pci_chipset_tag_t, pcitag_t, int, pcireg_t,
166 bus_addr_t *, bus_size_t *, int *));
167 int pci_mapreg_map __P((struct pci_attach_args *, int, pcireg_t, int,
168 bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
169 bus_size_t *));
170
171 int pci_get_capability __P((pci_chipset_tag_t, pcitag_t, int,
172 int *, pcireg_t *));
173
174 /*
175 * Helper functions for autoconfiguration.
176 */
177 void pci_devinfo __P((pcireg_t, pcireg_t, int, char *));
178 void pci_conf_print __P((pci_chipset_tag_t, pcitag_t,
179 void (*)(pci_chipset_tag_t, pcitag_t, const pcireg_t *)));
180 const struct pci_quirkdata *
181 pci_lookup_quirkdata __P((pci_vendor_id_t, pci_product_id_t));
182
183 /*
184 * Misc.
185 */
186 char *pci_findvendor __P((pcireg_t));
187
188 #endif /* _DEV_PCI_PCIVAR_H_ */
189