2 * PCI Endpoint *Function* (EPF) header file
4 * Copyright (C) 2017 Texas Instruments
5 * Author: Kishon Vijay Abraham I <kishon@ti.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 of
9 * the License as published by the Free Software Foundation.
12 #ifndef __LINUX_PCI_EPF_H
13 #define __LINUX_PCI_EPF_H
15 #include <linux/device.h>
16 #include <linux/mod_devicetable.h>
20 enum pci_interrupt_pin
{
21 PCI_INTERRUPT_UNKNOWN
,
38 * struct pci_epf_header - represents standard configuration header
39 * @vendorid: identifies device manufacturer
40 * @deviceid: identifies a particular device
41 * @revid: specifies a device-specific revision identifier
42 * @progif_code: identifies a specific register-level programming interface
43 * @subclass_code: identifies more specifically the function of the device
44 * @baseclass_code: broadly classifies the type of function the device performs
45 * @cache_line_size: specifies the system cacheline size in units of DWORDs
46 * @subsys_vendor_id: vendor of the add-in card or subsystem
47 * @subsys_id: id specific to vendor
48 * @interrupt_pin: interrupt pin the device (or device function) uses
50 struct pci_epf_header
{
60 enum pci_interrupt_pin interrupt_pin
;
64 * struct pci_epf_ops - set of function pointers for performing EPF operations
65 * @bind: ops to perform when a EPC device has been bound to EPF device
66 * @unbind: ops to perform when a binding has been lost between a EPC device
68 * @linkup: ops to perform when the EPC device has established a connection with
72 int (*bind
)(struct pci_epf
*epf
);
73 void (*unbind
)(struct pci_epf
*epf
);
74 void (*linkup
)(struct pci_epf
*epf
);
78 * struct pci_epf_driver - represents the PCI EPF driver
79 * @probe: ops to perform when a new EPF device has been bound to the EPF driver
80 * @remove: ops to perform when the binding between the EPF device and EPF
82 * @driver: PCI EPF driver
83 * @ops: set of function pointers for performing EPF operations
84 * @owner: the owner of the module that registers the PCI EPF driver
85 * @group: configfs group corresponding to the PCI EPF driver
86 * @id_table: identifies EPF devices for probing
88 struct pci_epf_driver
{
89 int (*probe
)(struct pci_epf
*epf
);
90 int (*remove
)(struct pci_epf
*epf
);
92 struct device_driver driver
;
93 struct pci_epf_ops
*ops
;
95 struct config_group
*group
;
96 const struct pci_epf_device_id
*id_table
;
99 #define to_pci_epf_driver(drv) (container_of((drv), struct pci_epf_driver, \
103 * struct pci_epf_bar - represents the BAR of EPF device
104 * @phys_addr: physical address that should be mapped to the BAR
105 * @size: the size of the address space present in BAR
108 dma_addr_t phys_addr
;
113 * struct pci_epf - represents the PCI EPF device
114 * @dev: the PCI EPF device
115 * @name: the name of the PCI EPF device
116 * @header: represents standard configuration header
117 * @bar: represents the BAR of EPF device
118 * @msi_interrupts: number of MSI interrupts required by this function
119 * @func_no: unique function number within this endpoint device
120 * @epc: the EPC device to which this EPF device is bound
121 * @driver: the EPF driver to which this EPF device is bound
122 * @list: to add pci_epf as a list of PCI endpoint functions to pci_epc
127 struct pci_epf_header
*header
;
128 struct pci_epf_bar bar
[6];
133 struct pci_epf_driver
*driver
;
134 struct list_head list
;
137 #define to_pci_epf(epf_dev) container_of((epf_dev), struct pci_epf, dev)
139 #define pci_epf_register_driver(driver) \
140 __pci_epf_register_driver((driver), THIS_MODULE)
142 static inline void epf_set_drvdata(struct pci_epf
*epf
, void *data
)
144 dev_set_drvdata(&epf
->dev
, data
);
147 static inline void *epf_get_drvdata(struct pci_epf
*epf
)
149 return dev_get_drvdata(&epf
->dev
);
152 struct pci_epf
*pci_epf_create(const char *name
);
153 void pci_epf_destroy(struct pci_epf
*epf
);
154 int __pci_epf_register_driver(struct pci_epf_driver
*driver
,
155 struct module
*owner
);
156 void pci_epf_unregister_driver(struct pci_epf_driver
*driver
);
157 void *pci_epf_alloc_space(struct pci_epf
*epf
, size_t size
, enum pci_barno bar
);
158 void pci_epf_free_space(struct pci_epf
*epf
, void *addr
, enum pci_barno bar
);
159 int pci_epf_bind(struct pci_epf
*epf
);
160 void pci_epf_unbind(struct pci_epf
*epf
);
161 void pci_epf_linkup(struct pci_epf
*epf
);
162 #endif /* __LINUX_PCI_EPF_H */