fpga-region.txt 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. FPGA Regions
  2. Alan Tull 2017
  3. CONTENTS
  4. - Introduction
  5. - The FPGA region API
  6. - Usage example
  7. Introduction
  8. ============
  9. This document is meant to be an brief overview of the FPGA region API usage. A
  10. more conceptual look at regions can be found in [1].
  11. For the purposes of this API document, let's just say that a region associates
  12. an FPGA Manager and a bridge (or bridges) with a reprogrammable region of an
  13. FPGA or the whole FPGA. The API provides a way to register a region and to
  14. program a region.
  15. Currently the only layer above fpga-region.c in the kernel is the Device Tree
  16. support (of-fpga-region.c) described in [1]. The DT support layer uses regions
  17. to program the FPGA and then DT to handle enumeration. The common region code
  18. is intended to be used by other schemes that have other ways of accomplishing
  19. enumeration after programming.
  20. An fpga-region can be set up to know the following things:
  21. * which FPGA manager to use to do the programming
  22. * which bridges to disable before programming and enable afterwards.
  23. Additional info needed to program the FPGA image is passed in the struct
  24. fpga_image_info [2] including:
  25. * pointers to the image as either a scatter-gather buffer, a contiguous
  26. buffer, or the name of firmware file
  27. * flags indicating specifics such as whether the image if for partial
  28. reconfiguration.
  29. ===================
  30. The FPGA region API
  31. ===================
  32. To register or unregister a region:
  33. -----------------------------------
  34. int fpga_region_register(struct device *dev,
  35. struct fpga_region *region);
  36. int fpga_region_unregister(struct fpga_region *region);
  37. An example of usage can be seen in the probe function of [3]
  38. To program an FPGA:
  39. -------------------
  40. int fpga_region_program_fpga(struct fpga_region *region);
  41. This function operates on info passed in the fpga_image_info
  42. (region->info).
  43. This function will attempt to:
  44. * lock the region's mutex
  45. * lock the region's FPGA manager
  46. * build a list of FPGA bridges if a method has been specified to do so
  47. * disable the bridges
  48. * program the FPGA
  49. * re-enable the bridges
  50. * release the locks
  51. =============
  52. Usage example
  53. =============
  54. First, allocate the info struct:
  55. info = fpga_image_info_alloc(dev);
  56. if (!info)
  57. return -ENOMEM;
  58. Set flags as needed, i.e.
  59. info->flags |= FPGA_MGR_PARTIAL_RECONFIG;
  60. Point to your FPGA image, such as:
  61. info->sgt = &sgt;
  62. Add info to region and do the programming:
  63. region->info = info;
  64. ret = fpga_region_program_fpga(region);
  65. Then enumerate whatever hardware has appeared in the FPGA.
  66. --
  67. [1] ../devicetree/bindings/fpga/fpga-region.txt
  68. [2] ./fpga-mgr.txt
  69. [3] ../../drivers/fpga/of-fpga-region.c