fpga-region.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _FPGA_REGION_H
  3. #define _FPGA_REGION_H
  4. #include <linux/device.h>
  5. #include <linux/fpga/fpga-mgr.h>
  6. #include <linux/fpga/fpga-bridge.h>
  7. struct fpga_region;
  8. /**
  9. * struct fpga_region_info - collection of parameters an FPGA Region
  10. * @mgr: fpga region manager
  11. * @compat_id: FPGA region id for compatibility check.
  12. * @priv: fpga region private data
  13. * @get_bridges: optional function to get bridges to a list
  14. *
  15. * fpga_region_info contains parameters for the register_full function.
  16. * These are separated into an info structure because they some are optional
  17. * others could be added to in the future. The info structure facilitates
  18. * maintaining a stable API.
  19. */
  20. struct fpga_region_info {
  21. struct fpga_manager *mgr;
  22. struct fpga_compat_id *compat_id;
  23. void *priv;
  24. int (*get_bridges)(struct fpga_region *region);
  25. };
  26. /**
  27. * struct fpga_region - FPGA Region structure
  28. * @dev: FPGA Region device
  29. * @mutex: enforces exclusive reference to region
  30. * @bridge_list: list of FPGA bridges specified in region
  31. * @mgr: FPGA manager
  32. * @info: FPGA image info
  33. * @compat_id: FPGA region id for compatibility check.
  34. * @priv: private data
  35. * @get_bridges: optional function to get bridges to a list
  36. */
  37. struct fpga_region {
  38. struct device dev;
  39. struct mutex mutex; /* for exclusive reference to region */
  40. struct list_head bridge_list;
  41. struct fpga_manager *mgr;
  42. struct fpga_image_info *info;
  43. struct fpga_compat_id *compat_id;
  44. void *priv;
  45. int (*get_bridges)(struct fpga_region *region);
  46. };
  47. #define to_fpga_region(d) container_of(d, struct fpga_region, dev)
  48. struct fpga_region *
  49. fpga_region_class_find(struct device *start, const void *data,
  50. int (*match)(struct device *, const void *));
  51. int fpga_region_program_fpga(struct fpga_region *region);
  52. struct fpga_region *
  53. fpga_region_register_full(struct device *parent, const struct fpga_region_info *info);
  54. struct fpga_region *
  55. fpga_region_register(struct device *parent, struct fpga_manager *mgr,
  56. int (*get_bridges)(struct fpga_region *));
  57. void fpga_region_unregister(struct fpga_region *region);
  58. #endif /* _FPGA_REGION_H */