Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
21aeda95 AT |
2 | |
3 | #ifndef _LINUX_FPGA_BRIDGE_H | |
4 | #define _LINUX_FPGA_BRIDGE_H | |
5 | ||
9c1c4b27 AT |
6 | #include <linux/device.h> |
7 | #include <linux/fpga/fpga-mgr.h> | |
8 | ||
21aeda95 AT |
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 | |
e7555cf6 | 14 | * @enable_set: set an FPGA bridge as enabled or disabled |
21aeda95 | 15 | * @fpga_bridge_remove: set FPGA into a specific state during driver remove |
845089bb | 16 | * @groups: optional attribute groups. |
21aeda95 AT |
17 | */ |
18 | struct fpga_bridge_ops { | |
19 | int (*enable_show)(struct fpga_bridge *bridge); | |
20 | int (*enable_set)(struct fpga_bridge *bridge, bool enable); | |
21 | void (*fpga_bridge_remove)(struct fpga_bridge *bridge); | |
845089bb | 22 | const struct attribute_group **groups; |
21aeda95 AT |
23 | }; |
24 | ||
0d70af3c RW |
25 | /** |
26 | * struct fpga_bridge_info - collection of parameters an FPGA Bridge | |
27 | * @name: fpga bridge name | |
28 | * @br_ops: pointer to structure of fpga bridge ops | |
29 | * @priv: fpga bridge private data | |
30 | * | |
31 | * fpga_bridge_info contains parameters for the register function. These | |
32 | * are separated into an info structure because they some are optional | |
33 | * others could be added to in the future. The info structure facilitates | |
34 | * maintaining a stable API. | |
35 | */ | |
36 | struct fpga_bridge_info { | |
37 | const char *name; | |
38 | const struct fpga_bridge_ops *br_ops; | |
39 | void *priv; | |
40 | }; | |
41 | ||
21aeda95 AT |
42 | /** |
43 | * struct fpga_bridge - FPGA bridge structure | |
44 | * @name: name of low level FPGA bridge | |
45 | * @dev: FPGA bridge device | |
46 | * @mutex: enforces exclusive reference to bridge | |
47 | * @br_ops: pointer to struct of FPGA bridge ops | |
1da11f82 | 48 | * @br_ops_owner: module containing the br_ops |
21aeda95 AT |
49 | * @info: fpga image specific information |
50 | * @node: FPGA bridge list node | |
51 | * @priv: low level driver private date | |
52 | */ | |
53 | struct fpga_bridge { | |
54 | const char *name; | |
55 | struct device dev; | |
56 | struct mutex mutex; /* for exclusive reference to bridge */ | |
57 | const struct fpga_bridge_ops *br_ops; | |
1da11f82 | 58 | struct module *br_ops_owner; |
21aeda95 AT |
59 | struct fpga_image_info *info; |
60 | struct list_head node; | |
61 | void *priv; | |
62 | }; | |
63 | ||
64 | #define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev) | |
65 | ||
66 | struct fpga_bridge *of_fpga_bridge_get(struct device_node *node, | |
67 | struct fpga_image_info *info); | |
9c1c4b27 AT |
68 | struct fpga_bridge *fpga_bridge_get(struct device *dev, |
69 | struct fpga_image_info *info); | |
21aeda95 AT |
70 | void fpga_bridge_put(struct fpga_bridge *bridge); |
71 | int fpga_bridge_enable(struct fpga_bridge *bridge); | |
72 | int fpga_bridge_disable(struct fpga_bridge *bridge); | |
73 | ||
74 | int fpga_bridges_enable(struct list_head *bridge_list); | |
75 | int fpga_bridges_disable(struct list_head *bridge_list); | |
76 | void fpga_bridges_put(struct list_head *bridge_list); | |
9c1c4b27 | 77 | int fpga_bridge_get_to_list(struct device *dev, |
21aeda95 AT |
78 | struct fpga_image_info *info, |
79 | struct list_head *bridge_list); | |
9c1c4b27 AT |
80 | int of_fpga_bridge_get_to_list(struct device_node *np, |
81 | struct fpga_image_info *info, | |
82 | struct list_head *bridge_list); | |
21aeda95 | 83 | |
1da11f82 MP |
84 | #define fpga_bridge_register(parent, name, br_ops, priv) \ |
85 | __fpga_bridge_register(parent, name, br_ops, priv, THIS_MODULE) | |
0d70af3c | 86 | struct fpga_bridge * |
1da11f82 MP |
87 | __fpga_bridge_register(struct device *parent, const char *name, |
88 | const struct fpga_bridge_ops *br_ops, void *priv, | |
89 | struct module *owner); | |
371cd1b1 | 90 | void fpga_bridge_unregister(struct fpga_bridge *br); |
21aeda95 AT |
91 | |
92 | #endif /* _LINUX_FPGA_BRIDGE_H */ |