fpga-bridge.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * @groups: optional attribute groups.
  13. */
  14. struct fpga_bridge_ops {
  15. int (*enable_show)(struct fpga_bridge *bridge);
  16. int (*enable_set)(struct fpga_bridge *bridge, bool enable);
  17. void (*fpga_bridge_remove)(struct fpga_bridge *bridge);
  18. const struct attribute_group **groups;
  19. };
  20. /**
  21. * struct fpga_bridge - FPGA bridge structure
  22. * @name: name of low level FPGA bridge
  23. * @dev: FPGA bridge device
  24. * @mutex: enforces exclusive reference to bridge
  25. * @br_ops: pointer to struct of FPGA bridge ops
  26. * @info: fpga image specific information
  27. * @node: FPGA bridge list node
  28. * @priv: low level driver private date
  29. */
  30. struct fpga_bridge {
  31. const char *name;
  32. struct device dev;
  33. struct mutex mutex; /* for exclusive reference to bridge */
  34. const struct fpga_bridge_ops *br_ops;
  35. struct fpga_image_info *info;
  36. struct list_head node;
  37. void *priv;
  38. };
  39. #define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev)
  40. struct fpga_bridge *of_fpga_bridge_get(struct device_node *node,
  41. struct fpga_image_info *info);
  42. struct fpga_bridge *fpga_bridge_get(struct device *dev,
  43. struct fpga_image_info *info);
  44. void fpga_bridge_put(struct fpga_bridge *bridge);
  45. int fpga_bridge_enable(struct fpga_bridge *bridge);
  46. int fpga_bridge_disable(struct fpga_bridge *bridge);
  47. int fpga_bridges_enable(struct list_head *bridge_list);
  48. int fpga_bridges_disable(struct list_head *bridge_list);
  49. void fpga_bridges_put(struct list_head *bridge_list);
  50. int fpga_bridge_get_to_list(struct device *dev,
  51. struct fpga_image_info *info,
  52. struct list_head *bridge_list);
  53. int of_fpga_bridge_get_to_list(struct device_node *np,
  54. struct fpga_image_info *info,
  55. struct list_head *bridge_list);
  56. struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name,
  57. const struct fpga_bridge_ops *br_ops,
  58. void *priv);
  59. void fpga_bridge_free(struct fpga_bridge *br);
  60. int fpga_bridge_register(struct fpga_bridge *br);
  61. void fpga_bridge_unregister(struct fpga_bridge *br);
  62. #endif /* _LINUX_FPGA_BRIDGE_H */