diff options
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r-- | include/linux/pci.h | 84 |
1 files changed, 72 insertions, 12 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index fefb4e19bf6a..5faa8310eec9 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -132,9 +132,10 @@ static inline const char *pci_power_name(pci_power_t state) | |||
132 | return pci_power_names[1 + (int) state]; | 132 | return pci_power_names[1 + (int) state]; |
133 | } | 133 | } |
134 | 134 | ||
135 | #define PCI_PM_D2_DELAY 200 | 135 | #define PCI_PM_D2_DELAY 200 |
136 | #define PCI_PM_D3_WAIT 10 | 136 | #define PCI_PM_D3_WAIT 10 |
137 | #define PCI_PM_BUS_WAIT 50 | 137 | #define PCI_PM_D3COLD_WAIT 100 |
138 | #define PCI_PM_BUS_WAIT 50 | ||
138 | 139 | ||
139 | /** The pci_channel state describes connectivity between the CPU and | 140 | /** The pci_channel state describes connectivity between the CPU and |
140 | * the pci device. If some PCI bus between here and the pci device | 141 | * the pci device. If some PCI bus between here and the pci device |
@@ -176,8 +177,6 @@ enum pci_dev_flags { | |||
176 | PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2, | 177 | PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2, |
177 | /* Provide indication device is assigned by a Virtual Machine Manager */ | 178 | /* Provide indication device is assigned by a Virtual Machine Manager */ |
178 | PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4, | 179 | PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4, |
179 | /* Device causes system crash if in D3 during S3 sleep */ | ||
180 | PCI_DEV_FLAGS_NO_D3_DURING_SLEEP = (__force pci_dev_flags_t) 8, | ||
181 | }; | 180 | }; |
182 | 181 | ||
183 | enum pci_irq_reroute_variant { | 182 | enum pci_irq_reroute_variant { |
@@ -280,11 +279,18 @@ struct pci_dev { | |||
280 | unsigned int pme_poll:1; /* Poll device's PME status bit */ | 279 | unsigned int pme_poll:1; /* Poll device's PME status bit */ |
281 | unsigned int d1_support:1; /* Low power state D1 is supported */ | 280 | unsigned int d1_support:1; /* Low power state D1 is supported */ |
282 | unsigned int d2_support:1; /* Low power state D2 is supported */ | 281 | unsigned int d2_support:1; /* Low power state D2 is supported */ |
283 | unsigned int no_d1d2:1; /* Only allow D0 and D3 */ | 282 | unsigned int no_d1d2:1; /* D1 and D2 are forbidden */ |
283 | unsigned int no_d3cold:1; /* D3cold is forbidden */ | ||
284 | unsigned int d3cold_allowed:1; /* D3cold is allowed by user */ | ||
284 | unsigned int mmio_always_on:1; /* disallow turning off io/mem | 285 | unsigned int mmio_always_on:1; /* disallow turning off io/mem |
285 | decoding during bar sizing */ | 286 | decoding during bar sizing */ |
286 | unsigned int wakeup_prepared:1; | 287 | unsigned int wakeup_prepared:1; |
288 | unsigned int runtime_d3cold:1; /* whether go through runtime | ||
289 | D3cold, not set for devices | ||
290 | powered on/off by the | ||
291 | corresponding bridge */ | ||
287 | unsigned int d3_delay; /* D3->D0 transition time in ms */ | 292 | unsigned int d3_delay; /* D3->D0 transition time in ms */ |
293 | unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */ | ||
288 | 294 | ||
289 | #ifdef CONFIG_PCIEASPM | 295 | #ifdef CONFIG_PCIEASPM |
290 | struct pcie_link_state *link_state; /* ASPM link state. */ | 296 | struct pcie_link_state *link_state; /* ASPM link state. */ |
@@ -326,6 +332,8 @@ struct pci_dev { | |||
326 | unsigned int is_hotplug_bridge:1; | 332 | unsigned int is_hotplug_bridge:1; |
327 | unsigned int __aer_firmware_first_valid:1; | 333 | unsigned int __aer_firmware_first_valid:1; |
328 | unsigned int __aer_firmware_first:1; | 334 | unsigned int __aer_firmware_first:1; |
335 | unsigned int broken_intx_masking:1; | ||
336 | unsigned int io_window_1k:1; /* Intel P2P bridge 1K I/O windows */ | ||
329 | pci_dev_flags_t dev_flags; | 337 | pci_dev_flags_t dev_flags; |
330 | atomic_t enable_cnt; /* pci_enable_device has been called */ | 338 | atomic_t enable_cnt; /* pci_enable_device has been called */ |
331 | 339 | ||
@@ -370,6 +378,8 @@ static inline int pci_channel_offline(struct pci_dev *pdev) | |||
370 | return (pdev->error_state != pci_channel_io_normal); | 378 | return (pdev->error_state != pci_channel_io_normal); |
371 | } | 379 | } |
372 | 380 | ||
381 | extern struct resource busn_resource; | ||
382 | |||
373 | struct pci_host_bridge_window { | 383 | struct pci_host_bridge_window { |
374 | struct list_head list; | 384 | struct list_head list; |
375 | struct resource *res; /* host bridge aperture (CPU address) */ | 385 | struct resource *res; /* host bridge aperture (CPU address) */ |
@@ -421,6 +431,7 @@ struct pci_bus { | |||
421 | struct list_head slots; /* list of slots on this bus */ | 431 | struct list_head slots; /* list of slots on this bus */ |
422 | struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; | 432 | struct resource *resource[PCI_BRIDGE_RESOURCE_NUM]; |
423 | struct list_head resources; /* address space routed to this bus */ | 433 | struct list_head resources; /* address space routed to this bus */ |
434 | struct resource busn_res; /* bus numbers routed to this bus */ | ||
424 | 435 | ||
425 | struct pci_ops *ops; /* configuration access functions */ | 436 | struct pci_ops *ops; /* configuration access functions */ |
426 | void *sysdata; /* hook for sys-specific extension */ | 437 | void *sysdata; /* hook for sys-specific extension */ |
@@ -428,8 +439,6 @@ struct pci_bus { | |||
428 | 439 | ||
429 | unsigned char number; /* bus number */ | 440 | unsigned char number; /* bus number */ |
430 | unsigned char primary; /* number of primary bridge */ | 441 | unsigned char primary; /* number of primary bridge */ |
431 | unsigned char secondary; /* number of secondary bridge */ | ||
432 | unsigned char subordinate; /* max number of subordinate buses */ | ||
433 | unsigned char max_bus_speed; /* enum pci_bus_speed */ | 442 | unsigned char max_bus_speed; /* enum pci_bus_speed */ |
434 | unsigned char cur_bus_speed; /* enum pci_bus_speed */ | 443 | unsigned char cur_bus_speed; /* enum pci_bus_speed */ |
435 | 444 | ||
@@ -476,6 +485,32 @@ static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false; | |||
476 | #define PCIBIOS_SET_FAILED 0x88 | 485 | #define PCIBIOS_SET_FAILED 0x88 |
477 | #define PCIBIOS_BUFFER_TOO_SMALL 0x89 | 486 | #define PCIBIOS_BUFFER_TOO_SMALL 0x89 |
478 | 487 | ||
488 | /* | ||
489 | * Translate above to generic errno for passing back through non-pci. | ||
490 | */ | ||
491 | static inline int pcibios_err_to_errno(int err) | ||
492 | { | ||
493 | if (err <= PCIBIOS_SUCCESSFUL) | ||
494 | return err; /* Assume already errno */ | ||
495 | |||
496 | switch (err) { | ||
497 | case PCIBIOS_FUNC_NOT_SUPPORTED: | ||
498 | return -ENOENT; | ||
499 | case PCIBIOS_BAD_VENDOR_ID: | ||
500 | return -EINVAL; | ||
501 | case PCIBIOS_DEVICE_NOT_FOUND: | ||
502 | return -ENODEV; | ||
503 | case PCIBIOS_BAD_REGISTER_NUMBER: | ||
504 | return -EFAULT; | ||
505 | case PCIBIOS_SET_FAILED: | ||
506 | return -EIO; | ||
507 | case PCIBIOS_BUFFER_TOO_SMALL: | ||
508 | return -ENOSPC; | ||
509 | } | ||
510 | |||
511 | return -ENOTTY; | ||
512 | } | ||
513 | |||
479 | /* Low-level architecture-dependent routines */ | 514 | /* Low-level architecture-dependent routines */ |
480 | 515 | ||
481 | struct pci_ops { | 516 | struct pci_ops { |
@@ -644,6 +679,7 @@ extern int no_pci_devices(void); | |||
644 | 679 | ||
645 | void pcibios_fixup_bus(struct pci_bus *); | 680 | void pcibios_fixup_bus(struct pci_bus *); |
646 | int __must_check pcibios_enable_device(struct pci_dev *, int mask); | 681 | int __must_check pcibios_enable_device(struct pci_dev *, int mask); |
682 | /* Architecture specific versions may override this (weak) */ | ||
647 | char *pcibios_setup(char *str); | 683 | char *pcibios_setup(char *str); |
648 | 684 | ||
649 | /* Used only when drivers/pci/setup.c is used */ | 685 | /* Used only when drivers/pci/setup.c is used */ |
@@ -670,6 +706,9 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata); | |||
670 | struct pci_bus *pci_create_root_bus(struct device *parent, int bus, | 706 | struct pci_bus *pci_create_root_bus(struct device *parent, int bus, |
671 | struct pci_ops *ops, void *sysdata, | 707 | struct pci_ops *ops, void *sysdata, |
672 | struct list_head *resources); | 708 | struct list_head *resources); |
709 | int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax); | ||
710 | int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax); | ||
711 | void pci_bus_release_busn_res(struct pci_bus *b); | ||
673 | struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, | 712 | struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, |
674 | struct pci_ops *ops, void *sysdata, | 713 | struct pci_ops *ops, void *sysdata, |
675 | struct list_head *resources); | 714 | struct list_head *resources); |
@@ -716,8 +755,6 @@ enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev); | |||
716 | int pci_find_capability(struct pci_dev *dev, int cap); | 755 | int pci_find_capability(struct pci_dev *dev, int cap); |
717 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); | 756 | int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); |
718 | int pci_find_ext_capability(struct pci_dev *dev, int cap); | 757 | int pci_find_ext_capability(struct pci_dev *dev, int cap); |
719 | int pci_bus_find_ext_capability(struct pci_bus *bus, unsigned int devfn, | ||
720 | int cap); | ||
721 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); | 758 | int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); |
722 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); | 759 | int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); |
723 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); | 760 | struct pci_bus *pci_find_next_bus(const struct pci_bus *from); |
@@ -779,6 +816,14 @@ static inline int pci_write_config_dword(const struct pci_dev *dev, int where, | |||
779 | return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); | 816 | return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); |
780 | } | 817 | } |
781 | 818 | ||
819 | /* user-space driven config access */ | ||
820 | int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); | ||
821 | int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val); | ||
822 | int pci_user_read_config_dword(struct pci_dev *dev, int where, u32 *val); | ||
823 | int pci_user_write_config_byte(struct pci_dev *dev, int where, u8 val); | ||
824 | int pci_user_write_config_word(struct pci_dev *dev, int where, u16 val); | ||
825 | int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val); | ||
826 | |||
782 | int __must_check pci_enable_device(struct pci_dev *dev); | 827 | int __must_check pci_enable_device(struct pci_dev *dev); |
783 | int __must_check pci_enable_device_io(struct pci_dev *dev); | 828 | int __must_check pci_enable_device_io(struct pci_dev *dev); |
784 | int __must_check pci_enable_device_mem(struct pci_dev *dev); | 829 | int __must_check pci_enable_device_mem(struct pci_dev *dev); |
@@ -877,7 +922,6 @@ enum pci_obff_signal_type { | |||
877 | int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type); | 922 | int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type); |
878 | void pci_disable_obff(struct pci_dev *dev); | 923 | void pci_disable_obff(struct pci_dev *dev); |
879 | 924 | ||
880 | bool pci_ltr_supported(struct pci_dev *dev); | ||
881 | int pci_enable_ltr(struct pci_dev *dev); | 925 | int pci_enable_ltr(struct pci_dev *dev); |
882 | void pci_disable_ltr(struct pci_dev *dev); | 926 | void pci_disable_ltr(struct pci_dev *dev); |
883 | int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns); | 927 | int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns); |
@@ -1334,6 +1378,9 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, | |||
1334 | static inline int pci_domain_nr(struct pci_bus *bus) | 1378 | static inline int pci_domain_nr(struct pci_bus *bus) |
1335 | { return 0; } | 1379 | { return 0; } |
1336 | 1380 | ||
1381 | static inline struct pci_dev *pci_dev_get(struct pci_dev *dev) | ||
1382 | { return NULL; } | ||
1383 | |||
1337 | #define dev_is_pci(d) (false) | 1384 | #define dev_is_pci(d) (false) |
1338 | #define dev_is_pf(d) (false) | 1385 | #define dev_is_pf(d) (false) |
1339 | #define dev_num_vf(d) (0) | 1386 | #define dev_num_vf(d) (0) |
@@ -1488,9 +1535,20 @@ enum pci_fixup_pass { | |||
1488 | 1535 | ||
1489 | #ifdef CONFIG_PCI_QUIRKS | 1536 | #ifdef CONFIG_PCI_QUIRKS |
1490 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); | 1537 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); |
1538 | struct pci_dev *pci_get_dma_source(struct pci_dev *dev); | ||
1539 | int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags); | ||
1491 | #else | 1540 | #else |
1492 | static inline void pci_fixup_device(enum pci_fixup_pass pass, | 1541 | static inline void pci_fixup_device(enum pci_fixup_pass pass, |
1493 | struct pci_dev *dev) {} | 1542 | struct pci_dev *dev) {} |
1543 | static inline struct pci_dev *pci_get_dma_source(struct pci_dev *dev) | ||
1544 | { | ||
1545 | return pci_dev_get(dev); | ||
1546 | } | ||
1547 | static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev, | ||
1548 | u16 acs_flags) | ||
1549 | { | ||
1550 | return -ENOTTY; | ||
1551 | } | ||
1494 | #endif | 1552 | #endif |
1495 | 1553 | ||
1496 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); | 1554 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); |
@@ -1593,7 +1651,9 @@ static inline bool pci_is_pcie(struct pci_dev *dev) | |||
1593 | } | 1651 | } |
1594 | 1652 | ||
1595 | void pci_request_acs(void); | 1653 | void pci_request_acs(void); |
1596 | 1654 | bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); | |
1655 | bool pci_acs_path_enabled(struct pci_dev *start, | ||
1656 | struct pci_dev *end, u16 acs_flags); | ||
1597 | 1657 | ||
1598 | #define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */ | 1658 | #define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */ |
1599 | #define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT) | 1659 | #define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT) |