diff options
Diffstat (limited to 'include/linux/pci.h')
| -rw-r--r-- | include/linux/pci.h | 268 |
1 files changed, 241 insertions, 27 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index f5c7cd343e56..a788fa12ff31 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; |
| @@ -218,6 +245,7 @@ struct pci_dev { | |||
| 218 | unsigned int class; /* 3 bytes: (base,sub,prog-if) */ | 245 | unsigned int class; /* 3 bytes: (base,sub,prog-if) */ |
| 219 | u8 revision; /* PCI revision, low byte of class word */ | 246 | u8 revision; /* PCI revision, low byte of class word */ |
| 220 | u8 hdr_type; /* PCI header type (`multi' flag masked out) */ | 247 | u8 hdr_type; /* PCI header type (`multi' flag masked out) */ |
| 248 | u8 pcie_cap; /* PCI-E capability offset */ | ||
| 221 | u8 pcie_type; /* PCI-E device/port type */ | 249 | u8 pcie_type; /* PCI-E device/port type */ |
| 222 | u8 rom_base_reg; /* which config register controls the ROM */ | 250 | u8 rom_base_reg; /* which config register controls the ROM */ |
| 223 | u8 pin; /* which interrupt pin this device uses */ | 251 | u8 pin; /* which interrupt pin this device uses */ |
| @@ -238,10 +266,12 @@ struct pci_dev { | |||
| 238 | configuration space */ | 266 | configuration space */ |
| 239 | unsigned int pme_support:5; /* Bitmask of states from which PME# | 267 | unsigned int pme_support:5; /* Bitmask of states from which PME# |
| 240 | can be generated */ | 268 | can be generated */ |
| 269 | unsigned int pme_interrupt:1; | ||
| 241 | unsigned int d1_support:1; /* Low power state D1 is supported */ | 270 | unsigned int d1_support:1; /* Low power state D1 is supported */ |
| 242 | unsigned int d2_support:1; /* Low power state D2 is supported */ | 271 | unsigned int d2_support:1; /* Low power state D2 is supported */ |
| 243 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ | 272 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ |
| 244 | unsigned int wakeup_prepared:1; | 273 | unsigned int wakeup_prepared:1; |
| 274 | unsigned int d3_delay; /* D3->D0 transition time in ms */ | ||
| 245 | 275 | ||
| 246 | #ifdef CONFIG_PCIEASPM | 276 | #ifdef CONFIG_PCIEASPM |
| 247 | struct pcie_link_state *link_state; /* ASPM link state. */ | 277 | struct pcie_link_state *link_state; /* ASPM link state. */ |
| @@ -273,13 +303,15 @@ struct pci_dev { | |||
| 273 | unsigned int msix_enabled:1; | 303 | unsigned int msix_enabled:1; |
| 274 | unsigned int ari_enabled:1; /* ARI forwarding */ | 304 | unsigned int ari_enabled:1; /* ARI forwarding */ |
| 275 | unsigned int is_managed:1; | 305 | unsigned int is_managed:1; |
| 276 | unsigned int is_pcie:1; | 306 | unsigned int is_pcie:1; /* Obsolete. Will be removed. |
| 307 | Use pci_is_pcie() instead */ | ||
| 277 | unsigned int needs_freset:1; /* Dev requires fundamental reset */ | 308 | unsigned int needs_freset:1; /* Dev requires fundamental reset */ |
| 278 | unsigned int state_saved:1; | 309 | unsigned int state_saved:1; |
| 279 | unsigned int is_physfn:1; | 310 | unsigned int is_physfn:1; |
| 280 | unsigned int is_virtfn:1; | 311 | unsigned int is_virtfn:1; |
| 281 | unsigned int reset_fn:1; | 312 | unsigned int reset_fn:1; |
| 282 | unsigned int is_hotplug_bridge:1; | 313 | unsigned int is_hotplug_bridge:1; |
| 314 | unsigned int aer_firmware_first:1; | ||
| 283 | pci_dev_flags_t dev_flags; | 315 | pci_dev_flags_t dev_flags; |
| 284 | atomic_t enable_cnt; /* pci_enable_device has been called */ | 316 | atomic_t enable_cnt; /* pci_enable_device has been called */ |
| 285 | 317 | ||
| @@ -332,9 +364,26 @@ static inline void pci_add_saved_cap(struct pci_dev *pci_dev, | |||
| 332 | hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); | 364 | hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); |
| 333 | } | 365 | } |
| 334 | 366 | ||
| 335 | #ifndef PCI_BUS_NUM_RESOURCES | 367 | /* |
| 336 | #define PCI_BUS_NUM_RESOURCES 16 | 368 | * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond |
| 337 | #endif | 369 | * to P2P or CardBus bridge windows) go in a table. Additional ones (for |
| 370 | * buses below host bridges or subtractive decode bridges) go in the list. | ||
| 371 | * Use pci_bus_for_each_resource() to iterate through all the resources. | ||
| 372 | */ | ||
| 373 | |||
| 374 | /* | ||
| 375 | * PCI_SUBTRACTIVE_DECODE means the bridge forwards the window implicitly | ||
| 376 | * and there's no way to program the bridge with the details of the window. | ||
| 377 | * This does not apply to ACPI _CRS windows, even with the _DEC subtractive- | ||
| 378 | * decode bit set, because they are explicit and can be programmed with _SRS. | ||
| 379 | */ | ||
| 380 | #define PCI_SUBTRACTIVE_DECODE 0x1 | ||
| 381 | |||
| 382 | struct pci_bus_resource { | ||
| 383 | struct list_head list; | ||
| 384 | struct resource *res; | ||
| 385 | unsigned int flags; | ||
| 386 | }; | ||
| 338 | 387 | ||
| 339 | #define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ | 388 | #define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ |
| 340 | 389 | ||
| @@ -345,8 +394,8 @@ struct pci_bus { | |||
| 345 | struct list_head devices; /* list of devices on this bus */ | 394 | struct list_head devices; /* list of devices on this bus */ |
| 346 | struct pci_dev *self; /* bridge device as seen by parent */ | 395 | struct pci_dev *self; /* bridge device as seen by parent */ |
| 347 | struct list_head slots; /* list of slots on this bus */ | 396 | struct list_head slots; /* list of slots on this bus */ |
| 348 | struct resource *resource[PCI_BUS_NUM_RESOURCES]; | 397 | struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; |
| 349 | /* address space routed to this bus */ | 398 | struct list_head resources; /* address space routed to this bus */ |
| 350 | 399 | ||
| 351 | struct pci_ops *ops; /* configuration access functions */ | 400 | struct pci_ops *ops; /* configuration access functions */ |
| 352 | void *sysdata; /* hook for sys-specific extension */ | 401 | void *sysdata; /* hook for sys-specific extension */ |
| @@ -356,6 +405,8 @@ struct pci_bus { | |||
| 356 | unsigned char primary; /* number of primary bridge */ | 405 | unsigned char primary; /* number of primary bridge */ |
| 357 | unsigned char secondary; /* number of secondary bridge */ | 406 | unsigned char secondary; /* number of secondary bridge */ |
| 358 | unsigned char subordinate; /* max number of subordinate buses */ | 407 | unsigned char subordinate; /* max number of subordinate buses */ |
| 408 | unsigned char max_bus_speed; /* enum pci_bus_speed */ | ||
| 409 | unsigned char cur_bus_speed; /* enum pci_bus_speed */ | ||
| 359 | 410 | ||
| 360 | char name[48]; | 411 | char name[48]; |
| 361 | 412 | ||
| @@ -560,10 +611,14 @@ int __must_check pcibios_enable_device(struct pci_dev *, int mask); | |||
| 560 | char *pcibios_setup(char *str); | 611 | char *pcibios_setup(char *str); |
| 561 | 612 | ||
| 562 | /* Used only when drivers/pci/setup.c is used */ | 613 | /* Used only when drivers/pci/setup.c is used */ |
| 563 | void pcibios_align_resource(void *, struct resource *, resource_size_t, | 614 | resource_size_t pcibios_align_resource(void *, const struct resource *, |
| 615 | resource_size_t, | ||
| 564 | resource_size_t); | 616 | resource_size_t); |
| 565 | void pcibios_update_irq(struct pci_dev *, int irq); | 617 | void pcibios_update_irq(struct pci_dev *, int irq); |
| 566 | 618 | ||
| 619 | /* Weak but can be overriden by arch */ | ||
| 620 | void pci_fixup_cardbus(struct pci_bus *); | ||
| 621 | |||
| 567 | /* Generic PCI functions used internally */ | 622 | /* Generic PCI functions used internally */ |
| 568 | 623 | ||
| 569 | extern struct pci_bus *pci_find_bus(int domain, int busnr); | 624 | extern struct pci_bus *pci_find_bus(int domain, int busnr); |
| @@ -583,6 +638,7 @@ struct pci_bus *pci_create_bus(struct device *parent, int bus, | |||
| 583 | struct pci_ops *ops, void *sysdata); | 638 | struct pci_ops *ops, void *sysdata); |
| 584 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, | 639 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, |
| 585 | int busnr); | 640 | int busnr); |
| 641 | void pcie_update_link_speed(struct pci_bus *bus, u16 link_status); | ||
| 586 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, | 642 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, |
| 587 | const char *name, | 643 | const char *name, |
| 588 | struct hotplug_slot *hotplug); | 644 | struct hotplug_slot *hotplug); |
| @@ -606,15 +662,12 @@ extern void pci_remove_bus_device(struct pci_dev *dev); | |||
| 606 | extern void pci_stop_bus_device(struct pci_dev *dev); | 662 | extern void pci_stop_bus_device(struct pci_dev *dev); |
| 607 | void pci_setup_cardbus(struct pci_bus *bus); | 663 | void pci_setup_cardbus(struct pci_bus *bus); |
| 608 | extern void pci_sort_breadthfirst(void); | 664 | extern void pci_sort_breadthfirst(void); |
| 665 | #define dev_is_pci(d) ((d)->bus == &pci_bus_type) | ||
| 666 | #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false)) | ||
| 667 | #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0)) | ||
| 609 | 668 | ||
| 610 | /* Generic PCI functions exported to card drivers */ | 669 | /* Generic PCI functions exported to card drivers */ |
| 611 | 670 | ||
| 612 | #ifdef CONFIG_PCI_LEGACY | ||
| 613 | struct pci_dev __deprecated *pci_find_device(unsigned int vendor, | ||
| 614 | unsigned int device, | ||
| 615 | struct pci_dev *from); | ||
| 616 | #endif /* CONFIG_PCI_LEGACY */ | ||
| 617 | |||
| 618 | enum pci_lost_interrupt_reason { | 671 | enum pci_lost_interrupt_reason { |
| 619 | PCI_LOST_IRQ_NO_INFORMATION = 0, | 672 | PCI_LOST_IRQ_NO_INFORMATION = 0, |
| 620 | PCI_LOST_IRQ_DISABLE_MSI, | 673 | PCI_LOST_IRQ_DISABLE_MSI, |
| @@ -625,6 +678,8 @@ enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev); | |||
| 625 | int pci_find_capability(struct pci_dev *dev, int cap); | 678 | int pci_find_capability(struct pci_dev *dev, int cap); |
| 626 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); | 679 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); |
| 627 | int pci_find_ext_capability(struct pci_dev *dev, int cap); | 680 | int pci_find_ext_capability(struct pci_dev *dev, int cap); |
| 681 | int pci_bus_find_ext_capability(struct pci_bus *bus, unsigned int devfn, | ||
| 682 | int cap); | ||
| 628 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); | 683 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); |
| 629 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); | 684 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); |
| 630 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); | 685 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); |
| @@ -635,7 +690,13 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, | |||
| 635 | unsigned int ss_vendor, unsigned int ss_device, | 690 | unsigned int ss_vendor, unsigned int ss_device, |
| 636 | struct pci_dev *from); | 691 | struct pci_dev *from); |
| 637 | struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn); | 692 | struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn); |
| 638 | struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn); | 693 | struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus, |
| 694 | unsigned int devfn); | ||
| 695 | static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, | ||
| 696 | unsigned int devfn) | ||
| 697 | { | ||
| 698 | return pci_get_domain_bus_and_slot(0, bus, devfn); | ||
| 699 | } | ||
| 639 | struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from); | 700 | struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from); |
| 640 | int pci_dev_present(const struct pci_device_id *ids); | 701 | int pci_dev_present(const struct pci_device_id *ids); |
| 641 | 702 | ||
| @@ -701,14 +762,13 @@ void pci_disable_device(struct pci_dev *dev); | |||
| 701 | void pci_set_master(struct pci_dev *dev); | 762 | void pci_set_master(struct pci_dev *dev); |
| 702 | void pci_clear_master(struct pci_dev *dev); | 763 | void pci_clear_master(struct pci_dev *dev); |
| 703 | int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); | 764 | int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); |
| 765 | int pci_set_cacheline_size(struct pci_dev *dev); | ||
| 704 | #define HAVE_PCI_SET_MWI | 766 | #define HAVE_PCI_SET_MWI |
| 705 | int __must_check pci_set_mwi(struct pci_dev *dev); | 767 | int __must_check pci_set_mwi(struct pci_dev *dev); |
| 706 | int pci_try_set_mwi(struct pci_dev *dev); | 768 | int pci_try_set_mwi(struct pci_dev *dev); |
| 707 | void pci_clear_mwi(struct pci_dev *dev); | 769 | void pci_clear_mwi(struct pci_dev *dev); |
| 708 | void pci_intx(struct pci_dev *dev, int enable); | 770 | void pci_intx(struct pci_dev *dev, int enable); |
| 709 | void pci_msi_off(struct pci_dev *dev); | 771 | void pci_msi_off(struct pci_dev *dev); |
| 710 | int pci_set_dma_mask(struct pci_dev *dev, u64 mask); | ||
| 711 | int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); | ||
| 712 | int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size); | 772 | int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size); |
| 713 | int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask); | 773 | int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask); |
| 714 | int pcix_get_max_mmrbc(struct pci_dev *dev); | 774 | int pcix_get_max_mmrbc(struct pci_dev *dev); |
| @@ -737,11 +797,23 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state); | |||
| 737 | pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); | 797 | pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); |
| 738 | bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); | 798 | bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); |
| 739 | void pci_pme_active(struct pci_dev *dev, bool enable); | 799 | void pci_pme_active(struct pci_dev *dev, bool enable); |
| 740 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable); | 800 | int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, |
| 801 | bool runtime, bool enable); | ||
| 741 | int pci_wake_from_d3(struct pci_dev *dev, bool enable); | 802 | int pci_wake_from_d3(struct pci_dev *dev, bool enable); |
| 742 | pci_power_t pci_target_state(struct pci_dev *dev); | 803 | pci_power_t pci_target_state(struct pci_dev *dev); |
| 743 | int pci_prepare_to_sleep(struct pci_dev *dev); | 804 | int pci_prepare_to_sleep(struct pci_dev *dev); |
| 744 | int pci_back_from_sleep(struct pci_dev *dev); | 805 | int pci_back_from_sleep(struct pci_dev *dev); |
| 806 | bool pci_dev_run_wake(struct pci_dev *dev); | ||
| 807 | |||
| 808 | static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, | ||
| 809 | bool enable) | ||
| 810 | { | ||
| 811 | return __pci_enable_wake(dev, state, false, enable); | ||
| 812 | } | ||
| 813 | |||
| 814 | /* For use by arch with custom probe code */ | ||
| 815 | void set_pcie_port_type(struct pci_dev *pdev); | ||
| 816 | void set_pcie_hotplug_bridge(struct pci_dev *pdev); | ||
| 745 | 817 | ||
| 746 | /* Functions for PCI Hotplug drivers to use */ | 818 | /* Functions for PCI Hotplug drivers to use */ |
| 747 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); | 819 | int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); |
| @@ -759,6 +831,7 @@ void pci_bus_assign_resources(const struct pci_bus *bus); | |||
| 759 | void pci_bus_size_bridges(struct pci_bus *bus); | 831 | void pci_bus_size_bridges(struct pci_bus *bus); |
| 760 | int pci_claim_resource(struct pci_dev *, int); | 832 | int pci_claim_resource(struct pci_dev *, int); |
| 761 | void pci_assign_unassigned_resources(void); | 833 | void pci_assign_unassigned_resources(void); |
| 834 | void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge); | ||
| 762 | void pdev_enable_device(struct pci_dev *); | 835 | void pdev_enable_device(struct pci_dev *); |
| 763 | void pdev_sort_resources(struct pci_dev *, struct resource_list *); | 836 | void pdev_sort_resources(struct pci_dev *, struct resource_list *); |
| 764 | int pci_enable_resources(struct pci_dev *, int mask); | 837 | int pci_enable_resources(struct pci_dev *, int mask); |
| @@ -776,12 +849,23 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *); | |||
| 776 | void pci_release_selected_regions(struct pci_dev *, int); | 849 | void pci_release_selected_regions(struct pci_dev *, int); |
| 777 | 850 | ||
| 778 | /* drivers/pci/bus.c */ | 851 | /* drivers/pci/bus.c */ |
| 852 | void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags); | ||
| 853 | struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n); | ||
| 854 | void pci_bus_remove_resources(struct pci_bus *bus); | ||
| 855 | |||
| 856 | #define pci_bus_for_each_resource(bus, res, i) \ | ||
| 857 | for (i = 0; \ | ||
| 858 | (res = pci_bus_resource_n(bus, i)) || i < PCI_BRIDGE_RESOURCE_NUM; \ | ||
| 859 | i++) | ||
| 860 | |||
| 779 | int __must_check pci_bus_alloc_resource(struct pci_bus *bus, | 861 | int __must_check pci_bus_alloc_resource(struct pci_bus *bus, |
| 780 | struct resource *res, resource_size_t size, | 862 | struct resource *res, resource_size_t size, |
| 781 | resource_size_t align, resource_size_t min, | 863 | resource_size_t align, resource_size_t min, |
| 782 | unsigned int type_mask, | 864 | unsigned int type_mask, |
| 783 | void (*alignf)(void *, struct resource *, | 865 | resource_size_t (*alignf)(void *, |
| 784 | resource_size_t, resource_size_t), | 866 | const struct resource *, |
| 867 | resource_size_t, | ||
| 868 | resource_size_t), | ||
| 785 | void *alignf_data); | 869 | void *alignf_data); |
| 786 | void pci_enable_bridges(struct pci_bus *bus); | 870 | void pci_enable_bridges(struct pci_bus *bus); |
| 787 | 871 | ||
| @@ -818,6 +902,7 @@ int pci_set_vga_state(struct pci_dev *pdev, bool decode, | |||
| 818 | unsigned int command_bits, bool change_bridge); | 902 | unsigned int command_bits, bool change_bridge); |
| 819 | /* kmem_cache style wrapper around pci_alloc_consistent() */ | 903 | /* kmem_cache style wrapper around pci_alloc_consistent() */ |
| 820 | 904 | ||
| 905 | #include <linux/pci-dma.h> | ||
| 821 | #include <linux/dmapool.h> | 906 | #include <linux/dmapool.h> |
| 822 | 907 | ||
| 823 | #define pci_pool dma_pool | 908 | #define pci_pool dma_pool |
| @@ -942,6 +1027,11 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
| 942 | } | 1027 | } |
| 943 | #endif /* CONFIG_PCI_DOMAINS */ | 1028 | #endif /* CONFIG_PCI_DOMAINS */ |
| 944 | 1029 | ||
| 1030 | /* some architectures require additional setup to direct VGA traffic */ | ||
| 1031 | typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, | ||
| 1032 | unsigned int command_bits, bool change_bridge); | ||
| 1033 | extern void pci_register_set_vga_state(arch_set_vga_state_t func); | ||
| 1034 | |||
| 945 | #else /* CONFIG_PCI is not enabled */ | 1035 | #else /* CONFIG_PCI is not enabled */ |
| 946 | 1036 | ||
| 947 | /* | 1037 | /* |
| @@ -960,13 +1050,6 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
| 960 | _PCI_NOP_ALL(read, *) | 1050 | _PCI_NOP_ALL(read, *) |
| 961 | _PCI_NOP_ALL(write,) | 1051 | _PCI_NOP_ALL(write,) |
| 962 | 1052 | ||
| 963 | static inline struct pci_dev *pci_find_device(unsigned int vendor, | ||
| 964 | unsigned int device, | ||
| 965 | struct pci_dev *from) | ||
| 966 | { | ||
| 967 | return NULL; | ||
| 968 | } | ||
| 969 | |||
| 970 | static inline struct pci_dev *pci_get_device(unsigned int vendor, | 1053 | static inline struct pci_dev *pci_get_device(unsigned int vendor, |
| 971 | unsigned int device, | 1054 | unsigned int device, |
| 972 | struct pci_dev *from) | 1055 | struct pci_dev *from) |
| @@ -1116,6 +1199,9 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, | |||
| 1116 | unsigned int devfn) | 1199 | unsigned int devfn) |
| 1117 | { return NULL; } | 1200 | { return NULL; } |
| 1118 | 1201 | ||
| 1202 | #define dev_is_pci(d) (false) | ||
| 1203 | #define dev_is_pf(d) (false) | ||
| 1204 | #define dev_num_vf(d) (0) | ||
| 1119 | #endif /* CONFIG_PCI */ | 1205 | #endif /* CONFIG_PCI */ |
| 1120 | 1206 | ||
| 1121 | /* Include architecture-dependent settings and functions */ | 1207 | /* Include architecture-dependent settings and functions */ |
| @@ -1224,8 +1310,12 @@ enum pci_fixup_pass { | |||
| 1224 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ | 1310 | DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ |
| 1225 | suspend##vendor##device##hook, vendor, device, hook) | 1311 | suspend##vendor##device##hook, vendor, device, hook) |
| 1226 | 1312 | ||
| 1227 | 1313 | #ifdef CONFIG_PCI_QUIRKS | |
| 1228 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); | 1314 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); |
| 1315 | #else | ||
| 1316 | static inline void pci_fixup_device(enum pci_fixup_pass pass, | ||
| 1317 | struct pci_dev *dev) {} | ||
| 1318 | #endif | ||
| 1229 | 1319 | ||
| 1230 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); | 1320 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); |
| 1231 | void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); | 1321 | void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); |
| @@ -1246,6 +1336,8 @@ extern int pci_pci_problems; | |||
| 1246 | 1336 | ||
| 1247 | extern unsigned long pci_cardbus_io_size; | 1337 | extern unsigned long pci_cardbus_io_size; |
| 1248 | extern unsigned long pci_cardbus_mem_size; | 1338 | extern unsigned long pci_cardbus_mem_size; |
| 1339 | extern u8 __devinitdata pci_dfl_cache_line_size; | ||
| 1340 | extern u8 pci_cache_line_size; | ||
| 1249 | 1341 | ||
| 1250 | extern unsigned long pci_hotplug_io_size; | 1342 | extern unsigned long pci_hotplug_io_size; |
| 1251 | extern unsigned long pci_hotplug_mem_size; | 1343 | extern unsigned long pci_hotplug_mem_size; |
| @@ -1271,6 +1363,7 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); | |||
| 1271 | extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); | 1363 | extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); |
| 1272 | extern void pci_disable_sriov(struct pci_dev *dev); | 1364 | extern void pci_disable_sriov(struct pci_dev *dev); |
| 1273 | extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); | 1365 | extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); |
| 1366 | extern int pci_num_vf(struct pci_dev *dev); | ||
| 1274 | #else | 1367 | #else |
| 1275 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) | 1368 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) |
| 1276 | { | 1369 | { |
| @@ -1283,6 +1376,10 @@ static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev) | |||
| 1283 | { | 1376 | { |
| 1284 | return IRQ_NONE; | 1377 | return IRQ_NONE; |
| 1285 | } | 1378 | } |
| 1379 | static inline int pci_num_vf(struct pci_dev *dev) | ||
| 1380 | { | ||
| 1381 | return 0; | ||
| 1382 | } | ||
| 1286 | #endif | 1383 | #endif |
| 1287 | 1384 | ||
| 1288 | #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) | 1385 | #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) |
| @@ -1290,5 +1387,122 @@ extern void pci_hp_create_module_link(struct pci_slot *pci_slot); | |||
| 1290 | extern void pci_hp_remove_module_link(struct pci_slot *pci_slot); | 1387 | extern void pci_hp_remove_module_link(struct pci_slot *pci_slot); |
| 1291 | #endif | 1388 | #endif |
| 1292 | 1389 | ||
| 1390 | /** | ||
| 1391 | * pci_pcie_cap - get the saved PCIe capability offset | ||
| 1392 | * @dev: PCI device | ||
| 1393 | * | ||
| 1394 | * PCIe capability offset is calculated at PCI device initialization | ||
| 1395 | * time and saved in the data structure. This function returns saved | ||
| 1396 | * PCIe capability offset. Using this instead of pci_find_capability() | ||
| 1397 | * reduces unnecessary search in the PCI configuration space. If you | ||
| 1398 | * need to calculate PCIe capability offset from raw device for some | ||
| 1399 | * reasons, please use pci_find_capability() instead. | ||
| 1400 | */ | ||
| 1401 | static inline int pci_pcie_cap(struct pci_dev *dev) | ||
| 1402 | { | ||
| 1403 | return dev->pcie_cap; | ||
| 1404 | } | ||
| 1405 | |||
| 1406 | /** | ||
| 1407 | * pci_is_pcie - check if the PCI device is PCI Express capable | ||
| 1408 | * @dev: PCI device | ||
| 1409 | * | ||
| 1410 | * Retrun true if the PCI device is PCI Express capable, false otherwise. | ||
| 1411 | */ | ||
| 1412 | static inline bool pci_is_pcie(struct pci_dev *dev) | ||
| 1413 | { | ||
| 1414 | return !!pci_pcie_cap(dev); | ||
| 1415 | } | ||
| 1416 | |||
| 1417 | void pci_request_acs(void); | ||
| 1418 | |||
| 1419 | |||
| 1420 | #define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */ | ||
| 1421 | #define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT) | ||
| 1422 | |||
| 1423 | /* Large Resource Data Type Tag Item Names */ | ||
| 1424 | #define PCI_VPD_LTIN_ID_STRING 0x02 /* Identifier String */ | ||
| 1425 | #define PCI_VPD_LTIN_RO_DATA 0x10 /* Read-Only Data */ | ||
| 1426 | #define PCI_VPD_LTIN_RW_DATA 0x11 /* Read-Write Data */ | ||
| 1427 | |||
| 1428 | #define PCI_VPD_LRDT_ID_STRING PCI_VPD_LRDT_ID(PCI_VPD_LTIN_ID_STRING) | ||
| 1429 | #define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA) | ||
| 1430 | #define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA) | ||
| 1431 | |||
| 1432 | /* Small Resource Data Type Tag Item Names */ | ||
| 1433 | #define PCI_VPD_STIN_END 0x78 /* End */ | ||
| 1434 | |||
| 1435 | #define PCI_VPD_SRDT_END PCI_VPD_STIN_END | ||
| 1436 | |||
| 1437 | #define PCI_VPD_SRDT_TIN_MASK 0x78 | ||
| 1438 | #define PCI_VPD_SRDT_LEN_MASK 0x07 | ||
| 1439 | |||
| 1440 | #define PCI_VPD_LRDT_TAG_SIZE 3 | ||
| 1441 | #define PCI_VPD_SRDT_TAG_SIZE 1 | ||
| 1442 | |||
| 1443 | #define PCI_VPD_INFO_FLD_HDR_SIZE 3 | ||
| 1444 | |||
| 1445 | #define PCI_VPD_RO_KEYWORD_PARTNO "PN" | ||
| 1446 | #define PCI_VPD_RO_KEYWORD_MFR_ID "MN" | ||
| 1447 | #define PCI_VPD_RO_KEYWORD_VENDOR0 "V0" | ||
| 1448 | |||
| 1449 | /** | ||
| 1450 | * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length | ||
| 1451 | * @lrdt: Pointer to the beginning of the Large Resource Data Type tag | ||
| 1452 | * | ||
| 1453 | * Returns the extracted Large Resource Data Type length. | ||
| 1454 | */ | ||
| 1455 | static inline u16 pci_vpd_lrdt_size(const u8 *lrdt) | ||
| 1456 | { | ||
| 1457 | return (u16)lrdt[1] + ((u16)lrdt[2] << 8); | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | /** | ||
| 1461 | * pci_vpd_srdt_size - Extracts the Small Resource Data Type length | ||
| 1462 | * @lrdt: Pointer to the beginning of the Small Resource Data Type tag | ||
| 1463 | * | ||
| 1464 | * Returns the extracted Small Resource Data Type length. | ||
| 1465 | */ | ||
| 1466 | static inline u8 pci_vpd_srdt_size(const u8 *srdt) | ||
| 1467 | { | ||
| 1468 | return (*srdt) & PCI_VPD_SRDT_LEN_MASK; | ||
| 1469 | } | ||
| 1470 | |||
| 1471 | /** | ||
| 1472 | * pci_vpd_info_field_size - Extracts the information field length | ||
| 1473 | * @lrdt: Pointer to the beginning of an information field header | ||
| 1474 | * | ||
| 1475 | * Returns the extracted information field length. | ||
| 1476 | */ | ||
| 1477 | static inline u8 pci_vpd_info_field_size(const u8 *info_field) | ||
| 1478 | { | ||
| 1479 | return info_field[2]; | ||
| 1480 | } | ||
| 1481 | |||
| 1482 | /** | ||
| 1483 | * pci_vpd_find_tag - Locates the Resource Data Type tag provided | ||
| 1484 | * @buf: Pointer to buffered vpd data | ||
| 1485 | * @off: The offset into the buffer at which to begin the search | ||
| 1486 | * @len: The length of the vpd buffer | ||
| 1487 | * @rdt: The Resource Data Type to search for | ||
| 1488 | * | ||
| 1489 | * Returns the index where the Resource Data Type was found or | ||
| 1490 | * -ENOENT otherwise. | ||
| 1491 | */ | ||
| 1492 | int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt); | ||
| 1493 | |||
| 1494 | /** | ||
| 1495 | * pci_vpd_find_info_keyword - Locates an information field keyword in the VPD | ||
| 1496 | * @buf: Pointer to buffered vpd data | ||
| 1497 | * @off: The offset into the buffer at which to begin the search | ||
| 1498 | * @len: The length of the buffer area, relative to off, in which to search | ||
| 1499 | * @kw: The keyword to search for | ||
| 1500 | * | ||
| 1501 | * Returns the index where the information field keyword was found or | ||
| 1502 | * -ENOENT otherwise. | ||
| 1503 | */ | ||
| 1504 | int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, | ||
| 1505 | unsigned int len, const char *kw); | ||
| 1506 | |||
| 1293 | #endif /* __KERNEL__ */ | 1507 | #endif /* __KERNEL__ */ |
| 1294 | #endif /* LINUX_PCI_H */ | 1508 | #endif /* LINUX_PCI_H */ |
