162306a36Sopenharmony_ciFPGA Region
262306a36Sopenharmony_ci===========
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciOverview
562306a36Sopenharmony_ci--------
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciThis document is meant to be a brief overview of the FPGA region API usage.  A
862306a36Sopenharmony_cimore conceptual look at regions can be found in the Device Tree binding
962306a36Sopenharmony_cidocument [#f1]_.
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciFor the purposes of this API document, let's just say that a region associates
1262306a36Sopenharmony_cian FPGA Manager and a bridge (or bridges) with a reprogrammable region of an
1362306a36Sopenharmony_ciFPGA or the whole FPGA.  The API provides a way to register a region and to
1462306a36Sopenharmony_ciprogram a region.
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciCurrently the only layer above fpga-region.c in the kernel is the Device Tree
1762306a36Sopenharmony_cisupport (of-fpga-region.c) described in [#f1]_.  The DT support layer uses regions
1862306a36Sopenharmony_cito program the FPGA and then DT to handle enumeration.  The common region code
1962306a36Sopenharmony_ciis intended to be used by other schemes that have other ways of accomplishing
2062306a36Sopenharmony_cienumeration after programming.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciAn fpga-region can be set up to know the following things:
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci * which FPGA manager to use to do the programming
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci * which bridges to disable before programming and enable afterwards.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ciAdditional info needed to program the FPGA image is passed in the struct
2962306a36Sopenharmony_cifpga_image_info including:
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci * pointers to the image as either a scatter-gather buffer, a contiguous
3262306a36Sopenharmony_ci   buffer, or the name of firmware file
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci * flags indicating specifics such as whether the image is for partial
3562306a36Sopenharmony_ci   reconfiguration.
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciHow to add a new FPGA region
3862306a36Sopenharmony_ci----------------------------
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciAn example of usage can be seen in the probe function of [#f2]_.
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci.. [#f1] ../devicetree/bindings/fpga/fpga-region.txt
4362306a36Sopenharmony_ci.. [#f2] ../../drivers/fpga/of-fpga-region.c
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciAPI to add a new FPGA region
4662306a36Sopenharmony_ci----------------------------
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci* struct fpga_region - The FPGA region struct
4962306a36Sopenharmony_ci* struct fpga_region_info - Parameter structure for fpga_region_register_full()
5062306a36Sopenharmony_ci* fpga_region_register_full() -  Create and register an FPGA region using the
5162306a36Sopenharmony_ci  fpga_region_info structure to provide the full flexibility of options
5262306a36Sopenharmony_ci* fpga_region_register() -  Create and register an FPGA region using standard
5362306a36Sopenharmony_ci  arguments
5462306a36Sopenharmony_ci* fpga_region_unregister() -  Unregister an FPGA region
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciThe FPGA region's probe function will need to get a reference to the FPGA
5762306a36Sopenharmony_ciManager it will be using to do the programming.  This usually would happen
5862306a36Sopenharmony_ciduring the region's probe function.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci* fpga_mgr_get() - Get a reference to an FPGA manager, raise ref count
6162306a36Sopenharmony_ci* of_fpga_mgr_get() -  Get a reference to an FPGA manager, raise ref count,
6262306a36Sopenharmony_ci  given a device node.
6362306a36Sopenharmony_ci* fpga_mgr_put() - Put an FPGA manager
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ciThe FPGA region will need to specify which bridges to control while programming
6662306a36Sopenharmony_cithe FPGA.  The region driver can build a list of bridges during probe time
6762306a36Sopenharmony_ci(:c:expr:`fpga_region->bridge_list`) or it can have a function that creates
6862306a36Sopenharmony_cithe list of bridges to program just before programming
6962306a36Sopenharmony_ci(:c:expr:`fpga_region->get_bridges`).  The FPGA bridge framework supplies the
7062306a36Sopenharmony_cifollowing APIs to handle building or tearing down that list.
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci* fpga_bridge_get_to_list() - Get a ref of an FPGA bridge, add it to a
7362306a36Sopenharmony_ci  list
7462306a36Sopenharmony_ci* of_fpga_bridge_get_to_list() - Get a ref of an FPGA bridge, add it to a
7562306a36Sopenharmony_ci  list, given a device node
7662306a36Sopenharmony_ci* fpga_bridges_put() - Given a list of bridges, put them
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci.. kernel-doc:: include/linux/fpga/fpga-region.h
7962306a36Sopenharmony_ci   :functions: fpga_region
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci.. kernel-doc:: include/linux/fpga/fpga-region.h
8262306a36Sopenharmony_ci   :functions: fpga_region_info
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-region.c
8562306a36Sopenharmony_ci   :functions: fpga_region_register_full
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-region.c
8862306a36Sopenharmony_ci   :functions: fpga_region_register
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-region.c
9162306a36Sopenharmony_ci   :functions: fpga_region_unregister
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-mgr.c
9462306a36Sopenharmony_ci   :functions: fpga_mgr_get
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-mgr.c
9762306a36Sopenharmony_ci   :functions: of_fpga_mgr_get
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-mgr.c
10062306a36Sopenharmony_ci   :functions: fpga_mgr_put
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-bridge.c
10362306a36Sopenharmony_ci   :functions: fpga_bridge_get_to_list
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-bridge.c
10662306a36Sopenharmony_ci   :functions: of_fpga_bridge_get_to_list
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci.. kernel-doc:: drivers/fpga/fpga-bridge.c
10962306a36Sopenharmony_ci   :functions: fpga_bridges_put
110