xtensa: fix high memory/reserved memory collision
[cris-mirror.git] / include / linux / pci-epf.h
blobe897bf0767013383cc06257849e1ca27ab59a702
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /**
3 * PCI Endpoint *Function* (EPF) header file
5 * Copyright (C) 2017 Texas Instruments
6 * Author: Kishon Vijay Abraham I <kishon@ti.com>
7 */
9 #ifndef __LINUX_PCI_EPF_H
10 #define __LINUX_PCI_EPF_H
12 #include <linux/device.h>
13 #include <linux/mod_devicetable.h>
14 #include <linux/pci.h>
16 struct pci_epf;
18 enum pci_barno {
19 BAR_0,
20 BAR_1,
21 BAR_2,
22 BAR_3,
23 BAR_4,
24 BAR_5,
27 /**
28 * struct pci_epf_header - represents standard configuration header
29 * @vendorid: identifies device manufacturer
30 * @deviceid: identifies a particular device
31 * @revid: specifies a device-specific revision identifier
32 * @progif_code: identifies a specific register-level programming interface
33 * @subclass_code: identifies more specifically the function of the device
34 * @baseclass_code: broadly classifies the type of function the device performs
35 * @cache_line_size: specifies the system cacheline size in units of DWORDs
36 * @subsys_vendor_id: vendor of the add-in card or subsystem
37 * @subsys_id: id specific to vendor
38 * @interrupt_pin: interrupt pin the device (or device function) uses
40 struct pci_epf_header {
41 u16 vendorid;
42 u16 deviceid;
43 u8 revid;
44 u8 progif_code;
45 u8 subclass_code;
46 u8 baseclass_code;
47 u8 cache_line_size;
48 u16 subsys_vendor_id;
49 u16 subsys_id;
50 enum pci_interrupt_pin interrupt_pin;
53 /**
54 * struct pci_epf_ops - set of function pointers for performing EPF operations
55 * @bind: ops to perform when a EPC device has been bound to EPF device
56 * @unbind: ops to perform when a binding has been lost between a EPC device
57 * and EPF device
58 * @linkup: ops to perform when the EPC device has established a connection with
59 * a host system
61 struct pci_epf_ops {
62 int (*bind)(struct pci_epf *epf);
63 void (*unbind)(struct pci_epf *epf);
64 void (*linkup)(struct pci_epf *epf);
67 /**
68 * struct pci_epf_driver - represents the PCI EPF driver
69 * @probe: ops to perform when a new EPF device has been bound to the EPF driver
70 * @remove: ops to perform when the binding between the EPF device and EPF
71 * driver is broken
72 * @driver: PCI EPF driver
73 * @ops: set of function pointers for performing EPF operations
74 * @owner: the owner of the module that registers the PCI EPF driver
75 * @group: configfs group corresponding to the PCI EPF driver
76 * @id_table: identifies EPF devices for probing
78 struct pci_epf_driver {
79 int (*probe)(struct pci_epf *epf);
80 int (*remove)(struct pci_epf *epf);
82 struct device_driver driver;
83 struct pci_epf_ops *ops;
84 struct module *owner;
85 struct config_group *group;
86 const struct pci_epf_device_id *id_table;
89 #define to_pci_epf_driver(drv) (container_of((drv), struct pci_epf_driver, \
90 driver))
92 /**
93 * struct pci_epf_bar - represents the BAR of EPF device
94 * @phys_addr: physical address that should be mapped to the BAR
95 * @size: the size of the address space present in BAR
97 struct pci_epf_bar {
98 dma_addr_t phys_addr;
99 size_t size;
103 * struct pci_epf - represents the PCI EPF device
104 * @dev: the PCI EPF device
105 * @name: the name of the PCI EPF device
106 * @header: represents standard configuration header
107 * @bar: represents the BAR of EPF device
108 * @msi_interrupts: number of MSI interrupts required by this function
109 * @func_no: unique function number within this endpoint device
110 * @epc: the EPC device to which this EPF device is bound
111 * @driver: the EPF driver to which this EPF device is bound
112 * @list: to add pci_epf as a list of PCI endpoint functions to pci_epc
114 struct pci_epf {
115 struct device dev;
116 const char *name;
117 struct pci_epf_header *header;
118 struct pci_epf_bar bar[6];
119 u8 msi_interrupts;
120 u8 func_no;
122 struct pci_epc *epc;
123 struct pci_epf_driver *driver;
124 struct list_head list;
127 #define to_pci_epf(epf_dev) container_of((epf_dev), struct pci_epf, dev)
129 #define pci_epf_register_driver(driver) \
130 __pci_epf_register_driver((driver), THIS_MODULE)
132 static inline void epf_set_drvdata(struct pci_epf *epf, void *data)
134 dev_set_drvdata(&epf->dev, data);
137 static inline void *epf_get_drvdata(struct pci_epf *epf)
139 return dev_get_drvdata(&epf->dev);
142 const struct pci_epf_device_id *
143 pci_epf_match_device(const struct pci_epf_device_id *id, struct pci_epf *epf);
144 struct pci_epf *pci_epf_create(const char *name);
145 void pci_epf_destroy(struct pci_epf *epf);
146 int __pci_epf_register_driver(struct pci_epf_driver *driver,
147 struct module *owner);
148 void pci_epf_unregister_driver(struct pci_epf_driver *driver);
149 void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar);
150 void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar);
151 int pci_epf_bind(struct pci_epf *epf);
152 void pci_epf_unbind(struct pci_epf *epf);
153 void pci_epf_linkup(struct pci_epf *epf);
154 #endif /* __LINUX_PCI_EPF_H */