1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Purpose: PCI Express Port Bus Driver's Internal Data Structures
5 * Copyright (C) 2004 Intel
6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
12 #include <linux/compiler.h>
15 #define PCIE_PORT_SERVICE_PME_SHIFT 0 /* Power Management Event */
16 #define PCIE_PORT_SERVICE_PME (1 << PCIE_PORT_SERVICE_PME_SHIFT)
17 #define PCIE_PORT_SERVICE_AER_SHIFT 1 /* Advanced Error Reporting */
18 #define PCIE_PORT_SERVICE_AER (1 << PCIE_PORT_SERVICE_AER_SHIFT)
19 #define PCIE_PORT_SERVICE_HP_SHIFT 2 /* Native Hotplug */
20 #define PCIE_PORT_SERVICE_HP (1 << PCIE_PORT_SERVICE_HP_SHIFT)
21 #define PCIE_PORT_SERVICE_DPC_SHIFT 3 /* Downstream Port Containment */
22 #define PCIE_PORT_SERVICE_DPC (1 << PCIE_PORT_SERVICE_DPC_SHIFT)
23 #define PCIE_PORT_SERVICE_BWNOTIF_SHIFT 4 /* Bandwidth notification */
24 #define PCIE_PORT_SERVICE_BWNOTIF (1 << PCIE_PORT_SERVICE_BWNOTIF_SHIFT)
26 #define PCIE_PORT_DEVICE_MAXSERVICES 5
28 extern bool pcie_ports_dpc_native;
31 int pcie_aer_init(void);
33 static inline int pcie_aer_init(void) { return 0; }
36 #ifdef CONFIG_HOTPLUG_PCI_PCIE
37 int pcie_hp_init(void);
39 static inline int pcie_hp_init(void) { return 0; }
42 #ifdef CONFIG_PCIE_PME
43 int pcie_pme_init(void);
45 static inline int pcie_pme_init(void) { return 0; }
48 #ifdef CONFIG_PCIE_DPC
49 int pcie_dpc_init(void);
51 static inline int pcie_dpc_init(void) { return 0; }
55 #define PCIE_ANY_PORT (~0)
58 int irq; /* Service IRQ/MSI/MSI-X Vector */
59 struct pci_dev *port; /* Root/Upstream/Downstream Port */
60 u32 service; /* Port service this device represents */
61 void *priv_data; /* Service Private Data */
62 struct device device; /* Generic Device Interface */
64 #define to_pcie_device(d) container_of(d, struct pcie_device, device)
66 static inline void set_service_data(struct pcie_device *dev, void *data)
68 dev->priv_data = data;
71 static inline void *get_service_data(struct pcie_device *dev)
73 return dev->priv_data;
76 struct pcie_port_service_driver {
78 int (*probe)(struct pcie_device *dev);
79 void (*remove)(struct pcie_device *dev);
80 int (*suspend)(struct pcie_device *dev);
81 int (*resume_noirq)(struct pcie_device *dev);
82 int (*resume)(struct pcie_device *dev);
83 int (*runtime_suspend)(struct pcie_device *dev);
84 int (*runtime_resume)(struct pcie_device *dev);
86 int (*slot_reset)(struct pcie_device *dev);
88 int port_type; /* Type of the port this driver can handle */
89 u32 service; /* Port service this device represents */
91 struct device_driver driver;
93 #define to_service_driver(d) \
94 container_of(d, struct pcie_port_service_driver, driver)
96 int pcie_port_service_register(struct pcie_port_service_driver *new);
97 void pcie_port_service_unregister(struct pcie_port_service_driver *new);
99 extern struct bus_type pcie_port_bus_type;
103 #ifdef CONFIG_PCIE_PME
104 extern bool pcie_pme_msi_disabled;
106 static inline void pcie_pme_disable_msi(void)
108 pcie_pme_msi_disabled = true;
111 static inline bool pcie_pme_no_msi(void)
113 return pcie_pme_msi_disabled;
116 void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable);
117 #else /* !CONFIG_PCIE_PME */
118 static inline void pcie_pme_disable_msi(void) {}
119 static inline bool pcie_pme_no_msi(void) { return false; }
120 static inline void pcie_pme_interrupt_enable(struct pci_dev *dev, bool en) {}
121 #endif /* !CONFIG_PCIE_PME */
123 struct device *pcie_port_find_device(struct pci_dev *dev, u32 service);
124 #endif /* _PORTDRV_H_ */