Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Alan Tull | 21aeda9 | 2016-11-01 14:14:28 -0500 | [diff] [blame] | 2 | |
| 3 | #ifndef _LINUX_FPGA_BRIDGE_H |
| 4 | #define _LINUX_FPGA_BRIDGE_H |
| 5 | |
Alan Tull | 9c1c4b2 | 2017-11-15 14:20:11 -0600 | [diff] [blame] | 6 | #include <linux/device.h> |
| 7 | #include <linux/fpga/fpga-mgr.h> |
| 8 | |
Alan Tull | 21aeda9 | 2016-11-01 14:14:28 -0500 | [diff] [blame] | 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 |
Alan Tull | 845089b | 2017-11-15 14:20:28 -0600 | [diff] [blame] | 16 | * @groups: optional attribute groups. |
Alan Tull | 21aeda9 | 2016-11-01 14:14:28 -0500 | [diff] [blame] | 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); |
Alan Tull | 845089b | 2017-11-15 14:20:28 -0600 | [diff] [blame] | 22 | const struct attribute_group **groups; |
Alan Tull | 21aeda9 | 2016-11-01 14:14:28 -0500 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | /** |
| 26 | * struct fpga_bridge - FPGA bridge structure |
| 27 | * @name: name of low level FPGA bridge |
| 28 | * @dev: FPGA bridge device |
| 29 | * @mutex: enforces exclusive reference to bridge |
| 30 | * @br_ops: pointer to struct of FPGA bridge ops |
| 31 | * @info: fpga image specific information |
| 32 | * @node: FPGA bridge list node |
| 33 | * @priv: low level driver private date |
| 34 | */ |
| 35 | struct fpga_bridge { |
| 36 | const char *name; |
| 37 | struct device dev; |
| 38 | struct mutex mutex; /* for exclusive reference to bridge */ |
| 39 | const struct fpga_bridge_ops *br_ops; |
| 40 | struct fpga_image_info *info; |
| 41 | struct list_head node; |
| 42 | void *priv; |
| 43 | }; |
| 44 | |
| 45 | #define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev) |
| 46 | |
| 47 | struct fpga_bridge *of_fpga_bridge_get(struct device_node *node, |
| 48 | struct fpga_image_info *info); |
Alan Tull | 9c1c4b2 | 2017-11-15 14:20:11 -0600 | [diff] [blame] | 49 | struct fpga_bridge *fpga_bridge_get(struct device *dev, |
| 50 | struct fpga_image_info *info); |
Alan Tull | 21aeda9 | 2016-11-01 14:14:28 -0500 | [diff] [blame] | 51 | void fpga_bridge_put(struct fpga_bridge *bridge); |
| 52 | int fpga_bridge_enable(struct fpga_bridge *bridge); |
| 53 | int fpga_bridge_disable(struct fpga_bridge *bridge); |
| 54 | |
| 55 | int fpga_bridges_enable(struct list_head *bridge_list); |
| 56 | int fpga_bridges_disable(struct list_head *bridge_list); |
| 57 | void fpga_bridges_put(struct list_head *bridge_list); |
Alan Tull | 9c1c4b2 | 2017-11-15 14:20:11 -0600 | [diff] [blame] | 58 | int fpga_bridge_get_to_list(struct device *dev, |
Alan Tull | 21aeda9 | 2016-11-01 14:14:28 -0500 | [diff] [blame] | 59 | struct fpga_image_info *info, |
| 60 | struct list_head *bridge_list); |
Alan Tull | 9c1c4b2 | 2017-11-15 14:20:11 -0600 | [diff] [blame] | 61 | int of_fpga_bridge_get_to_list(struct device_node *np, |
| 62 | struct fpga_image_info *info, |
| 63 | struct list_head *bridge_list); |
Alan Tull | 21aeda9 | 2016-11-01 14:14:28 -0500 | [diff] [blame] | 64 | |
| 65 | int fpga_bridge_register(struct device *dev, const char *name, |
| 66 | const struct fpga_bridge_ops *br_ops, void *priv); |
| 67 | void fpga_bridge_unregister(struct device *dev); |
| 68 | |
| 69 | #endif /* _LINUX_FPGA_BRIDGE_H */ |