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