• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/device.h>
3 #include <linux/fpga/fpga-mgr.h>
4 
5 #ifndef _LINUX_FPGA_BRIDGE_H
6 #define _LINUX_FPGA_BRIDGE_H
7 
8 struct fpga_bridge;
9 
10 /**
11  * struct fpga_bridge_ops - ops for low level FPGA bridge drivers
12  * @enable_show: returns the FPGA bridge's status
13  * @enable_set: set a FPGA bridge as enabled or disabled
14  * @fpga_bridge_remove: set FPGA into a specific state during driver remove
15  */
16 struct fpga_bridge_ops {
17 	int (*enable_show)(struct fpga_bridge *bridge);
18 	int (*enable_set)(struct fpga_bridge *bridge, bool enable);
19 	void (*fpga_bridge_remove)(struct fpga_bridge *bridge);
20 };
21 
22 /**
23  * struct fpga_bridge - FPGA bridge structure
24  * @name: name of low level FPGA bridge
25  * @dev: FPGA bridge device
26  * @mutex: enforces exclusive reference to bridge
27  * @br_ops: pointer to struct of FPGA bridge ops
28  * @info: fpga image specific information
29  * @node: FPGA bridge list node
30  * @priv: low level driver private date
31  */
32 struct fpga_bridge {
33 	const char *name;
34 	struct device dev;
35 	struct mutex mutex; /* for exclusive reference to bridge */
36 	const struct fpga_bridge_ops *br_ops;
37 	struct fpga_image_info *info;
38 	struct list_head node;
39 	void *priv;
40 };
41 
42 #define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev)
43 
44 struct fpga_bridge *of_fpga_bridge_get(struct device_node *node,
45 				       struct fpga_image_info *info);
46 void fpga_bridge_put(struct fpga_bridge *bridge);
47 int fpga_bridge_enable(struct fpga_bridge *bridge);
48 int fpga_bridge_disable(struct fpga_bridge *bridge);
49 
50 int fpga_bridges_enable(struct list_head *bridge_list);
51 int fpga_bridges_disable(struct list_head *bridge_list);
52 void fpga_bridges_put(struct list_head *bridge_list);
53 int fpga_bridge_get_to_list(struct device_node *np,
54 			    struct fpga_image_info *info,
55 			    struct list_head *bridge_list);
56 
57 int fpga_bridge_register(struct device *dev, const char *name,
58 			 const struct fpga_bridge_ops *br_ops, void *priv);
59 void fpga_bridge_unregister(struct device *dev);
60 
61 #endif /* _LINUX_FPGA_BRIDGE_H */
62