fpga-bridge.h 2.2 KB

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