blob: 587aef36030dbbabe591b7dc98c3f5f16f75f378 [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/*
Kenji Kaneshigef9f45602009-11-25 21:06:51 +090016 * According to the PCI Express Base Specification 2.0, the indices of
Bjorn Helgaasf7625982013-11-14 11:28:18 -070017 * the MSI-X table entries used by port services must not exceed 31
Rafael J. Wysockib43d4512009-01-24 00:23:22 +010018 */
19#define PCIE_PORT_MAX_MSIX_ENTRIES 32
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Keith Busch6d814172016-05-03 09:58:11 -050021#define get_descriptor_id(type, service) (((type - 4) << 8) | service)
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23extern struct bus_type pcie_port_bus_type;
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060024int pcie_port_device_register(struct pci_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#ifdef CONFIG_PM
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060026int pcie_port_device_suspend(struct device *dev);
27int pcie_port_device_resume(struct device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#endif
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060029void pcie_port_device_remove(struct pci_dev *dev);
30int __must_check pcie_port_bus_register(void);
31void pcie_port_bus_unregister(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020033struct pci_dev;
34
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060035void pcie_clear_root_pme_status(struct pci_dev *dev);
Rafael J. Wysockife31e692010-12-19 15:57:16 +010036
MUNEDA Takahiro7570a332012-02-02 11:09:22 -050037#ifdef CONFIG_HOTPLUG_PCI_PCIE
38extern bool pciehp_msi_disabled;
39
40static inline bool pciehp_no_msi(void)
41{
42 return pciehp_msi_disabled;
43}
44
45#else /* !CONFIG_HOTPLUG_PCI_PCIE */
46static inline bool pciehp_no_msi(void) { return false; }
47#endif /* !CONFIG_HOTPLUG_PCI_PCIE */
48
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010049#ifdef CONFIG_PCIE_PME
50extern bool pcie_pme_msi_disabled;
51
52static inline void pcie_pme_disable_msi(void)
53{
54 pcie_pme_msi_disabled = true;
55}
56
57static inline bool pcie_pme_no_msi(void)
58{
59 return pcie_pme_msi_disabled;
60}
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020061
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060062void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable);
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010063#else /* !CONFIG_PCIE_PME */
64static inline void pcie_pme_disable_msi(void) {}
65static inline bool pcie_pme_no_msi(void) { return false; }
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020066static inline void pcie_pme_interrupt_enable(struct pci_dev *dev, bool en) {}
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010067#endif /* !CONFIG_PCIE_PME */
68
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020069#ifdef CONFIG_ACPI
Jon Derrick88a97da2016-04-08 11:35:51 -060070void pcie_port_acpi_setup(struct pci_dev *port, int *mask);
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020071
Jon Derrick88a97da2016-04-08 11:35:51 -060072static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask)
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020073{
Jon Derrick88a97da2016-04-08 11:35:51 -060074 pcie_port_acpi_setup(port, mask);
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020075}
76#else /* !CONFIG_ACPI */
Jon Derrick88a97da2016-04-08 11:35:51 -060077static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask){}
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020078#endif /* !CONFIG_ACPI */
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#endif /* _PORTDRV_H_ */