blob: ec2e1eb1bacca1fa40aca8088e0c0cdc535b7e95 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * File: pcieport_if.h
3 * Purpose: PCI Express Port Bus Driver's IF Data Structure
4 *
5 * Copyright (C) 2004 Intel
6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
7 */
8
9#ifndef _PCIEPORT_IF_H_
10#define _PCIEPORT_IF_H_
11
12/* Port Type */
13#define PCIE_RC_PORT 4 /* Root port of RC */
14#define PCIE_SW_UPSTREAM_PORT 5 /* Upstream port of Switch */
15#define PCIE_SW_DOWNSTREAM_PORT 6 /* Downstream port of Switch */
16#define PCIE_ANY_PORT 7
17
18/* Service Type */
Rafael J. Wysockib43d4512009-01-24 00:23:22 +010019#define PCIE_PORT_SERVICE_PME_SHIFT 0 /* Power Management Event */
20#define PCIE_PORT_SERVICE_PME (1 << PCIE_PORT_SERVICE_PME_SHIFT)
21#define PCIE_PORT_SERVICE_AER_SHIFT 1 /* Advanced Error Reporting */
22#define PCIE_PORT_SERVICE_AER (1 << PCIE_PORT_SERVICE_AER_SHIFT)
23#define PCIE_PORT_SERVICE_HP_SHIFT 2 /* Native Hotplug */
24#define PCIE_PORT_SERVICE_HP (1 << PCIE_PORT_SERVICE_HP_SHIFT)
25#define PCIE_PORT_SERVICE_VC_SHIFT 3 /* Virtual Channel */
26#define PCIE_PORT_SERVICE_VC (1 << PCIE_PORT_SERVICE_VC_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Rafael J. Wysocki22106362009-01-13 14:46:46 +010028struct pcie_port_data {
29 int port_type; /* Type of the port */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030};
31
32struct pcie_device {
33 int irq; /* Service IRQ/MSI/MSI-X Vector */
Rafael J. Wysocki22106362009-01-13 14:46:46 +010034 struct pci_dev *port; /* Root/Upstream/Downstream Port */
35 u32 service; /* Port service this device represents */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 void *priv_data; /* Service Private Data */
37 struct device device; /* Generic Device Interface */
38};
39#define to_pcie_device(d) container_of(d, struct pcie_device, device)
40
41static inline void set_service_data(struct pcie_device *dev, void *data)
42{
43 dev->priv_data = data;
44}
45
46static inline void* get_service_data(struct pcie_device *dev)
47{
48 return dev->priv_data;
49}
50
51struct pcie_port_service_driver {
52 const char *name;
Rafael J. Wysocki0516c8b2009-01-13 14:44:19 +010053 int (*probe) (struct pcie_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 void (*remove) (struct pcie_device *dev);
Rafael J. Wysocki3a3c2442009-02-15 22:32:48 +010055 int (*suspend) (struct pcie_device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 int (*resume) (struct pcie_device *dev);
57
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080058 /* Service Error Recovery Handler */
59 struct pci_error_handlers *err_handler;
60
61 /* Link Reset Capability - AER service driver specific */
62 pci_ers_result_t (*reset_link) (struct pci_dev *dev);
63
Rafael J. Wysocki22106362009-01-13 14:46:46 +010064 int port_type; /* Type of the port this driver can handle */
65 u32 service; /* Port service this device represents */
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 struct device_driver driver;
68};
69#define to_service_driver(d) \
70 container_of(d, struct pcie_port_service_driver, driver)
71
72extern int pcie_port_service_register(struct pcie_port_service_driver *new);
73extern void pcie_port_service_unregister(struct pcie_port_service_driver *new);
74
75#endif /* _PCIEPORT_IF_H_ */