Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * File: portdrv.h |
| 4 | * Purpose: PCI Express Port Bus Driver's Internal Data Structures |
| 5 | * |
| 6 | * Copyright (C) 2004 Intel |
| 7 | * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) |
| 8 | */ |
| 9 | |
| 10 | #ifndef _PORTDRV_H_ |
| 11 | #define _PORTDRV_H_ |
| 12 | |
Andrew Morton | 3ec6a8d | 2006-09-25 16:52:20 -0700 | [diff] [blame] | 13 | #include <linux/compiler.h> |
| 14 | |
Keith Busch | 10126ac | 2016-05-02 15:10:31 -0500 | [diff] [blame] | 15 | #define PCIE_PORT_DEVICE_MAXSERVICES 5 |
Rafael J. Wysocki | b43d451 | 2009-01-24 00:23:22 +0100 | [diff] [blame] | 16 | /* |
Gabriele Paoloni | a1d5f18 | 2017-05-23 15:23:58 +0100 | [diff] [blame] | 17 | * The PCIe Capability Interrupt Message Number (PCIe r3.1, sec 7.8.2) must |
| 18 | * be one of the first 32 MSI-X entries. Per PCI r3.0, sec 6.8.3.1, MSI |
| 19 | * supports a maximum of 32 vectors per function. |
Rafael J. Wysocki | b43d451 | 2009-01-24 00:23:22 +0100 | [diff] [blame] | 20 | */ |
Gabriele Paoloni | a1d5f18 | 2017-05-23 15:23:58 +0100 | [diff] [blame] | 21 | #define PCIE_PORT_MAX_MSI_ENTRIES 32 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Keith Busch | 6d81417 | 2016-05-03 09:58:11 -0500 | [diff] [blame] | 23 | #define get_descriptor_id(type, service) (((type - 4) << 8) | service) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | extern struct bus_type pcie_port_bus_type; |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 26 | int pcie_port_device_register(struct pci_dev *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #ifdef CONFIG_PM |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 28 | int pcie_port_device_suspend(struct device *dev); |
| 29 | int pcie_port_device_resume(struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #endif |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 31 | void pcie_port_device_remove(struct pci_dev *dev); |
| 32 | int __must_check pcie_port_bus_register(void); |
| 33 | void pcie_port_bus_unregister(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Rafael J. Wysocki | 28eb5f2 | 2010-08-21 22:02:38 +0200 | [diff] [blame] | 35 | struct pci_dev; |
| 36 | |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 37 | void pcie_clear_root_pme_status(struct pci_dev *dev); |
Rafael J. Wysocki | fe31e69 | 2010-12-19 15:57:16 +0100 | [diff] [blame] | 38 | |
MUNEDA Takahiro | 7570a33 | 2012-02-02 11:09:22 -0500 | [diff] [blame] | 39 | #ifdef CONFIG_HOTPLUG_PCI_PCIE |
| 40 | extern bool pciehp_msi_disabled; |
| 41 | |
| 42 | static inline bool pciehp_no_msi(void) |
| 43 | { |
| 44 | return pciehp_msi_disabled; |
| 45 | } |
| 46 | |
| 47 | #else /* !CONFIG_HOTPLUG_PCI_PCIE */ |
| 48 | static inline bool pciehp_no_msi(void) { return false; } |
| 49 | #endif /* !CONFIG_HOTPLUG_PCI_PCIE */ |
| 50 | |
Rafael J. Wysocki | c39fae1 | 2010-02-17 23:40:07 +0100 | [diff] [blame] | 51 | #ifdef CONFIG_PCIE_PME |
| 52 | extern bool pcie_pme_msi_disabled; |
| 53 | |
| 54 | static inline void pcie_pme_disable_msi(void) |
| 55 | { |
| 56 | pcie_pme_msi_disabled = true; |
| 57 | } |
| 58 | |
| 59 | static inline bool pcie_pme_no_msi(void) |
| 60 | { |
| 61 | return pcie_pme_msi_disabled; |
| 62 | } |
Rafael J. Wysocki | 28eb5f2 | 2010-08-21 22:02:38 +0200 | [diff] [blame] | 63 | |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 64 | void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable); |
Rafael J. Wysocki | c39fae1 | 2010-02-17 23:40:07 +0100 | [diff] [blame] | 65 | #else /* !CONFIG_PCIE_PME */ |
| 66 | static inline void pcie_pme_disable_msi(void) {} |
| 67 | static inline bool pcie_pme_no_msi(void) { return false; } |
Rafael J. Wysocki | 28eb5f2 | 2010-08-21 22:02:38 +0200 | [diff] [blame] | 68 | static inline void pcie_pme_interrupt_enable(struct pci_dev *dev, bool en) {} |
Rafael J. Wysocki | c39fae1 | 2010-02-17 23:40:07 +0100 | [diff] [blame] | 69 | #endif /* !CONFIG_PCIE_PME */ |
| 70 | |
Rafael J. Wysocki | 28eb5f2 | 2010-08-21 22:02:38 +0200 | [diff] [blame] | 71 | #ifdef CONFIG_ACPI |
Jon Derrick | 88a97da | 2016-04-08 11:35:51 -0600 | [diff] [blame] | 72 | void pcie_port_acpi_setup(struct pci_dev *port, int *mask); |
Rafael J. Wysocki | 28eb5f2 | 2010-08-21 22:02:38 +0200 | [diff] [blame] | 73 | |
Jon Derrick | 88a97da | 2016-04-08 11:35:51 -0600 | [diff] [blame] | 74 | static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask) |
Rafael J. Wysocki | 28eb5f2 | 2010-08-21 22:02:38 +0200 | [diff] [blame] | 75 | { |
Jon Derrick | 88a97da | 2016-04-08 11:35:51 -0600 | [diff] [blame] | 76 | pcie_port_acpi_setup(port, mask); |
Rafael J. Wysocki | 28eb5f2 | 2010-08-21 22:02:38 +0200 | [diff] [blame] | 77 | } |
| 78 | #else /* !CONFIG_ACPI */ |
Jon Derrick | 88a97da | 2016-04-08 11:35:51 -0600 | [diff] [blame] | 79 | static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask){} |
Rafael J. Wysocki | 28eb5f2 | 2010-08-21 22:02:38 +0200 | [diff] [blame] | 80 | #endif /* !CONFIG_ACPI */ |
| 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #endif /* _PORTDRV_H_ */ |