xref: /openbmc/linux/include/linux/fpga/fpga-region.h (revision 3ac14b39)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef _FPGA_REGION_H
4 #define _FPGA_REGION_H
5 
6 #include <linux/device.h>
7 #include <linux/fpga/fpga-mgr.h>
8 #include <linux/fpga/fpga-bridge.h>
9 
10 /**
11  * struct fpga_region - FPGA Region structure
12  * @dev: FPGA Region device
13  * @mutex: enforces exclusive reference to region
14  * @bridge_list: list of FPGA bridges specified in region
15  * @mgr: FPGA manager
16  * @info: FPGA image info
17  * @priv: private data
18  * @get_bridges: optional function to get bridges to a list
19  */
20 struct fpga_region {
21 	struct device dev;
22 	struct mutex mutex; /* for exclusive reference to region */
23 	struct list_head bridge_list;
24 	struct fpga_manager *mgr;
25 	struct fpga_image_info *info;
26 	void *priv;
27 	int (*get_bridges)(struct fpga_region *region);
28 };
29 
30 #define to_fpga_region(d) container_of(d, struct fpga_region, dev)
31 
32 struct fpga_region *fpga_region_class_find(
33 	struct device *start, const void *data,
34 	int (*match)(struct device *, const void *));
35 
36 int fpga_region_program_fpga(struct fpga_region *region);
37 
38 struct fpga_region
39 *fpga_region_create(struct device *dev, struct fpga_manager *mgr,
40 		    int (*get_bridges)(struct fpga_region *));
41 void fpga_region_free(struct fpga_region *region);
42 int fpga_region_register(struct fpga_region *region);
43 void fpga_region_unregister(struct fpga_region *region);
44 
45 #endif /* _FPGA_REGION_H */
46