Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 #ifndef _LINUX_FPGA_BRIDGE_H
0004 #define _LINUX_FPGA_BRIDGE_H
0005 
0006 #include <linux/device.h>
0007 #include <linux/fpga/fpga-mgr.h>
0008 
0009 struct fpga_bridge;
0010 
0011 /**
0012  * struct fpga_bridge_ops - ops for low level FPGA bridge drivers
0013  * @enable_show: returns the FPGA bridge's status
0014  * @enable_set: set an FPGA bridge as enabled or disabled
0015  * @fpga_bridge_remove: set FPGA into a specific state during driver remove
0016  * @groups: optional attribute groups.
0017  */
0018 struct fpga_bridge_ops {
0019     int (*enable_show)(struct fpga_bridge *bridge);
0020     int (*enable_set)(struct fpga_bridge *bridge, bool enable);
0021     void (*fpga_bridge_remove)(struct fpga_bridge *bridge);
0022     const struct attribute_group **groups;
0023 };
0024 
0025 /**
0026  * struct fpga_bridge_info - collection of parameters an FPGA Bridge
0027  * @name: fpga bridge name
0028  * @br_ops: pointer to structure of fpga bridge ops
0029  * @priv: fpga bridge private data
0030  *
0031  * fpga_bridge_info contains parameters for the register function. These
0032  * are separated into an info structure because they some are optional
0033  * others could be added to in the future. The info structure facilitates
0034  * maintaining a stable API.
0035  */
0036 struct fpga_bridge_info {
0037     const char *name;
0038     const struct fpga_bridge_ops *br_ops;
0039     void *priv;
0040 };
0041 
0042 /**
0043  * struct fpga_bridge - FPGA bridge structure
0044  * @name: name of low level FPGA bridge
0045  * @dev: FPGA bridge device
0046  * @mutex: enforces exclusive reference to bridge
0047  * @br_ops: pointer to struct of FPGA bridge ops
0048  * @info: fpga image specific information
0049  * @node: FPGA bridge list node
0050  * @priv: low level driver private date
0051  */
0052 struct fpga_bridge {
0053     const char *name;
0054     struct device dev;
0055     struct mutex mutex; /* for exclusive reference to bridge */
0056     const struct fpga_bridge_ops *br_ops;
0057     struct fpga_image_info *info;
0058     struct list_head node;
0059     void *priv;
0060 };
0061 
0062 #define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev)
0063 
0064 struct fpga_bridge *of_fpga_bridge_get(struct device_node *node,
0065                        struct fpga_image_info *info);
0066 struct fpga_bridge *fpga_bridge_get(struct device *dev,
0067                     struct fpga_image_info *info);
0068 void fpga_bridge_put(struct fpga_bridge *bridge);
0069 int fpga_bridge_enable(struct fpga_bridge *bridge);
0070 int fpga_bridge_disable(struct fpga_bridge *bridge);
0071 
0072 int fpga_bridges_enable(struct list_head *bridge_list);
0073 int fpga_bridges_disable(struct list_head *bridge_list);
0074 void fpga_bridges_put(struct list_head *bridge_list);
0075 int fpga_bridge_get_to_list(struct device *dev,
0076                 struct fpga_image_info *info,
0077                 struct list_head *bridge_list);
0078 int of_fpga_bridge_get_to_list(struct device_node *np,
0079                    struct fpga_image_info *info,
0080                    struct list_head *bridge_list);
0081 
0082 struct fpga_bridge *
0083 fpga_bridge_register(struct device *parent, const char *name,
0084              const struct fpga_bridge_ops *br_ops,
0085              void *priv);
0086 void fpga_bridge_unregister(struct fpga_bridge *br);
0087 
0088 #endif /* _LINUX_FPGA_BRIDGE_H */