1*4882a593SmuzhiyunFPGA Region 2*4882a593Smuzhiyun=========== 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunOverview 5*4882a593Smuzhiyun-------- 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThis document is meant to be a brief overview of the FPGA region API usage. A 8*4882a593Smuzhiyunmore conceptual look at regions can be found in the Device Tree binding 9*4882a593Smuzhiyundocument [#f1]_. 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunFor the purposes of this API document, let's just say that a region associates 12*4882a593Smuzhiyunan FPGA Manager and a bridge (or bridges) with a reprogrammable region of an 13*4882a593SmuzhiyunFPGA or the whole FPGA. The API provides a way to register a region and to 14*4882a593Smuzhiyunprogram a region. 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunCurrently the only layer above fpga-region.c in the kernel is the Device Tree 17*4882a593Smuzhiyunsupport (of-fpga-region.c) described in [#f1]_. The DT support layer uses regions 18*4882a593Smuzhiyunto program the FPGA and then DT to handle enumeration. The common region code 19*4882a593Smuzhiyunis intended to be used by other schemes that have other ways of accomplishing 20*4882a593Smuzhiyunenumeration after programming. 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunAn fpga-region can be set up to know the following things: 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun * which FPGA manager to use to do the programming 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun * which bridges to disable before programming and enable afterwards. 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunAdditional info needed to program the FPGA image is passed in the struct 29*4882a593Smuzhiyunfpga_image_info including: 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun * pointers to the image as either a scatter-gather buffer, a contiguous 32*4882a593Smuzhiyun buffer, or the name of firmware file 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun * flags indicating specifics such as whether the image is for partial 35*4882a593Smuzhiyun reconfiguration. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunHow to add a new FPGA region 38*4882a593Smuzhiyun---------------------------- 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunAn example of usage can be seen in the probe function of [#f2]_. 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun.. [#f1] ../devicetree/bindings/fpga/fpga-region.txt 43*4882a593Smuzhiyun.. [#f2] ../../drivers/fpga/of-fpga-region.c 44*4882a593Smuzhiyun 45*4882a593SmuzhiyunAPI to add a new FPGA region 46*4882a593Smuzhiyun---------------------------- 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun* struct fpga_region — The FPGA region struct 49*4882a593Smuzhiyun* devm_fpga_region_create() — Allocate and init a region struct 50*4882a593Smuzhiyun* fpga_region_register() — Register an FPGA region 51*4882a593Smuzhiyun* fpga_region_unregister() — Unregister an FPGA region 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunThe FPGA region's probe function will need to get a reference to the FPGA 54*4882a593SmuzhiyunManager it will be using to do the programming. This usually would happen 55*4882a593Smuzhiyunduring the region's probe function. 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun* fpga_mgr_get() — Get a reference to an FPGA manager, raise ref count 58*4882a593Smuzhiyun* of_fpga_mgr_get() — Get a reference to an FPGA manager, raise ref count, 59*4882a593Smuzhiyun given a device node. 60*4882a593Smuzhiyun* fpga_mgr_put() — Put an FPGA manager 61*4882a593Smuzhiyun 62*4882a593SmuzhiyunThe FPGA region will need to specify which bridges to control while programming 63*4882a593Smuzhiyunthe FPGA. The region driver can build a list of bridges during probe time 64*4882a593Smuzhiyun(:c:expr:`fpga_region->bridge_list`) or it can have a function that creates 65*4882a593Smuzhiyunthe list of bridges to program just before programming 66*4882a593Smuzhiyun(:c:expr:`fpga_region->get_bridges`). The FPGA bridge framework supplies the 67*4882a593Smuzhiyunfollowing APIs to handle building or tearing down that list. 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun* fpga_bridge_get_to_list() — Get a ref of an FPGA bridge, add it to a 70*4882a593Smuzhiyun list 71*4882a593Smuzhiyun* of_fpga_bridge_get_to_list() — Get a ref of an FPGA bridge, add it to a 72*4882a593Smuzhiyun list, given a device node 73*4882a593Smuzhiyun* fpga_bridges_put() — Given a list of bridges, put them 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun.. kernel-doc:: include/linux/fpga/fpga-region.h 76*4882a593Smuzhiyun :functions: fpga_region 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-region.c 79*4882a593Smuzhiyun :functions: devm_fpga_region_create 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-region.c 82*4882a593Smuzhiyun :functions: fpga_region_register 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-region.c 85*4882a593Smuzhiyun :functions: fpga_region_unregister 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-mgr.c 88*4882a593Smuzhiyun :functions: fpga_mgr_get 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-mgr.c 91*4882a593Smuzhiyun :functions: of_fpga_mgr_get 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-mgr.c 94*4882a593Smuzhiyun :functions: fpga_mgr_put 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-bridge.c 97*4882a593Smuzhiyun :functions: fpga_bridge_get_to_list 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-bridge.c 100*4882a593Smuzhiyun :functions: of_fpga_bridge_get_to_list 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun.. kernel-doc:: drivers/fpga/fpga-bridge.c 103*4882a593Smuzhiyun :functions: fpga_bridges_put 104