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: pcieport_if.h |
| 4 | * Purpose: PCI Express Port Bus Driver's IF Data Structure |
| 5 | * |
| 6 | * Copyright (C) 2004 Intel |
| 7 | * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) |
| 8 | */ |
| 9 | |
| 10 | #ifndef _PCIEPORT_IF_H_ |
| 11 | #define _PCIEPORT_IF_H_ |
| 12 | |
| 13 | /* Port Type */ |
Kenji Kaneshige | 694f88e | 2009-11-25 21:06:15 +0900 | [diff] [blame] | 14 | #define PCIE_ANY_PORT (~0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | /* Service Type */ |
Rafael J. Wysocki | b43d451 | 2009-01-24 00:23:22 +0100 | [diff] [blame] | 17 | #define PCIE_PORT_SERVICE_PME_SHIFT 0 /* Power Management Event */ |
| 18 | #define PCIE_PORT_SERVICE_PME (1 << PCIE_PORT_SERVICE_PME_SHIFT) |
| 19 | #define PCIE_PORT_SERVICE_AER_SHIFT 1 /* Advanced Error Reporting */ |
| 20 | #define PCIE_PORT_SERVICE_AER (1 << PCIE_PORT_SERVICE_AER_SHIFT) |
| 21 | #define PCIE_PORT_SERVICE_HP_SHIFT 2 /* Native Hotplug */ |
| 22 | #define PCIE_PORT_SERVICE_HP (1 << PCIE_PORT_SERVICE_HP_SHIFT) |
| 23 | #define PCIE_PORT_SERVICE_VC_SHIFT 3 /* Virtual Channel */ |
| 24 | #define PCIE_PORT_SERVICE_VC (1 << PCIE_PORT_SERVICE_VC_SHIFT) |
Keith Busch | 10126ac | 2016-05-02 15:10:31 -0500 | [diff] [blame] | 25 | #define PCIE_PORT_SERVICE_DPC_SHIFT 4 /* Downstream Port Containment */ |
| 26 | #define PCIE_PORT_SERVICE_DPC (1 << PCIE_PORT_SERVICE_DPC_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | struct pcie_device { |
Bjorn Helgaas | f762598 | 2013-11-14 11:28:18 -0700 | [diff] [blame] | 29 | int irq; /* Service IRQ/MSI/MSI-X Vector */ |
Rafael J. Wysocki | 2210636 | 2009-01-13 14:46:46 +0100 | [diff] [blame] | 30 | struct pci_dev *port; /* Root/Upstream/Downstream Port */ |
| 31 | u32 service; /* Port service this device represents */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | void *priv_data; /* Service Private Data */ |
| 33 | struct device device; /* Generic Device Interface */ |
| 34 | }; |
| 35 | #define to_pcie_device(d) container_of(d, struct pcie_device, device) |
| 36 | |
| 37 | static inline void set_service_data(struct pcie_device *dev, void *data) |
| 38 | { |
| 39 | dev->priv_data = data; |
| 40 | } |
| 41 | |
Bjorn Helgaas | 96291d5 | 2017-09-01 16:35:50 -0500 | [diff] [blame] | 42 | static inline void *get_service_data(struct pcie_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | { |
| 44 | return dev->priv_data; |
| 45 | } |
| 46 | |
| 47 | struct pcie_port_service_driver { |
| 48 | const char *name; |
Rafael J. Wysocki | 0516c8b | 2009-01-13 14:44:19 +0100 | [diff] [blame] | 49 | int (*probe) (struct pcie_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | void (*remove) (struct pcie_device *dev); |
Rafael J. Wysocki | 3a3c244 | 2009-02-15 22:32:48 +0100 | [diff] [blame] | 51 | int (*suspend) (struct pcie_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | int (*resume) (struct pcie_device *dev); |
| 53 | |
Christoph Hellwig | c5dc3c6 | 2017-06-19 20:04:58 +0200 | [diff] [blame] | 54 | /* Device driver may resume normal operations */ |
| 55 | void (*error_resume)(struct pci_dev *dev); |
Zhang, Yanmin | 6c2b374 | 2006-07-31 15:21:33 +0800 | [diff] [blame] | 56 | |
| 57 | /* Link Reset Capability - AER service driver specific */ |
| 58 | pci_ers_result_t (*reset_link) (struct pci_dev *dev); |
| 59 | |
Rafael J. Wysocki | 2210636 | 2009-01-13 14:46:46 +0100 | [diff] [blame] | 60 | int port_type; /* Type of the port this driver can handle */ |
| 61 | u32 service; /* Port service this device represents */ |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | struct device_driver driver; |
| 64 | }; |
| 65 | #define to_service_driver(d) \ |
| 66 | container_of(d, struct pcie_port_service_driver, driver) |
| 67 | |
Bjorn Helgaas | f39d5b7 | 2013-04-12 12:02:59 -0600 | [diff] [blame] | 68 | int pcie_port_service_register(struct pcie_port_service_driver *new); |
| 69 | void pcie_port_service_unregister(struct pcie_port_service_driver *new); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | #endif /* _PCIEPORT_IF_H_ */ |