blob: 4334fd5d7de9e7d9984d91addab3d1bfe4cab741 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * File: portdrv.h
3 * Purpose: PCI Express Port Bus Driver's Internal Data Structures
4 *
5 * Copyright (C) 2004 Intel
6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
7 */
8
9#ifndef _PORTDRV_H_
10#define _PORTDRV_H_
11
Andrew Morton3ec6a8d2006-09-25 16:52:20 -070012#include <linux/compiler.h>
13
Keith Busch10126ac2016-05-02 15:10:31 -050014#define PCIE_PORT_DEVICE_MAXSERVICES 5
Rafael J. Wysockib43d4512009-01-24 00:23:22 +010015/*
Gabriele Paolonia1d5f182017-05-23 15:23:58 +010016 * The PCIe Capability Interrupt Message Number (PCIe r3.1, sec 7.8.2) must
17 * be one of the first 32 MSI-X entries. Per PCI r3.0, sec 6.8.3.1, MSI
18 * supports a maximum of 32 vectors per function.
Rafael J. Wysockib43d4512009-01-24 00:23:22 +010019 */
Gabriele Paolonia1d5f182017-05-23 15:23:58 +010020#define PCIE_PORT_MAX_MSI_ENTRIES 32
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Keith Busch6d814172016-05-03 09:58:11 -050022#define get_descriptor_id(type, service) (((type - 4) << 8) | service)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24extern struct bus_type pcie_port_bus_type;
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060025int pcie_port_device_register(struct pci_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#ifdef CONFIG_PM
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060027int pcie_port_device_suspend(struct device *dev);
28int pcie_port_device_resume(struct device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#endif
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060030void pcie_port_device_remove(struct pci_dev *dev);
31int __must_check pcie_port_bus_register(void);
32void pcie_port_bus_unregister(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020034struct pci_dev;
35
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060036void pcie_clear_root_pme_status(struct pci_dev *dev);
Rafael J. Wysockife31e692010-12-19 15:57:16 +010037
MUNEDA Takahiro7570a332012-02-02 11:09:22 -050038#ifdef CONFIG_HOTPLUG_PCI_PCIE
39extern bool pciehp_msi_disabled;
40
41static inline bool pciehp_no_msi(void)
42{
43 return pciehp_msi_disabled;
44}
45
46#else /* !CONFIG_HOTPLUG_PCI_PCIE */
47static inline bool pciehp_no_msi(void) { return false; }
48#endif /* !CONFIG_HOTPLUG_PCI_PCIE */
49
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010050#ifdef CONFIG_PCIE_PME
51extern bool pcie_pme_msi_disabled;
52
53static inline void pcie_pme_disable_msi(void)
54{
55 pcie_pme_msi_disabled = true;
56}
57
58static inline bool pcie_pme_no_msi(void)
59{
60 return pcie_pme_msi_disabled;
61}
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020062
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060063void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable);
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010064#else /* !CONFIG_PCIE_PME */
65static inline void pcie_pme_disable_msi(void) {}
66static inline bool pcie_pme_no_msi(void) { return false; }
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020067static inline void pcie_pme_interrupt_enable(struct pci_dev *dev, bool en) {}
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010068#endif /* !CONFIG_PCIE_PME */
69
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020070#ifdef CONFIG_ACPI
Jon Derrick88a97da2016-04-08 11:35:51 -060071void pcie_port_acpi_setup(struct pci_dev *port, int *mask);
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020072
Jon Derrick88a97da2016-04-08 11:35:51 -060073static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask)
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020074{
Jon Derrick88a97da2016-04-08 11:35:51 -060075 pcie_port_acpi_setup(port, mask);
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020076}
77#else /* !CONFIG_ACPI */
Jon Derrick88a97da2016-04-08 11:35:51 -060078static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask){}
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020079#endif /* !CONFIG_ACPI */
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#endif /* _PORTDRV_H_ */