pci.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Functions internal to the PCI core code */
  2. extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
  3. extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
  4. extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
  5. extern void pci_cleanup_rom(struct pci_dev *dev);
  6. /* Firmware callbacks */
  7. extern pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev,
  8. pm_message_t state);
  9. extern int (*platform_pci_set_power_state)(struct pci_dev *dev,
  10. pci_power_t state);
  11. extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
  12. extern int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val);
  13. extern int pci_user_read_config_dword(struct pci_dev *dev, int where, u32 *val);
  14. extern int pci_user_write_config_byte(struct pci_dev *dev, int where, u8 val);
  15. extern int pci_user_write_config_word(struct pci_dev *dev, int where, u16 val);
  16. extern int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val);
  17. /* PCI /proc functions */
  18. #ifdef CONFIG_PROC_FS
  19. extern int pci_proc_attach_device(struct pci_dev *dev);
  20. extern int pci_proc_detach_device(struct pci_dev *dev);
  21. extern int pci_proc_detach_bus(struct pci_bus *bus);
  22. #else
  23. static inline int pci_proc_attach_device(struct pci_dev *dev) { return 0; }
  24. static inline int pci_proc_detach_device(struct pci_dev *dev) { return 0; }
  25. static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }
  26. #endif
  27. /* Functions for PCI Hotplug drivers to use */
  28. extern unsigned int pci_do_scan_bus(struct pci_bus *bus);
  29. extern void pci_remove_legacy_files(struct pci_bus *bus);
  30. /* Lock for read/write access to pci device and bus lists */
  31. extern struct rw_semaphore pci_bus_sem;
  32. extern unsigned int pci_pm_d3_delay;
  33. #ifdef CONFIG_PCI_MSI
  34. void pci_no_msi(void);
  35. extern void pci_msi_init_pci_dev(struct pci_dev *dev);
  36. #else
  37. static inline void pci_no_msi(void) { }
  38. static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { }
  39. #endif
  40. #ifdef CONFIG_PCIEAER
  41. void pci_no_aer(void);
  42. #else
  43. static inline void pci_no_aer(void) { }
  44. #endif
  45. static inline int pci_no_d1d2(struct pci_dev *dev)
  46. {
  47. unsigned int parent_dstates = 0;
  48. if (dev->bus->self)
  49. parent_dstates = dev->bus->self->no_d1d2;
  50. return (dev->no_d1d2 || parent_dstates);
  51. }
  52. extern int pcie_mch_quirk;
  53. extern struct device_attribute pci_dev_attrs[];
  54. extern struct class_device_attribute class_device_attr_cpuaffinity;
  55. /**
  56. * pci_match_one_device - Tell if a PCI device structure has a matching
  57. * PCI device id structure
  58. * @id: single PCI device id structure to match
  59. * @dev: the PCI device structure to match against
  60. *
  61. * Returns the matching pci_device_id structure or %NULL if there is no match.
  62. */
  63. static inline const struct pci_device_id *
  64. pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev)
  65. {
  66. if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) &&
  67. (id->device == PCI_ANY_ID || id->device == dev->device) &&
  68. (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) &&
  69. (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) &&
  70. !((id->class ^ dev->class) & id->class_mask))
  71. return id;
  72. return NULL;
  73. }
  74. struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev);