fpga-bridge.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 an 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_info - collection of parameters an FPGA Bridge
  22. * @name: fpga bridge name
  23. * @br_ops: pointer to structure of fpga bridge ops
  24. * @priv: fpga bridge private data
  25. *
  26. * fpga_bridge_info contains parameters for the register function. These
  27. * are separated into an info structure because they some are optional
  28. * others could be added to in the future. The info structure facilitates
  29. * maintaining a stable API.
  30. */
  31. struct fpga_bridge_info {
  32. const char *name;
  33. const struct fpga_bridge_ops *br_ops;
  34. void *priv;
  35. };
  36. /**
  37. * struct fpga_bridge - FPGA bridge structure
  38. * @name: name of low level FPGA bridge
  39. * @dev: FPGA bridge device
  40. * @mutex: enforces exclusive reference to bridge
  41. * @br_ops: pointer to struct of FPGA bridge ops
  42. * @info: fpga image specific information
  43. * @node: FPGA bridge list node
  44. * @priv: low level driver private date
  45. */
  46. struct fpga_bridge {
  47. const char *name;
  48. struct device dev;
  49. struct mutex mutex; /* for exclusive reference to bridge */
  50. const struct fpga_bridge_ops *br_ops;
  51. struct fpga_image_info *info;
  52. struct list_head node;
  53. void *priv;
  54. };
  55. #define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev)
  56. struct fpga_bridge *of_fpga_bridge_get(struct device_node *node,
  57. struct fpga_image_info *info);
  58. struct fpga_bridge *fpga_bridge_get(struct device *dev,
  59. struct fpga_image_info *info);
  60. void fpga_bridge_put(struct fpga_bridge *bridge);
  61. int fpga_bridge_enable(struct fpga_bridge *bridge);
  62. int fpga_bridge_disable(struct fpga_bridge *bridge);
  63. int fpga_bridges_enable(struct list_head *bridge_list);
  64. int fpga_bridges_disable(struct list_head *bridge_list);
  65. void fpga_bridges_put(struct list_head *bridge_list);
  66. int fpga_bridge_get_to_list(struct device *dev,
  67. struct fpga_image_info *info,
  68. struct list_head *bridge_list);
  69. int of_fpga_bridge_get_to_list(struct device_node *np,
  70. struct fpga_image_info *info,
  71. struct list_head *bridge_list);
  72. struct fpga_bridge *
  73. fpga_bridge_register(struct device *parent, const char *name,
  74. const struct fpga_bridge_ops *br_ops,
  75. void *priv);
  76. void fpga_bridge_unregister(struct fpga_bridge *br);
  77. #endif /* _LINUX_FPGA_BRIDGE_H */