.. | .. |
---|
34 | 34 | * flags indicating specifics such as whether the image is for partial |
---|
35 | 35 | reconfiguration. |
---|
36 | 36 | |
---|
37 | | -How to program an FPGA using a region |
---|
38 | | -------------------------------------- |
---|
39 | | - |
---|
40 | | -First, allocate the info struct:: |
---|
41 | | - |
---|
42 | | - info = fpga_image_info_alloc(dev); |
---|
43 | | - if (!info) |
---|
44 | | - return -ENOMEM; |
---|
45 | | - |
---|
46 | | -Set flags as needed, i.e.:: |
---|
47 | | - |
---|
48 | | - info->flags |= FPGA_MGR_PARTIAL_RECONFIG; |
---|
49 | | - |
---|
50 | | -Point to your FPGA image, such as:: |
---|
51 | | - |
---|
52 | | - info->sgt = &sgt; |
---|
53 | | - |
---|
54 | | -Add info to region and do the programming:: |
---|
55 | | - |
---|
56 | | - region->info = info; |
---|
57 | | - ret = fpga_region_program_fpga(region); |
---|
58 | | - |
---|
59 | | -:c:func:`fpga_region_program_fpga()` operates on info passed in the |
---|
60 | | -fpga_image_info (region->info). This function will attempt to: |
---|
61 | | - |
---|
62 | | - * lock the region's mutex |
---|
63 | | - * lock the region's FPGA manager |
---|
64 | | - * build a list of FPGA bridges if a method has been specified to do so |
---|
65 | | - * disable the bridges |
---|
66 | | - * program the FPGA |
---|
67 | | - * re-enable the bridges |
---|
68 | | - * release the locks |
---|
69 | | - |
---|
70 | | -Then you will want to enumerate whatever hardware has appeared in the FPGA. |
---|
71 | | - |
---|
72 | 37 | How to add a new FPGA region |
---|
73 | 38 | ---------------------------- |
---|
74 | 39 | |
---|
.. | .. |
---|
77 | 42 | .. [#f1] ../devicetree/bindings/fpga/fpga-region.txt |
---|
78 | 43 | .. [#f2] ../../drivers/fpga/of-fpga-region.c |
---|
79 | 44 | |
---|
80 | | -API to program an FPGA |
---|
81 | | ----------------------- |
---|
82 | | - |
---|
83 | | -.. kernel-doc:: drivers/fpga/fpga-region.c |
---|
84 | | - :functions: fpga_region_program_fpga |
---|
85 | | - |
---|
86 | 45 | API to add a new FPGA region |
---|
87 | 46 | ---------------------------- |
---|
| 47 | + |
---|
| 48 | +* struct fpga_region — The FPGA region struct |
---|
| 49 | +* devm_fpga_region_create() — Allocate and init a region struct |
---|
| 50 | +* fpga_region_register() — Register an FPGA region |
---|
| 51 | +* fpga_region_unregister() — Unregister an FPGA region |
---|
| 52 | + |
---|
| 53 | +The FPGA region's probe function will need to get a reference to the FPGA |
---|
| 54 | +Manager it will be using to do the programming. This usually would happen |
---|
| 55 | +during the region's probe function. |
---|
| 56 | + |
---|
| 57 | +* fpga_mgr_get() — Get a reference to an FPGA manager, raise ref count |
---|
| 58 | +* of_fpga_mgr_get() — Get a reference to an FPGA manager, raise ref count, |
---|
| 59 | + given a device node. |
---|
| 60 | +* fpga_mgr_put() — Put an FPGA manager |
---|
| 61 | + |
---|
| 62 | +The FPGA region will need to specify which bridges to control while programming |
---|
| 63 | +the FPGA. The region driver can build a list of bridges during probe time |
---|
| 64 | +(:c:expr:`fpga_region->bridge_list`) or it can have a function that creates |
---|
| 65 | +the list of bridges to program just before programming |
---|
| 66 | +(:c:expr:`fpga_region->get_bridges`). The FPGA bridge framework supplies the |
---|
| 67 | +following APIs to handle building or tearing down that list. |
---|
| 68 | + |
---|
| 69 | +* fpga_bridge_get_to_list() — Get a ref of an FPGA bridge, add it to a |
---|
| 70 | + list |
---|
| 71 | +* of_fpga_bridge_get_to_list() — Get a ref of an FPGA bridge, add it to a |
---|
| 72 | + list, given a device node |
---|
| 73 | +* fpga_bridges_put() — Given a list of bridges, put them |
---|
88 | 74 | |
---|
89 | 75 | .. kernel-doc:: include/linux/fpga/fpga-region.h |
---|
90 | 76 | :functions: fpga_region |
---|
91 | 77 | |
---|
92 | 78 | .. kernel-doc:: drivers/fpga/fpga-region.c |
---|
93 | | - :functions: fpga_region_create |
---|
94 | | - |
---|
95 | | -.. kernel-doc:: drivers/fpga/fpga-region.c |
---|
96 | | - :functions: fpga_region_free |
---|
| 79 | + :functions: devm_fpga_region_create |
---|
97 | 80 | |
---|
98 | 81 | .. kernel-doc:: drivers/fpga/fpga-region.c |
---|
99 | 82 | :functions: fpga_region_register |
---|
100 | 83 | |
---|
101 | 84 | .. kernel-doc:: drivers/fpga/fpga-region.c |
---|
102 | 85 | :functions: fpga_region_unregister |
---|
| 86 | + |
---|
| 87 | +.. kernel-doc:: drivers/fpga/fpga-mgr.c |
---|
| 88 | + :functions: fpga_mgr_get |
---|
| 89 | + |
---|
| 90 | +.. kernel-doc:: drivers/fpga/fpga-mgr.c |
---|
| 91 | + :functions: of_fpga_mgr_get |
---|
| 92 | + |
---|
| 93 | +.. kernel-doc:: drivers/fpga/fpga-mgr.c |
---|
| 94 | + :functions: fpga_mgr_put |
---|
| 95 | + |
---|
| 96 | +.. kernel-doc:: drivers/fpga/fpga-bridge.c |
---|
| 97 | + :functions: fpga_bridge_get_to_list |
---|
| 98 | + |
---|
| 99 | +.. kernel-doc:: drivers/fpga/fpga-bridge.c |
---|
| 100 | + :functions: of_fpga_bridge_get_to_list |
---|
| 101 | + |
---|
| 102 | +.. kernel-doc:: drivers/fpga/fpga-bridge.c |
---|
| 103 | + :functions: fpga_bridges_put |
---|