pci-acpi.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * File pci-acpi.h
  4. *
  5. * Copyright (C) 2004 Intel
  6. * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
  7. */
  8. #ifndef _PCI_ACPI_H_
  9. #define _PCI_ACPI_H_
  10. #include <linux/acpi.h>
  11. #ifdef CONFIG_ACPI
  12. extern acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev);
  13. static inline acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev)
  14. {
  15. return acpi_remove_pm_notifier(dev);
  16. }
  17. extern acpi_status pci_acpi_add_pm_notifier(struct acpi_device *dev,
  18. struct pci_dev *pci_dev);
  19. static inline acpi_status pci_acpi_remove_pm_notifier(struct acpi_device *dev)
  20. {
  21. return acpi_remove_pm_notifier(dev);
  22. }
  23. extern phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle);
  24. struct pci_ecam_ops;
  25. extern int pci_mcfg_lookup(struct acpi_pci_root *root, struct resource *cfgres,
  26. const struct pci_ecam_ops **ecam_ops);
  27. static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev)
  28. {
  29. struct pci_bus *pbus = pdev->bus;
  30. /* Find a PCI root bus */
  31. while (!pci_is_root_bus(pbus))
  32. pbus = pbus->parent;
  33. return ACPI_HANDLE(pbus->bridge);
  34. }
  35. static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus)
  36. {
  37. struct device *dev;
  38. if (pci_is_root_bus(pbus))
  39. dev = pbus->bridge;
  40. else {
  41. /* If pbus is a virtual bus, there is no bridge to it */
  42. if (!pbus->self)
  43. return NULL;
  44. dev = &pbus->self->dev;
  45. }
  46. return ACPI_HANDLE(dev);
  47. }
  48. struct acpi_pci_root;
  49. struct acpi_pci_root_ops;
  50. struct acpi_pci_root_info {
  51. struct acpi_pci_root *root;
  52. struct acpi_device *bridge;
  53. struct acpi_pci_root_ops *ops;
  54. struct list_head resources;
  55. char name[16];
  56. };
  57. struct acpi_pci_root_ops {
  58. struct pci_ops *pci_ops;
  59. int (*init_info)(struct acpi_pci_root_info *info);
  60. void (*release_info)(struct acpi_pci_root_info *info);
  61. int (*prepare_resources)(struct acpi_pci_root_info *info);
  62. };
  63. extern int acpi_pci_probe_root_resources(struct acpi_pci_root_info *info);
  64. extern struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
  65. struct acpi_pci_root_ops *ops,
  66. struct acpi_pci_root_info *info,
  67. void *sd);
  68. void acpi_pci_add_bus(struct pci_bus *bus);
  69. void acpi_pci_remove_bus(struct pci_bus *bus);
  70. #ifdef CONFIG_ACPI_PCI_SLOT
  71. void acpi_pci_slot_init(void);
  72. void acpi_pci_slot_enumerate(struct pci_bus *bus);
  73. void acpi_pci_slot_remove(struct pci_bus *bus);
  74. #else
  75. static inline void acpi_pci_slot_init(void) { }
  76. static inline void acpi_pci_slot_enumerate(struct pci_bus *bus) { }
  77. static inline void acpi_pci_slot_remove(struct pci_bus *bus) { }
  78. #endif
  79. #ifdef CONFIG_HOTPLUG_PCI_ACPI
  80. void acpiphp_init(void);
  81. void acpiphp_enumerate_slots(struct pci_bus *bus);
  82. void acpiphp_remove_slots(struct pci_bus *bus);
  83. void acpiphp_check_host_bridge(struct acpi_device *adev);
  84. #else
  85. static inline void acpiphp_init(void) { }
  86. static inline void acpiphp_enumerate_slots(struct pci_bus *bus) { }
  87. static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
  88. static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
  89. #endif
  90. extern const guid_t pci_acpi_dsm_guid;
  91. /* _DSM Definitions for PCI */
  92. #define DSM_PCI_PRESERVE_BOOT_CONFIG 0x05
  93. #define DSM_PCI_DEVICE_NAME 0x07
  94. #define DSM_PCI_POWER_ON_RESET_DELAY 0x08
  95. #define DSM_PCI_DEVICE_READINESS_DURATIONS 0x09
  96. #ifdef CONFIG_PCIE_EDR
  97. void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
  98. void pci_acpi_remove_edr_notifier(struct pci_dev *pdev);
  99. #else
  100. static inline void pci_acpi_add_edr_notifier(struct pci_dev *pdev) { }
  101. static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { }
  102. #endif /* CONFIG_PCIE_EDR */
  103. #else /* CONFIG_ACPI */
  104. static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
  105. static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
  106. #endif /* CONFIG_ACPI */
  107. #endif /* _PCI_ACPI_H_ */