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