blob: a854bc56911740684cd0df2b25a64ca32164beb4 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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 Morton3ec6a8d2006-09-25 16:52:20 -070013#include <linux/compiler.h>
14
Keith Busch10126ac2016-05-02 15:10:31 -050015#define PCIE_PORT_DEVICE_MAXSERVICES 5
Rafael J. Wysockib43d4512009-01-24 00:23:22 +010016/*
Gabriele Paolonia1d5f182017-05-23 15:23:58 +010017 * 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. Wysockib43d4512009-01-24 00:23:22 +010020 */
Gabriele Paolonia1d5f182017-05-23 15:23:58 +010021#define PCIE_PORT_MAX_MSI_ENTRIES 32
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Keith Busch6d814172016-05-03 09:58:11 -050023#define get_descriptor_id(type, service) (((type - 4) << 8) | service)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25extern struct bus_type pcie_port_bus_type;
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060026int pcie_port_device_register(struct pci_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#ifdef CONFIG_PM
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060028int pcie_port_device_suspend(struct device *dev);
29int pcie_port_device_resume(struct device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#endif
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060031void pcie_port_device_remove(struct pci_dev *dev);
32int __must_check pcie_port_bus_register(void);
33void pcie_port_bus_unregister(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020035struct pci_dev;
36
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060037void pcie_clear_root_pme_status(struct pci_dev *dev);
Rafael J. Wysockife31e692010-12-19 15:57:16 +010038
MUNEDA Takahiro7570a332012-02-02 11:09:22 -050039#ifdef CONFIG_HOTPLUG_PCI_PCIE
40extern bool pciehp_msi_disabled;
41
42static inline bool pciehp_no_msi(void)
43{
44 return pciehp_msi_disabled;
45}
46
47#else /* !CONFIG_HOTPLUG_PCI_PCIE */
48static inline bool pciehp_no_msi(void) { return false; }
49#endif /* !CONFIG_HOTPLUG_PCI_PCIE */
50
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010051#ifdef CONFIG_PCIE_PME
52extern bool pcie_pme_msi_disabled;
53
54static inline void pcie_pme_disable_msi(void)
55{
56 pcie_pme_msi_disabled = true;
57}
58
59static inline bool pcie_pme_no_msi(void)
60{
61 return pcie_pme_msi_disabled;
62}
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020063
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060064void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable);
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010065#else /* !CONFIG_PCIE_PME */
66static inline void pcie_pme_disable_msi(void) {}
67static inline bool pcie_pme_no_msi(void) { return false; }
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020068static inline void pcie_pme_interrupt_enable(struct pci_dev *dev, bool en) {}
Rafael J. Wysockic39fae12010-02-17 23:40:07 +010069#endif /* !CONFIG_PCIE_PME */
70
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020071#ifdef CONFIG_ACPI
Jon Derrick88a97da2016-04-08 11:35:51 -060072void pcie_port_acpi_setup(struct pci_dev *port, int *mask);
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020073
Jon Derrick88a97da2016-04-08 11:35:51 -060074static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask)
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020075{
Jon Derrick88a97da2016-04-08 11:35:51 -060076 pcie_port_acpi_setup(port, mask);
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020077}
78#else /* !CONFIG_ACPI */
Jon Derrick88a97da2016-04-08 11:35:51 -060079static inline void pcie_port_platform_notify(struct pci_dev *port, int *mask){}
Rafael J. Wysocki28eb5f22010-08-21 22:02:38 +020080#endif /* !CONFIG_ACPI */
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#endif /* _PORTDRV_H_ */