pci.h revision 1.56 1 1.56 riastrad /* $NetBSD: pci.h,v 1.56 2022/10/25 23:37:06 riastradh Exp $ */
2 1.2 riastrad
3 1.2 riastrad /*-
4 1.2 riastrad * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 1.2 riastrad * All rights reserved.
6 1.2 riastrad *
7 1.2 riastrad * This code is derived from software contributed to The NetBSD Foundation
8 1.2 riastrad * by Taylor R. Campbell.
9 1.2 riastrad *
10 1.2 riastrad * Redistribution and use in source and binary forms, with or without
11 1.2 riastrad * modification, are permitted provided that the following conditions
12 1.2 riastrad * are met:
13 1.2 riastrad * 1. Redistributions of source code must retain the above copyright
14 1.2 riastrad * notice, this list of conditions and the following disclaimer.
15 1.2 riastrad * 2. Redistributions in binary form must reproduce the above copyright
16 1.2 riastrad * notice, this list of conditions and the following disclaimer in the
17 1.2 riastrad * documentation and/or other materials provided with the distribution.
18 1.2 riastrad *
19 1.2 riastrad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.2 riastrad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.2 riastrad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.2 riastrad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.2 riastrad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.2 riastrad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.2 riastrad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.2 riastrad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.2 riastrad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.2 riastrad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.2 riastrad * POSSIBILITY OF SUCH DAMAGE.
30 1.2 riastrad */
31 1.2 riastrad
32 1.2 riastrad #ifndef _LINUX_PCI_H_
33 1.2 riastrad #define _LINUX_PCI_H_
34 1.2 riastrad
35 1.11 nonaka #ifdef _KERNEL_OPT
36 1.10 nonaka #include "acpica.h"
37 1.11 nonaka #endif
38 1.10 nonaka
39 1.2 riastrad #include <sys/types.h>
40 1.4 riastrad #include <sys/param.h>
41 1.2 riastrad #include <sys/bus.h>
42 1.3 riastrad #include <sys/cdefs.h>
43 1.2 riastrad #include <sys/kmem.h>
44 1.2 riastrad #include <sys/systm.h>
45 1.2 riastrad
46 1.4 riastrad #include <machine/limits.h>
47 1.4 riastrad
48 1.2 riastrad #include <dev/pci/pcidevs.h>
49 1.2 riastrad #include <dev/pci/pcireg.h>
50 1.2 riastrad #include <dev/pci/pcivar.h>
51 1.4 riastrad #include <dev/pci/agpvar.h>
52 1.55 mrg #include <dev/pci/ppbvar.h>
53 1.2 riastrad
54 1.39 maya #include <linux/device.h>
55 1.7 riastrad #include <linux/dma-mapping.h>
56 1.39 maya #include <linux/errno.h>
57 1.39 maya #include <linux/io.h>
58 1.43 riastrad #include <linux/interrupt.h>
59 1.2 riastrad #include <linux/ioport.h>
60 1.15 riastrad #include <linux/kernel.h>
61 1.2 riastrad
62 1.47 riastrad struct acpi_devnode;
63 1.25 riastrad struct pci_driver;
64 1.55 mrg struct pci_dev;
65 1.25 riastrad
66 1.10 nonaka struct pci_bus {
67 1.29 riastrad /* NetBSD private members */
68 1.29 riastrad pci_chipset_tag_t pb_pc;
69 1.29 riastrad device_t pb_dev;
70 1.29 riastrad
71 1.29 riastrad /* Linux API */
72 1.28 riastrad u_int number;
73 1.55 mrg
74 1.55 mrg struct pci_dev *self;
75 1.10 nonaka };
76 1.2 riastrad
77 1.2 riastrad struct pci_device_id {
78 1.2 riastrad uint32_t vendor;
79 1.2 riastrad uint32_t device;
80 1.2 riastrad uint32_t subvendor;
81 1.2 riastrad uint32_t subdevice;
82 1.2 riastrad uint32_t class;
83 1.2 riastrad uint32_t class_mask;
84 1.2 riastrad unsigned long driver_data;
85 1.2 riastrad };
86 1.2 riastrad
87 1.49 riastrad #define PCI_DEVICE(VENDOR, DEVICE) \
88 1.49 riastrad .vendor = (VENDOR), \
89 1.49 riastrad .device = (DEVICE)
90 1.49 riastrad
91 1.29 riastrad #define PCI_ANY_ID (~0)
92 1.2 riastrad
93 1.2 riastrad #define PCI_BASE_CLASS_DISPLAY PCI_CLASS_DISPLAY
94 1.2 riastrad
95 1.15 riastrad #define PCI_CLASS_DISPLAY_VGA \
96 1.15 riastrad ((PCI_CLASS_DISPLAY << 8) | PCI_SUBCLASS_DISPLAY_VGA)
97 1.53 riastrad CTASSERT(PCI_CLASS_DISPLAY_VGA == 0x0300);
98 1.53 riastrad
99 1.53 riastrad #define PCI_CLASS_DISPLAY_OTHER \
100 1.53 riastrad ((PCI_CLASS_DISPLAY << 8) | PCI_SUBCLASS_DISPLAY_MISC)
101 1.53 riastrad CTASSERT(PCI_CLASS_DISPLAY_OTHER == 0x0380);
102 1.53 riastrad
103 1.2 riastrad #define PCI_CLASS_BRIDGE_ISA \
104 1.2 riastrad ((PCI_CLASS_BRIDGE << 8) | PCI_SUBCLASS_BRIDGE_ISA)
105 1.2 riastrad CTASSERT(PCI_CLASS_BRIDGE_ISA == 0x0601);
106 1.2 riastrad
107 1.5 riastrad /* XXX This is getting silly... */
108 1.29 riastrad #define PCI_VENDOR_ID_APPLE PCI_VENDOR_APPLE
109 1.5 riastrad #define PCI_VENDOR_ID_ASUSTEK PCI_VENDOR_ASUSTEK
110 1.5 riastrad #define PCI_VENDOR_ID_ATI PCI_VENDOR_ATI
111 1.5 riastrad #define PCI_VENDOR_ID_DELL PCI_VENDOR_DELL
112 1.5 riastrad #define PCI_VENDOR_ID_IBM PCI_VENDOR_IBM
113 1.5 riastrad #define PCI_VENDOR_ID_HP PCI_VENDOR_HP
114 1.2 riastrad #define PCI_VENDOR_ID_INTEL PCI_VENDOR_INTEL
115 1.7 riastrad #define PCI_VENDOR_ID_NVIDIA PCI_VENDOR_NVIDIA
116 1.29 riastrad #define PCI_VENDOR_ID_SI PCI_VENDOR_SIS
117 1.5 riastrad #define PCI_VENDOR_ID_SONY PCI_VENDOR_SONY
118 1.5 riastrad #define PCI_VENDOR_ID_VIA PCI_VENDOR_VIATECH
119 1.5 riastrad
120 1.40 riastrad #define PCI_SUBVENDOR_ID_REDHAT_QUMRANET 0x1af4
121 1.40 riastrad
122 1.5 riastrad #define PCI_DEVICE_ID_ATI_RADEON_QY PCI_PRODUCT_ATI_RADEON_RV100_QY
123 1.2 riastrad
124 1.40 riastrad #define PCI_SUBDEVICE_ID_QEMU 0x1100
125 1.40 riastrad
126 1.2 riastrad #define PCI_DEVFN(DEV, FN) \
127 1.2 riastrad (__SHIFTIN((DEV), __BITS(3, 7)) | __SHIFTIN((FN), __BITS(0, 2)))
128 1.51 riastrad #define PCI_SLOT(DEVFN) ((int)__SHIFTOUT((DEVFN), __BITS(3, 7)))
129 1.51 riastrad #define PCI_FUNC(DEVFN) ((int)__SHIFTOUT((DEVFN), __BITS(0, 2)))
130 1.51 riastrad
131 1.51 riastrad #define PCI_DEVID(BUS, DEVFN) \
132 1.51 riastrad (__SHIFTIN((BUS), __BITS(15, 8)) | __SHIFTIN((DEVFN), __BITS(7, 0)))
133 1.51 riastrad #define PCI_BUS_NUM(DEVID) ((int)__SHIFTOUT((DEVID), __BITS(15,8)))
134 1.2 riastrad
135 1.4 riastrad #define PCI_NUM_RESOURCES ((PCI_MAPREG_END - PCI_MAPREG_START) / 4)
136 1.5 riastrad #define DEVICE_COUNT_RESOURCE PCI_NUM_RESOURCES
137 1.4 riastrad
138 1.2 riastrad #define PCI_CAP_ID_AGP PCI_CAP_AGP
139 1.2 riastrad
140 1.55 mrg #define PCI_EXP_LNKCTL PCIE_LCSR
141 1.55 mrg #define PCI_EXP_LNKCTL_HAWD PCIE_LCSR_HAWD
142 1.55 mrg #define PCI_EXP_DEVSTA (PCIE_DCSR + 2)
143 1.55 mrg #define PCI_EXP_DEVSTA_TRPND (PCIE_DCSR_TRANSACTION_PND >> 16)
144 1.55 mrg #define PCI_EXP_LNKCTL2 PCIE_LCAP2
145 1.55 mrg #define PCI_EXP_LNKCTL2_ENTER_COMP PCIE_LCSR2_ENT_COMPL
146 1.55 mrg #define PCI_EXP_LNKCTL2_TX_MARGIN PCIE_LCSR2_TX_MARGIN
147 1.55 mrg #define PCI_EXP_LNKCTL2_TLS PCIE_LCSR2_TGT_LSPEED
148 1.55 mrg #define PCI_EXP_LNKCTL2_TLS_2_5GT PCIE_LCSR2_TGT_LSPEED_2_5G
149 1.55 mrg #define PCI_EXP_LNKCTL2_TLS_5_0GT PCIE_LCSR2_TGT_LSPEED_5G
150 1.55 mrg #define PCI_EXP_LNKCTL2_TLS_8_0GT PCIE_LCSR2_TGT_LSPEED_8G
151 1.55 mrg #define PCI_EXP_LNKCAP PCIE_LCAP
152 1.55 mrg #define PCI_EXP_LNKCAP_CLKPM PCIE_LCAP_CLOCK_PM
153 1.55 mrg
154 1.55 mrg
155 1.4 riastrad typedef int pci_power_t;
156 1.4 riastrad
157 1.4 riastrad #define PCI_D0 0
158 1.4 riastrad #define PCI_D1 1
159 1.4 riastrad #define PCI_D2 2
160 1.4 riastrad #define PCI_D3hot 3
161 1.4 riastrad #define PCI_D3cold 4
162 1.4 riastrad
163 1.4 riastrad #define __pci_iomem
164 1.4 riastrad
165 1.2 riastrad struct pci_dev {
166 1.2 riastrad struct pci_attach_args pd_pa;
167 1.2 riastrad int pd_kludges; /* Gotta lose 'em... */
168 1.2 riastrad #define NBPCI_KLUDGE_GET_MUMBLE 0x01
169 1.2 riastrad #define NBPCI_KLUDGE_MAP_ROM 0x02
170 1.2 riastrad bus_space_tag_t pd_rom_bst;
171 1.2 riastrad bus_space_handle_t pd_rom_bsh;
172 1.2 riastrad bus_size_t pd_rom_size;
173 1.18 riastrad bus_space_handle_t pd_rom_found_bsh;
174 1.19 riastrad bus_size_t pd_rom_found_size;
175 1.2 riastrad void *pd_rom_vaddr;
176 1.2 riastrad device_t pd_dev;
177 1.42 riastrad void *pd_drvdata;
178 1.4 riastrad struct {
179 1.4 riastrad pcireg_t type;
180 1.4 riastrad bus_addr_t addr;
181 1.4 riastrad bus_size_t size;
182 1.4 riastrad int flags;
183 1.4 riastrad bus_space_tag_t bst;
184 1.4 riastrad bus_space_handle_t bsh;
185 1.4 riastrad void __pci_iomem *kva;
186 1.34 riastrad bool mapped;
187 1.4 riastrad } pd_resources[PCI_NUM_RESOURCES];
188 1.5 riastrad struct pci_conf_state *pd_saved_state;
189 1.10 nonaka struct acpi_devnode *pd_ad;
190 1.27 riastrad pci_intr_handle_t *pd_intr_handles;
191 1.29 riastrad unsigned pd_enablecnt;
192 1.27 riastrad
193 1.27 riastrad /* Linx API only below */
194 1.2 riastrad struct pci_bus *bus;
195 1.2 riastrad uint32_t devfn;
196 1.2 riastrad uint16_t vendor;
197 1.2 riastrad uint16_t device;
198 1.2 riastrad uint16_t subsystem_vendor;
199 1.2 riastrad uint16_t subsystem_device;
200 1.2 riastrad uint8_t revision;
201 1.2 riastrad uint32_t class;
202 1.5 riastrad bool msi_enabled;
203 1.30 riastrad bool no_64bit_msi;
204 1.2 riastrad };
205 1.2 riastrad
206 1.46 riastrad enum pci_bus_speed {
207 1.46 riastrad PCI_SPEED_UNKNOWN,
208 1.46 riastrad PCIE_SPEED_2_5GT,
209 1.46 riastrad PCIE_SPEED_5_0GT,
210 1.46 riastrad PCIE_SPEED_8_0GT,
211 1.46 riastrad PCIE_SPEED_16_0GT,
212 1.54 mrg PCIE_SPEED_32_0GT,
213 1.54 mrg PCIE_SPEED_64_0GT,
214 1.54 mrg };
215 1.54 mrg
216 1.54 mrg /*
217 1.54 mrg * Actually values from the Link Status register, bits 16-19. Don't use
218 1.54 mrg * these as a bit-mask -- these are the only known, valid values.
219 1.54 mrg */
220 1.54 mrg enum pcie_link_width {
221 1.54 mrg PCIE_LNK_WIDTH_RESRV = 0,
222 1.54 mrg PCIE_LNK_X1 = __BIT(0),
223 1.54 mrg PCIE_LNK_X2 = __BIT(1),
224 1.54 mrg PCIE_LNK_X4 = __BIT(2),
225 1.54 mrg PCIE_LNK_X8 = __BIT(3),
226 1.54 mrg PCIE_LNK_X12 = __BITS(2,3),
227 1.54 mrg PCIE_LNK_X16 = __BIT(4),
228 1.54 mrg PCIE_LNK_X32 = __BIT(5),
229 1.54 mrg PCIE_LNK_WIDTH_UNKNOWN = __BITS(0, 7),
230 1.46 riastrad };
231 1.46 riastrad
232 1.17 riastrad #define PCIBIOS_MIN_MEM 0x100000 /* XXX bogus x86 kludge bollocks */
233 1.2 riastrad
234 1.37 riastrad #define __pci_rom_iomem
235 1.2 riastrad
236 1.37 riastrad /* Namespace. */
237 1.37 riastrad #define pci_bus_alloc_resource linux_pci_bus_alloc_resource
238 1.37 riastrad #define pci_bus_read_config_byte linux_pci_bus_read_config_byte
239 1.37 riastrad #define pci_bus_read_config_dword linux_pci_bus_read_config_dword
240 1.37 riastrad #define pci_bus_read_config_word linux_pci_bus_read_config_word
241 1.37 riastrad #define pci_bus_write_config_byte linux_pci_bus_write_config_byte
242 1.37 riastrad #define pci_bus_write_config_dword linux_pci_bus_write_config_dword
243 1.37 riastrad #define pci_bus_write_config_word linux_pci_bus_write_config_word
244 1.37 riastrad #define pci_clear_master linux_pci_clear_master
245 1.37 riastrad #define pci_dev_dev linux_pci_dev_dev
246 1.49 riastrad #define pci_dev_present linux_pci_dev_present
247 1.37 riastrad #define pci_dev_put linux_pci_dev_put
248 1.37 riastrad #define pci_disable_msi linux_pci_disable_msi
249 1.37 riastrad #define pci_disable_rom linux_pci_disable_rom
250 1.37 riastrad #define pci_dma_supported linux_pci_dma_supported
251 1.37 riastrad #define pci_domain_nr linux_pci_domain_nr
252 1.37 riastrad #define pci_enable_msi linux_pci_enable_msi
253 1.37 riastrad #define pci_enable_rom linux_pci_enable_rom
254 1.37 riastrad #define pci_find_capability linux_pci_find_capability
255 1.37 riastrad #define pci_get_class linux_pci_get_class
256 1.41 riastrad #define pci_get_domain_bus_and_slot linux_pci_get_domain_bus_and_slot
257 1.37 riastrad #define pci_get_drvdata linux_pci_get_drvdata
258 1.37 riastrad #define pci_iomap linux_pci_iomap
259 1.37 riastrad #define pci_iounmap linux_pci_iounmap
260 1.37 riastrad #define pci_is_pcie linux_pci_is_pcie
261 1.37 riastrad #define pci_is_root_bus linux_pci_is_root_bus
262 1.44 riastrad #define pci_is_thunderbolt_attached linux_pci_is_thunderbolt_attached
263 1.37 riastrad #define pci_map_rom linux_pci_map_rom
264 1.50 riastrad #define pci_name linux_pci_name
265 1.37 riastrad #define pci_platform_rom linux_pci_platform_rom
266 1.37 riastrad #define pci_read_config_byte linux_pci_read_config_byte
267 1.37 riastrad #define pci_read_config_dword linux_pci_read_config_dword
268 1.37 riastrad #define pci_read_config_word linux_pci_read_config_word
269 1.56 riastrad #define pci_release_region linux_pci_release_region
270 1.56 riastrad #define pci_release_regions linux_pci_release_regions
271 1.56 riastrad #define pci_request_region linux_pci_request_region
272 1.56 riastrad #define pci_request_regions linux_pci_request_regions
273 1.37 riastrad #define pci_resource_end linux_pci_resource_end
274 1.37 riastrad #define pci_resource_flags linux_pci_resource_flags
275 1.37 riastrad #define pci_resource_len linux_pci_resource_len
276 1.37 riastrad #define pci_resource_start linux_pci_resource_start
277 1.37 riastrad #define pci_restore_state linux_pci_restore_state
278 1.37 riastrad #define pci_save_state linux_pci_save_state
279 1.42 riastrad #define pci_set_drvdata linux_pci_set_drvdata
280 1.37 riastrad #define pci_set_master linux_pci_set_master
281 1.37 riastrad #define pci_unmap_rom linux_pci_unmap_rom
282 1.37 riastrad #define pci_write_config_byte linux_pci_write_config_byte
283 1.37 riastrad #define pci_write_config_dword linux_pci_write_config_dword
284 1.37 riastrad #define pci_write_config_word linux_pci_write_config_word
285 1.37 riastrad #define pcibios_align_resource linux_pcibios_align_resource
286 1.54 mrg #define pcie_get_speed_cap linux_pcie_get_speed_cap
287 1.54 mrg #define pcie_bandwidth_available linux_pcie_bandwidth_available
288 1.55 mrg #define pcie_read_config_dword linux_pcie_capability_read_dword
289 1.55 mrg #define pcie_read_config_word linux_pcie_capability_read_word
290 1.55 mrg #define pcie_write_config_dword linux_pcie_capability_write_dword
291 1.55 mrg #define pcie_write_config_word linux_pcie_capability_write_word
292 1.37 riastrad
293 1.37 riastrad /* NetBSD local additions. */
294 1.37 riastrad void linux_pci_dev_init(struct pci_dev *, device_t, device_t,
295 1.37 riastrad const struct pci_attach_args *, int);
296 1.37 riastrad void linux_pci_dev_destroy(struct pci_dev *);
297 1.37 riastrad
298 1.37 riastrad /* NetBSD no-renames because use requires review. */
299 1.37 riastrad int linux_pci_enable_device(struct pci_dev *);
300 1.37 riastrad void linux_pci_disable_device(struct pci_dev *);
301 1.37 riastrad
302 1.37 riastrad bool pci_is_root_bus(struct pci_bus *);
303 1.37 riastrad int pci_domain_nr(struct pci_bus *);
304 1.37 riastrad
305 1.37 riastrad device_t pci_dev_dev(struct pci_dev *);
306 1.42 riastrad void pci_set_drvdata(struct pci_dev *, void *);
307 1.42 riastrad void * pci_get_drvdata(struct pci_dev *);
308 1.50 riastrad const char * pci_name(struct pci_dev *);
309 1.37 riastrad
310 1.37 riastrad int pci_find_capability(struct pci_dev *, int);
311 1.37 riastrad bool pci_is_pcie(struct pci_dev *);
312 1.37 riastrad bool pci_dma_supported(struct pci_dev *, uintmax_t);
313 1.44 riastrad bool pci_is_thunderbolt_attached(struct pci_dev *);
314 1.37 riastrad
315 1.37 riastrad int pci_read_config_dword(struct pci_dev *, int, uint32_t *);
316 1.37 riastrad int pci_read_config_word(struct pci_dev *, int, uint16_t *);
317 1.37 riastrad int pci_read_config_byte(struct pci_dev *, int, uint8_t *);
318 1.37 riastrad int pci_write_config_dword(struct pci_dev *, int, uint32_t);
319 1.37 riastrad int pci_write_config_word(struct pci_dev *, int, uint16_t);
320 1.37 riastrad int pci_write_config_byte(struct pci_dev *, int, uint8_t);
321 1.37 riastrad
322 1.55 mrg int pcie_capability_read_dword(struct pci_dev *, int, uint32_t *);
323 1.55 mrg int pcie_capability_read_word(struct pci_dev *, int, uint16_t *);
324 1.55 mrg int pcie_capability_write_dword(struct pci_dev *, int, uint32_t);
325 1.55 mrg int pcie_capability_write_word(struct pci_dev *, int, uint16_t);
326 1.55 mrg
327 1.37 riastrad int pci_bus_read_config_dword(struct pci_bus *, unsigned, int,
328 1.37 riastrad uint32_t *);
329 1.37 riastrad int pci_bus_read_config_word(struct pci_bus *, unsigned, int,
330 1.37 riastrad uint16_t *);
331 1.37 riastrad int pci_bus_read_config_byte(struct pci_bus *, unsigned, int,
332 1.37 riastrad uint8_t *);
333 1.37 riastrad int pci_bus_write_config_dword(struct pci_bus *, unsigned, int,
334 1.37 riastrad uint32_t);
335 1.37 riastrad int pci_bus_write_config_word(struct pci_bus *, unsigned, int,
336 1.37 riastrad uint16_t);
337 1.37 riastrad int pci_bus_write_config_byte(struct pci_bus *, unsigned, int,
338 1.37 riastrad uint8_t);
339 1.37 riastrad
340 1.37 riastrad int pci_enable_msi(struct pci_dev *);
341 1.37 riastrad void pci_disable_msi(struct pci_dev *);
342 1.37 riastrad void pci_set_master(struct pci_dev *);
343 1.37 riastrad void pci_clear_master(struct pci_dev *);
344 1.37 riastrad
345 1.55 mrg int pcie_get_readrq(struct pci_dev *);
346 1.55 mrg int pcie_set_readrq(struct pci_dev *, int);
347 1.55 mrg
348 1.37 riastrad bus_addr_t pcibios_align_resource(void *, const struct resource *,
349 1.37 riastrad bus_addr_t, bus_size_t);
350 1.37 riastrad int pci_bus_alloc_resource(struct pci_bus *, struct resource *,
351 1.37 riastrad bus_size_t, bus_size_t, bus_addr_t, int,
352 1.37 riastrad bus_addr_t (*)(void *, const struct resource *, bus_addr_t,
353 1.37 riastrad bus_size_t), struct pci_dev *);
354 1.37 riastrad
355 1.37 riastrad /* XXX Kludges only -- do not use without checking the implementation! */
356 1.41 riastrad struct pci_dev *pci_get_domain_bus_and_slot(int, int, int);
357 1.37 riastrad struct pci_dev *pci_get_class(uint32_t, struct pci_dev *); /* i915 kludge */
358 1.49 riastrad int pci_dev_present(const struct pci_device_id *);
359 1.37 riastrad void pci_dev_put(struct pci_dev *);
360 1.37 riastrad
361 1.37 riastrad void __pci_rom_iomem *
362 1.37 riastrad pci_map_rom(struct pci_dev *, size_t *);
363 1.37 riastrad void __pci_rom_iomem *
364 1.37 riastrad pci_platform_rom(struct pci_dev *, size_t *);
365 1.37 riastrad void pci_unmap_rom(struct pci_dev *, void __pci_rom_iomem *);
366 1.37 riastrad int pci_enable_rom(struct pci_dev *);
367 1.37 riastrad void pci_disable_rom(struct pci_dev *);
368 1.37 riastrad
369 1.56 riastrad int pci_request_regions(struct pci_dev *, const char *);
370 1.56 riastrad void pci_release_regions(struct pci_dev *);
371 1.56 riastrad int pci_request_region(struct pci_dev *, int, const char *);
372 1.56 riastrad void pci_release_region(struct pci_dev *, int);
373 1.56 riastrad
374 1.37 riastrad bus_addr_t pci_resource_start(struct pci_dev *, unsigned);
375 1.37 riastrad bus_size_t pci_resource_len(struct pci_dev *, unsigned);
376 1.37 riastrad bus_addr_t pci_resource_end(struct pci_dev *, unsigned);
377 1.37 riastrad int pci_resource_flags(struct pci_dev *, unsigned);
378 1.37 riastrad
379 1.37 riastrad void __pci_iomem *
380 1.37 riastrad pci_iomap(struct pci_dev *, unsigned, bus_size_t);
381 1.37 riastrad void pci_iounmap(struct pci_dev *, void __pci_iomem *);
382 1.2 riastrad
383 1.37 riastrad void pci_save_state(struct pci_dev *);
384 1.37 riastrad void pci_restore_state(struct pci_dev *);
385 1.48 riastrad
386 1.54 mrg enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *dev);
387 1.54 mrg unsigned pcie_bandwidth_available(struct pci_dev *dev,
388 1.54 mrg struct pci_dev **limiting_dev,
389 1.54 mrg enum pci_bus_speed *speed,
390 1.54 mrg enum pcie_link_width *width);
391 1.54 mrg
392 1.48 riastrad static inline bool
393 1.48 riastrad dev_is_pci(struct device *dev)
394 1.48 riastrad {
395 1.48 riastrad struct device *parent = device_parent(dev);
396 1.48 riastrad
397 1.48 riastrad return parent && device_is_a(parent, "pci");
398 1.48 riastrad }
399 1.34 riastrad
400 1.2 riastrad #endif /* _LINUX_PCI_H_ */
401