diff options
Diffstat (limited to 'include/linux/pci.h')
| -rw-r--r-- | include/linux/pci.h | 242 |
1 files changed, 215 insertions, 27 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 174e5392e51e..c8d95e369ff4 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -187,6 +187,33 @@ enum pci_bus_flags { | |||
| 187 | PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2, | 187 | PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2, |
| 188 | }; | 188 | }; |
| 189 | 189 | ||
| 190 | /* Based on the PCI Hotplug Spec, but some values are made up by us */ | ||
| 191 | enum pci_bus_speed { | ||
| 192 | PCI_SPEED_33MHz = 0x00, | ||
| 193 | PCI_SPEED_66MHz = 0x01, | ||
| 194 | PCI_SPEED_66MHz_PCIX = 0x02, | ||
| 195 | PCI_SPEED_100MHz_PCIX = 0x03, | ||
| 196 | PCI_SPEED_133MHz_PCIX = 0x04, | ||
| 197 | PCI_SPEED_66MHz_PCIX_ECC = 0x05, | ||
| 198 | PCI_SPEED_100MHz_PCIX_ECC = 0x06, | ||
| 199 | PCI_SPEED_133MHz_PCIX_ECC = 0x07, | ||
| 200 | PCI_SPEED_66MHz_PCIX_266 = 0x09, | ||
| 201 | PCI_SPEED_100MHz_PCIX_266 = 0x0a, | ||
| 202 | PCI_SPEED_133MHz_PCIX_266 = 0x0b, | ||
| 203 | AGP_UNKNOWN = 0x0c, | ||
| 204 | AGP_1X = 0x0d, | ||
| 205 | AGP_2X = 0x0e, | ||
| 206 | AGP_4X = 0x0f, | ||
| 207 | AGP_8X = 0x10, | ||
| 208 | PCI_SPEED_66MHz_PCIX_533 = 0x11, | ||
| 209 | PCI_SPEED_100MHz_PCIX_533 = 0x12, | ||
| 210 | PCI_SPEED_133MHz_PCIX_533 = 0x13, | ||
| 211 | PCIE_SPEED_2_5GT = 0x14, | ||
| 212 | PCIE_SPEED_5_0GT = 0x15, | ||
| 213 | PCIE_SPEED_8_0GT = 0x16, | ||
| 214 | PCI_SPEED_UNKNOWN = 0xff, | ||
| 215 | }; | ||
| 216 | |||
| 190 | struct pci_cap_saved_state { | 217 | struct pci_cap_saved_state { |
| 191 | struct hlist_node next; | 218 | struct hlist_node next; |
| 192 | char cap_nr; | 219 | char cap_nr; |
| @@ -239,9 +266,12 @@ struct pci_dev { | |||
| 239 | configuration space */ | 266 | configuration space */ |
| 240 | unsigned int pme_support:5; /* Bitmask of states from which PME# | 267 | unsigned int pme_support:5; /* Bitmask of states from which PME# |
| 241 | can be generated */ | 268 | can be generated */ |
| 269 | unsigned int pme_interrupt:1; | ||
| 242 | unsigned int d1_support:1; /* Low power state D1 is supported */ | 270 | unsigned int d1_support:1; /* Low power state D1 is supported */ |
| 243 | unsigned int d2_support:1; /* Low power state D2 is supported */ | 271 | unsigned int d2_support:1; /* Low power state D2 is supported */ |
| 244 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ | 272 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ |
| 273 | unsigned int mmio_always_on:1; /* disallow turning off io/mem | ||
| 274 | decoding during bar sizing */ | ||
| 245 | unsigned int wakeup_prepared:1; | 275 | unsigned int wakeup_prepared:1; |
| 246 | unsigned int d3_delay; /* D3->D0 transition time in ms */ | 276 | unsigned int d3_delay; /* D3->D0 transition time in ms */ |
| 247 | 277 | ||
| @@ -260,6 +290,7 @@ struct pci_dev { | |||
| 260 | */ | 290 | */ |
| 261 | unsigned int irq; | 291 | unsigned int irq; |
| 262 | struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ | 292 | struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ |
| 293 | resource_size_t fw_addr[DEVICE_COUNT_RESOURCE]; /* FW-assigned addr */ | ||
| 263 | 294 | ||
| 264 | /* These fields are used by common fixups */ | 295 | /* These fields are used by common fixups */ |
| 265 | unsigned int transparent:1; /* Transparent PCI bridge */ | 296 | unsigned int transparent:1; /* Transparent PCI bridge */ |
| @@ -275,14 +306,16 @@ struct pci_dev { | |||
| 275 | unsigned int msix_enabled:1; | 306 | unsigned int msix_enabled:1; |
| 276 | unsigned int ari_enabled:1; /* ARI forwarding */ | 307 | unsigned int ari_enabled:1; /* ARI forwarding */ |
| 277 | unsigned int is_managed:1; | 308 | unsigned int is_managed:1; |
| 278 | unsigned int is_pcie:1; | 309 | unsigned int is_pcie:1; /* Obsolete. Will be removed. |
| 310 | Use pci_is_pcie() instead */ | ||
| 279 | unsigned int needs_freset:1; /* Dev requires fundamental reset */ | 311 | unsigned int needs_freset:1; /* Dev requires fundamental reset */ |
| 280 | unsigned int state_saved:1; | 312 | unsigned int state_saved:1; |
| 281 | unsigned int is_physfn:1; | 313 | unsigned int is_physfn:1; |
| 282 | unsigned int is_virtfn:1; | 314 | unsigned int is_virtfn:1; |
| 283 | unsigned int reset_fn:1; | 315 | unsigned int reset_fn:1; |
| 284 | unsigned int is_hotplug_bridge:1; | 316 | unsigned int is_hotplug_bridge:1; |
| 285 | unsigned int aer_firmware_first:1; | 317 | unsigned int __aer_firmware_first_valid:1; |
| 318 | unsigned int __aer_firmware_first:1; | ||
| 286 | pci_dev_flags_t dev_flags; | 319 | pci_dev_flags_t dev_flags; |
| 287 | atomic_t enable_cnt; /* pci_enable_device has been called */ | 320 | atomic_t enable_cnt; /* pci_enable_device has been called */ |
| 288 | 321 | ||
| @@ -305,6 +338,16 @@ struct pci_dev { | |||
| 305 | #endif | 338 | #endif |
| 306 | }; | 339 | }; |
| 307 | 340 | ||
| 341 | static inline struct pci_dev *pci_physfn(struct pci_dev *dev) | ||
| 342 | { | ||
| 343 | #ifdef CONFIG_PCI_IOV | ||
| 344 | if (dev->is_virtfn) | ||
| 345 | dev = dev->physfn; | ||
| 346 | #endif | ||
| 347 | |||
| 348 | return dev; | ||
| 349 | } | ||
| 350 | |||
| 308 | extern struct pci_dev *alloc_pci_dev(void); | 351 | extern struct pci_dev *alloc_pci_dev(void); |
| 309 | 352 | ||
| 310 | #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) | 353 | #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) |
| @@ -335,9 +378,26 @@ static inline void pci_add_saved_cap(struct pci_dev *pci_dev, | |||
| 335 | hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); | 378 | hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); |
| 336 | } | 379 | } |
| 337 | 380 | ||
| 338 | #ifndef PCI_BUS_NUM_RESOURCES | 381 | /* |
| 339 | #define PCI_BUS_NUM_RESOURCES 16 | 382 | * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond |
| 340 | #endif | 383 | * to P2P or CardBus bridge windows) go in a table. Additional ones (for |
| 384 | * buses below host bridges or subtractive decode bridges) go in the list. | ||
| 385 | * Use pci_bus_for_each_resource() to iterate through all the resources. | ||
| 386 | */ | ||
| 387 | |||
| 388 | /* | ||
| 389 | * PCI_SUBTRACTIVE_DECODE means the bridge forwards the window implicitly | ||
| 390 | * and there's no way to program the bridge with the details of the window. | ||
| 391 | * This does not apply to ACPI _CRS windows, even with the _DEC subtractive- | ||
| 392 | * decode bit set, because they are explicit and can be programmed with _SRS. | ||
| 393 | */ | ||
| 394 | #define PCI_SUBTRACTIVE_DECODE 0x1 | ||
| 395 | |||
| 396 | struct pci_bus_resource { | ||
| 397 | struct list_head list; | ||
| 398 | struct resource *res; | ||
| 399 | unsigned int flags; | ||
| 400 | }; | ||
| 341 | 401 | ||
| 342 | #define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ | 402 | #define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ |
| 343 | 403 | ||
| @@ -348,8 +408,8 @@ struct pci_bus { | |||
| 348 | struct list_head devices; /* list of devices on this bus */ | 408 | struct list_head devices; /* list of devices on this bus */ |
| 349 | struct pci_dev *self; /* bridge device as seen by parent */ | 409 | struct pci_dev *self; /* bridge device as seen by parent */ |
| 350 | struct list_head slots; /* list of slots on this bus */ | 410 | struct list_head slots; /* list of slots on this bus */ |
| 351 | struct resource *resource[PCI_BUS_NUM_RESOURCES]; | 411 | struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; |
| 352 | /* address space routed to this bus */ | 412 | struct list_head resources; /* address space routed to this bus */ |
| 353 | 413 | ||
| 354 | struct pci_ops *ops; /* configuration access functions */ | 414 | struct pci_ops *ops; /* configuration access functions */ |
| 355 | void *sysdata; /* hook for sys-specific extension */ | 415 | void *sysdata; /* hook for sys-specific extension */ |
| @@ -359,6 +419,8 @@ struct pci_bus { | |||
| 359 | unsigned char primary; /* number of primary bridge */ | 419 | unsigned char primary; /* number of primary bridge */ |
| 360 | unsigned char secondary; /* number of secondary bridge */ | 420 | unsigned char secondary; /* number of secondary bridge */ |
| 361 | unsigned char subordinate; /* max number of subordinate buses */ | 421 | unsigned char subordinate; /* max number of subordinate buses */ |
| 422 | unsigned char max_bus_speed; /* enum pci_bus_speed */ | ||
| 423 | unsigned char cur_bus_speed; /* enum pci_bus_speed */ | ||
| 362 | 424 | ||
| 363 | char name[48]; | 425 | char name[48]; |
| 364 | 426 | ||
| @@ -563,7 +625,8 @@ int __must_check pcibios_enable_device(struct pci_dev *, int mask); | |||
| 563 | char *pcibios_setup(char *str); | 625 | char *pcibios_setup(char *str); |
| 564 | 626 | ||
| 565 | /* Used only when drivers/pci/setup.c is used */ | 627 | /* Used only when drivers/pci/setup.c is used */ |
| 566 | void pcibios_align_resource(void *, struct resource *, resource_size_t, | 628 | resource_size_t pcibios_align_resource(void *, const struct resource *, |
| 629 | resource_size_t, | ||
| 567 | resource_size_t); | 630 | resource_size_t); |
| 568 | void pcibios_update_irq(struct pci_dev *, int irq); | 631 | void pcibios_update_irq(struct pci_dev *, int irq); |
| 569 | 632 | ||
| @@ -572,6 +635,7 @@ void pci_fixup_cardbus(struct pci_bus *); | |||
| 572 | 635 | ||
| 573 | /* Generic PCI functions used internally */ | 636 | /* Generic PCI functions used internally */ |
| 574 | 637 | ||
| 638 | void pcibios_scan_specific_bus(int busn); | ||
| 575 | extern struct pci_bus *pci_find_bus(int domain, int busnr); | 639 | extern struct pci_bus *pci_find_bus(int domain, int busnr); |
| 576 | void pci_bus_add_devices(const struct pci_bus *bus); | 640 | void pci_bus_add_devices(const struct pci_bus *bus); |
| 577 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, | 641 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, |
| @@ -589,6 +653,7 @@ struct pci_bus *pci_create_bus(struct device *parent, int bus, | |||
| 589 | struct pci_ops *ops, void *sysdata); | 653 | struct pci_ops *ops, void *sysdata); |
| 590 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, | 654 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, |
| 591 | int busnr); | 655 | int busnr); |
| 656 | void pcie_update_link_speed(struct pci_bus *bus, u16 link_status); | ||
| 592 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, | 657 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, |
| 593 | const char *name, | 658 | const char *name, |
| 594 | struct hotplug_slot *hotplug); | 659 | struct hotplug_slot *hotplug); |
| @@ -612,15 +677,12 @@ extern void pci_remove_bus_device(struct pci_dev *dev); | |||
| 612 | extern void pci_stop_bus_device(struct pci_dev *dev); | 677 | extern void pci_stop_bus_device(struct pci_dev *dev); |
| 613 | void pci_setup_cardbus(struct pci_bus *bus); | 678 | void pci_setup_cardbus(struct pci_bus *bus); |
| 614 | extern void pci_sort_breadthfirst(void); | 679 | extern void pci_sort_breadthfirst(void); |
| 680 | #define dev_is_pci(d) ((d)->bus == &pci_bus_type) | ||
| 681 | #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false)) | ||
| 682 | #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0)) | ||
| 615 | 683 | ||
| 616 | /* Generic PCI functions exported to card drivers */ | 684 | /* Generic PCI functions exported to card drivers */ |
| 617 | 685 | ||
| 618 | #ifdef CONFIG_PCI_LEGACY | ||
| 619 | struct pci_dev __deprecated *pci_find_device(unsigned int vendor, | ||
| 620 | unsigned int device, | ||
| 621 | struct pci_dev *from); | ||
| 622 | #endif /* CONFIG_PCI_LEGACY */ | ||
| 623 | |||
| 624 | enum pci_lost_interrupt_reason { | 686 | enum pci_lost_interrupt_reason { |
| 625 | PCI_LOST_IRQ_NO_INFORMATION = 0, | 687 | PCI_LOST_IRQ_NO_INFORMATION = 0, |
| 626 | PCI_LOST_IRQ_DISABLE_MSI, | 688 | PCI_LOST_IRQ_DISABLE_MSI, |
| @@ -631,6 +693,8 @@ enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev); | |||
| 631 | int pci_find_capability(struct pci_dev *dev, int cap); | 693 | int pci_find_capability(struct pci_dev *dev, int cap); |
| 632 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); | 694 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); |
| 633 | int pci_find_ext_capability(struct pci_dev *dev, int cap); | 695 | int pci_find_ext_capability(struct pci_dev *dev, int cap); |
| 696 | int pci_bus_find_ext_capability(struct pci_bus *bus, unsigned int devfn, | ||
| 697 | int cap); | ||
| 634 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); | 698 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); |
| 635 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); | 699 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); |
| 636 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); | 700 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); |
| @@ -720,8 +784,6 @@ int pci_try_set_mwi(struct pci_dev *dev); | |||
| 720 | void pci_clear_mwi(struct pci_dev *dev); | 784 | void pci_clear_mwi(struct pci_dev *dev); |
| 721 | void pci_intx(struct pci_dev *dev, int enable); | 785 | void pci_intx(struct pci_dev *dev, int enable); |
| 722 | void pci_msi_off(struct pci_dev *dev); | 786 | void pci_msi_off(struct pci_dev *dev); |
| 723 | int pci_set_dma_mask(struct pci_dev *dev, u64 mask); | ||
| 724 | int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); | ||
| 725 | int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size); | 787 | int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size); |
| 726 | int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask); | 788 | int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask); |
| 727 | int pcix_get_max_mmrbc(struct pci_dev *dev); | 789 | int pcix_get_max_mmrbc(struct pci_dev *dev); |
| @@ -750,11 +812,23 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state); | |||
| 750 | pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); | 812 | pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); |
| 751 | bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); | 813 | bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); |
| 752 | void pci_pme_active(struct pci_dev *dev, bool enable); | 814 | void pci_pme_active(struct pci_dev *dev, bool enable); |
| 753 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable); | 815 | int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, |
| 816 | bool runtime, bool enable); | ||
| 754 | int pci_wake_from_d3(struct pci_dev *dev, bool enable); | 817 | int pci_wake_from_d3(struct pci_dev *dev, bool enable); |
| 755 | pci_power_t pci_target_state(struct pci_dev *dev); | 818 | pci_power_t pci_target_state(struct pci_dev *dev); |
| 756 | int pci_prepare_to_sleep(struct pci_dev *dev); | 819 | int pci_prepare_to_sleep(struct pci_dev *dev); |
| 757 | int pci_back_from_sleep(struct pci_dev *dev); | 820 | int pci_back_from_sleep(struct pci_dev *dev); |
| 821 | bool pci_dev_run_wake(struct pci_dev *dev); | ||
| 822 | |||
| 823 | static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, | ||
| 824 | bool enable) | ||
| 825 | { | ||
| 826 | return __pci_enable_wake(dev, state, false, enable); | ||
| 827 | } | ||
| 828 | |||
| 829 | /* For use by arch with custom probe code */ | ||
| 830 | void set_pcie_port_type(struct pci_dev *pdev); | ||
| 831 | void set_pcie_hotplug_bridge(struct pci_dev *pdev); | ||
| 758 | 832 | ||
| 759 | /* Functions for PCI Hotplug drivers to use */ | 833 | /* Functions for PCI Hotplug drivers to use */ |
| 760 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); | 834 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); |
| @@ -772,6 +846,7 @@ void pci_bus_assign_resources(const struct pci_bus *bus); | |||
| 772 | void pci_bus_size_bridges(struct pci_bus *bus); | 846 | void pci_bus_size_bridges(struct pci_bus *bus); |
| 773 | int pci_claim_resource(struct pci_dev *, int); | 847 | int pci_claim_resource(struct pci_dev *, int); |
| 774 | void pci_assign_unassigned_resources(void); | 848 | void pci_assign_unassigned_resources(void); |
| 849 | void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge); | ||
| 775 | void pdev_enable_device(struct pci_dev *); | 850 | void pdev_enable_device(struct pci_dev *); |
| 776 | void pdev_sort_resources(struct pci_dev *, struct resource_list *); | 851 | void pdev_sort_resources(struct pci_dev *, struct resource_list *); |
| 777 | int pci_enable_resources(struct pci_dev *, int mask); | 852 | int pci_enable_resources(struct pci_dev *, int mask); |
| @@ -789,12 +864,23 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *); | |||
| 789 | void pci_release_selected_regions(struct pci_dev *, int); | 864 | void pci_release_selected_regions(struct pci_dev *, int); |
| 790 | 865 | ||
| 791 | /* drivers/pci/bus.c */ | 866 | /* drivers/pci/bus.c */ |
| 867 | void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags); | ||
| 868 | struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n); | ||
| 869 | void pci_bus_remove_resources(struct pci_bus *bus); | ||
| 870 | |||
| 871 | #define pci_bus_for_each_resource(bus, res, i) \ | ||
| 872 | for (i = 0; \ | ||
| 873 | (res = pci_bus_resource_n(bus, i)) || i < PCI_BRIDGE_RESOURCE_NUM; \ | ||
| 874 | i++) | ||
| 875 | |||
| 792 | int __must_check pci_bus_alloc_resource(struct pci_bus *bus, | 876 | int __must_check pci_bus_alloc_resource(struct pci_bus *bus, |
| 793 | struct resource *res, resource_size_t size, | 877 | struct resource *res, resource_size_t size, |
| 794 | resource_size_t align, resource_size_t min, | 878 | resource_size_t align, resource_size_t min, |
| 795 | unsigned int type_mask, | 879 | unsigned int type_mask, |
| 796 | void (*alignf)(void *, struct resource *, | 880 | resource_size_t (*alignf)(void *, |
| 797 | resource_size_t, resource_size_t), | 881 | const struct resource *, |
| 882 | resource_size_t, | ||
| 883 | resource_size_t), | ||
| 798 | void *alignf_data); | 884 | void *alignf_data); |
| 799 | void pci_enable_bridges(struct pci_bus *bus); | 885 | void pci_enable_bridges(struct pci_bus *bus); |
| 800 | 886 | ||
| @@ -831,6 +917,7 @@ int pci_set_vga_state(struct pci_dev *pdev, bool decode, | |||
| 831 | unsigned int command_bits, bool change_bridge); | 917 | unsigned int command_bits, bool change_bridge); |
| 832 | /* kmem_cache style wrapper around pci_alloc_consistent() */ | 918 | /* kmem_cache style wrapper around pci_alloc_consistent() */ |
| 833 | 919 | ||
| 920 | #include <linux/pci-dma.h> | ||
| 834 | #include <linux/dmapool.h> | 921 | #include <linux/dmapool.h> |
| 835 | 922 | ||
| 836 | #define pci_pool dma_pool | 923 | #define pci_pool dma_pool |
| @@ -955,6 +1042,11 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
| 955 | } | 1042 | } |
| 956 | #endif /* CONFIG_PCI_DOMAINS */ | 1043 | #endif /* CONFIG_PCI_DOMAINS */ |
| 957 | 1044 | ||
| 1045 | /* some architectures require additional setup to direct VGA traffic */ | ||
| 1046 | typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, | ||
| 1047 | unsigned int command_bits, bool change_bridge); | ||
| 1048 | extern void pci_register_set_vga_state(arch_set_vga_state_t func); | ||
| 1049 | |||
| 958 | #else /* CONFIG_PCI is not enabled */ | 1050 | #else /* CONFIG_PCI is not enabled */ |
| 959 | 1051 | ||
| 960 | /* | 1052 | /* |
| @@ -973,13 +1065,6 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
| 973 | _PCI_NOP_ALL(read, *) | 1065 | _PCI_NOP_ALL(read, *) |
| 974 | _PCI_NOP_ALL(write,) | 1066 | _PCI_NOP_ALL(write,) |
| 975 | 1067 | ||
| 976 | static inline struct pci_dev *pci_find_device(unsigned int vendor, | ||
| 977 | unsigned int device, | ||
| 978 | struct pci_dev *from) | ||
| 979 | { | ||
| 980 | return NULL; | ||
| 981 | } | ||
| 982 | |||
| 983 | static inline struct pci_dev *pci_get_device(unsigned int vendor, | 1068 | static inline struct pci_dev *pci_get_device(unsigned int vendor, |
| 984 | unsigned int device, | 1069 | unsigned int device, |
| 985 | struct pci_dev *from) | 1070 | struct pci_dev *from) |
| @@ -1129,6 +1214,12 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, | |||
| 1129 | unsigned int devfn) | 1214 | unsigned int devfn) |
| 1130 | { return NULL; } | 1215 | { return NULL; } |
| 1131 | 1216 | ||
| 1217 | static inline int pci_domain_nr(struct pci_bus *bus) | ||
| 1218 | { return 0; } | ||
| 1219 | |||
| 1220 | #define dev_is_pci(d) (false) | ||
| 1221 | #define dev_is_pf(d) (false) | ||
| 1222 | #define dev_num_vf(d) (0) | ||
| 1132 | #endif /* CONFIG_PCI */ | 1223 | #endif /* CONFIG_PCI */ |
| 1133 | 1224 | ||
| 1134 | /* Include architecture-dependent settings and functions */ | 1225 | /* Include architecture-dependent settings and functions */ |
| @@ -1237,8 +1328,12 @@ enum pci_fixup_pass { | |||
| 1237 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ | 1328 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ |
| 1238 | suspend##vendor##device##hook, vendor, device, hook) | 1329 | suspend##vendor##device##hook, vendor, device, hook) |
| 1239 | 1330 | ||
| 1240 | 1331 | #ifdef CONFIG_PCI_QUIRKS | |
| 1241 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); | 1332 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); |
| 1333 | #else | ||
| 1334 | static inline void pci_fixup_device(enum pci_fixup_pass pass, | ||
| 1335 | struct pci_dev *dev) {} | ||
| 1336 | #endif | ||
| 1242 | 1337 | ||
| 1243 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); | 1338 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); |
| 1244 | void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); | 1339 | void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); |
| @@ -1286,6 +1381,7 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); | |||
| 1286 | extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); | 1381 | extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); |
| 1287 | extern void pci_disable_sriov(struct pci_dev *dev); | 1382 | extern void pci_disable_sriov(struct pci_dev *dev); |
| 1288 | extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); | 1383 | extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); |
| 1384 | extern int pci_num_vf(struct pci_dev *dev); | ||
| 1289 | #else | 1385 | #else |
| 1290 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) | 1386 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) |
| 1291 | { | 1387 | { |
| @@ -1298,6 +1394,10 @@ static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev) | |||
| 1298 | { | 1394 | { |
| 1299 | return IRQ_NONE; | 1395 | return IRQ_NONE; |
| 1300 | } | 1396 | } |
| 1397 | static inline int pci_num_vf(struct pci_dev *dev) | ||
| 1398 | { | ||
| 1399 | return 0; | ||
| 1400 | } | ||
| 1301 | #endif | 1401 | #endif |
| 1302 | 1402 | ||
| 1303 | #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) | 1403 | #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) |
| @@ -1334,5 +1434,93 @@ static inline bool pci_is_pcie(struct pci_dev *dev) | |||
| 1334 | 1434 | ||
| 1335 | void pci_request_acs(void); | 1435 | void pci_request_acs(void); |
| 1336 | 1436 | ||
| 1437 | |||
| 1438 | #define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */ | ||
| 1439 | #define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT) | ||
| 1440 | |||
| 1441 | /* Large Resource Data Type Tag Item Names */ | ||
| 1442 | #define PCI_VPD_LTIN_ID_STRING 0x02 /* Identifier String */ | ||
| 1443 | #define PCI_VPD_LTIN_RO_DATA 0x10 /* Read-Only Data */ | ||
| 1444 | #define PCI_VPD_LTIN_RW_DATA 0x11 /* Read-Write Data */ | ||
| 1445 | |||
| 1446 | #define PCI_VPD_LRDT_ID_STRING PCI_VPD_LRDT_ID(PCI_VPD_LTIN_ID_STRING) | ||
| 1447 | #define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA) | ||
| 1448 | #define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA) | ||
| 1449 | |||
| 1450 | /* Small Resource Data Type Tag Item Names */ | ||
| 1451 | #define PCI_VPD_STIN_END 0x78 /* End */ | ||
| 1452 | |||
| 1453 | #define PCI_VPD_SRDT_END PCI_VPD_STIN_END | ||
| 1454 | |||
| 1455 | #define PCI_VPD_SRDT_TIN_MASK 0x78 | ||
| 1456 | #define PCI_VPD_SRDT_LEN_MASK 0x07 | ||
| 1457 | |||
| 1458 | #define PCI_VPD_LRDT_TAG_SIZE 3 | ||
| 1459 | #define PCI_VPD_SRDT_TAG_SIZE 1 | ||
| 1460 | |||
| 1461 | #define PCI_VPD_INFO_FLD_HDR_SIZE 3 | ||
| 1462 | |||
| 1463 | #define PCI_VPD_RO_KEYWORD_PARTNO "PN" | ||
| 1464 | #define PCI_VPD_RO_KEYWORD_MFR_ID "MN" | ||
| 1465 | #define PCI_VPD_RO_KEYWORD_VENDOR0 "V0" | ||
| 1466 | |||
| 1467 | /** | ||
| 1468 | * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length | ||
| 1469 | * @lrdt: Pointer to the beginning of the Large Resource Data Type tag | ||
| 1470 | * | ||
| 1471 | * Returns the extracted Large Resource Data Type length. | ||
| 1472 | */ | ||
| 1473 | static inline u16 pci_vpd_lrdt_size(const u8 *lrdt) | ||
| 1474 | { | ||
| 1475 | return (u16)lrdt[1] + ((u16)lrdt[2] << 8); | ||
| 1476 | } | ||
| 1477 | |||
| 1478 | /** | ||
| 1479 | * pci_vpd_srdt_size - Extracts the Small Resource Data Type length | ||
| 1480 | * @lrdt: Pointer to the beginning of the Small Resource Data Type tag | ||
| 1481 | * | ||
| 1482 | * Returns the extracted Small Resource Data Type length. | ||
| 1483 | */ | ||
| 1484 | static inline u8 pci_vpd_srdt_size(const u8 *srdt) | ||
| 1485 | { | ||
| 1486 | return (*srdt) & PCI_VPD_SRDT_LEN_MASK; | ||
| 1487 | } | ||
| 1488 | |||
| 1489 | /** | ||
| 1490 | * pci_vpd_info_field_size - Extracts the information field length | ||
| 1491 | * @lrdt: Pointer to the beginning of an information field header | ||
| 1492 | * | ||
| 1493 | * Returns the extracted information field length. | ||
| 1494 | */ | ||
| 1495 | static inline u8 pci_vpd_info_field_size(const u8 *info_field) | ||
| 1496 | { | ||
| 1497 | return info_field[2]; | ||
| 1498 | } | ||
| 1499 | |||
| 1500 | /** | ||
| 1501 | * pci_vpd_find_tag - Locates the Resource Data Type tag provided | ||
| 1502 | * @buf: Pointer to buffered vpd data | ||
| 1503 | * @off: The offset into the buffer at which to begin the search | ||
| 1504 | * @len: The length of the vpd buffer | ||
| 1505 | * @rdt: The Resource Data Type to search for | ||
| 1506 | * | ||
| 1507 | * Returns the index where the Resource Data Type was found or | ||
| 1508 | * -ENOENT otherwise. | ||
| 1509 | */ | ||
| 1510 | int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt); | ||
| 1511 | |||
| 1512 | /** | ||
| 1513 | * pci_vpd_find_info_keyword - Locates an information field keyword in the VPD | ||
| 1514 | * @buf: Pointer to buffered vpd data | ||
| 1515 | * @off: The offset into the buffer at which to begin the search | ||
| 1516 | * @len: The length of the buffer area, relative to off, in which to search | ||
| 1517 | * @kw: The keyword to search for | ||
| 1518 | * | ||
| 1519 | * Returns the index where the information field keyword was found or | ||
| 1520 | * -ENOENT otherwise. | ||
| 1521 | */ | ||
| 1522 | int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, | ||
| 1523 | unsigned int len, const char *kw); | ||
| 1524 | |||
| 1337 | #endif /* __KERNEL__ */ | 1525 | #endif /* __KERNEL__ */ |
| 1338 | #endif /* LINUX_PCI_H */ | 1526 | #endif /* LINUX_PCI_H */ |
