summaryrefslogtreecommitdiffstats
path: root/Documentation/fpga/fpga-mgr.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/fpga/fpga-mgr.txt')
-rw-r--r--Documentation/fpga/fpga-mgr.txt132
1 files changed, 66 insertions, 66 deletions
diff --git a/Documentation/fpga/fpga-mgr.txt b/Documentation/fpga/fpga-mgr.txt
index 78f197fadfd1..cc6413ed6fc9 100644
--- a/Documentation/fpga/fpga-mgr.txt
+++ b/Documentation/fpga/fpga-mgr.txt
@@ -11,61 +11,65 @@ hidden away in a low level driver which registers a set of ops with the core.
11The FPGA image data itself is very manufacturer specific, but for our purposes 11The FPGA image data itself is very manufacturer specific, but for our purposes
12it's just binary data. The FPGA manager core won't parse it. 12it's just binary data. The FPGA manager core won't parse it.
13 13
14The FPGA image to be programmed can be in a scatter gather list, a single
15contiguous buffer, or a firmware file. Because allocating contiguous kernel
16memory for the buffer should be avoided, users are encouraged to use a scatter
17gather list instead if possible.
18
19The particulars for programming the image are presented in a structure (struct
20fpga_image_info). This struct contains parameters such as pointers to the
21FPGA image as well as image-specific particulars such as whether the image was
22built for full or partial reconfiguration.
14 23
15API Functions: 24API Functions:
16============== 25==============
17 26
18To program the FPGA from a file or from a buffer: 27To program the FPGA:
19------------------------------------------------- 28--------------------
20
21 int fpga_mgr_buf_load(struct fpga_manager *mgr,
22 struct fpga_image_info *info,
23 const char *buf, size_t count);
24
25Load the FPGA from an image which exists as a contiguous buffer in
26memory. Allocating contiguous kernel memory for the buffer should be avoided,
27users are encouraged to use the _sg interface instead of this.
28
29 int fpga_mgr_buf_load_sg(struct fpga_manager *mgr,
30 struct fpga_image_info *info,
31 struct sg_table *sgt);
32 29
33Load the FPGA from an image from non-contiguous in memory. Callers can 30 int fpga_mgr_load(struct fpga_manager *mgr,
34construct a sg_table using alloc_page backed memory. 31 struct fpga_image_info *info);
35 32
36 int fpga_mgr_firmware_load(struct fpga_manager *mgr, 33Load the FPGA from an image which is indicated in the info. If successful,
37 struct fpga_image_info *info,
38 const char *image_name);
39
40Load the FPGA from an image which exists as a file. The image file must be on
41the firmware search path (see the firmware class documentation). If successful,
42the FPGA ends up in operating mode. Return 0 on success or a negative error 34the FPGA ends up in operating mode. Return 0 on success or a negative error
43code. 35code.
44 36
45A FPGA design contained in a FPGA image file will likely have particulars that 37To allocate or free a struct fpga_image_info:
46affect how the image is programmed to the FPGA. These are contained in struct 38---------------------------------------------
47fpga_image_info. Currently the only such particular is a single flag bit 39
48indicating whether the image is for full or partial reconfiguration. 40 struct fpga_image_info *fpga_image_info_alloc(struct device *dev);
41
42 void fpga_image_info_free(struct fpga_image_info *info);
49 43
50To get/put a reference to a FPGA manager: 44To get/put a reference to a FPGA manager:
51----------------------------------------- 45-----------------------------------------
52 46
53 struct fpga_manager *of_fpga_mgr_get(struct device_node *node); 47 struct fpga_manager *of_fpga_mgr_get(struct device_node *node);
54 struct fpga_manager *fpga_mgr_get(struct device *dev); 48 struct fpga_manager *fpga_mgr_get(struct device *dev);
49 void fpga_mgr_put(struct fpga_manager *mgr);
55 50
56Given a DT node or device, get an exclusive reference to a FPGA manager. 51Given a DT node or device, get a reference to a FPGA manager. This pointer
52can be saved until you are ready to program the FPGA. fpga_mgr_put releases
53the reference.
57 54
58 void fpga_mgr_put(struct fpga_manager *mgr);
59 55
60Release the reference. 56To get exclusive control of a FPGA manager:
57-------------------------------------------
58
59 int fpga_mgr_lock(struct fpga_manager *mgr);
60 void fpga_mgr_unlock(struct fpga_manager *mgr);
61
62The user should call fpga_mgr_lock and verify that it returns 0 before
63attempting to program the FPGA. Likewise, the user should call
64fpga_mgr_unlock when done programming the FPGA.
61 65
62 66
63To register or unregister the low level FPGA-specific driver: 67To register or unregister the low level FPGA-specific driver:
64------------------------------------------------------------- 68-------------------------------------------------------------
65 69
66 int fpga_mgr_register(struct device *dev, const char *name, 70 int fpga_mgr_register(struct device *dev, const char *name,
67 const struct fpga_manager_ops *mops, 71 const struct fpga_manager_ops *mops,
68 void *priv); 72 void *priv);
69 73
70 void fpga_mgr_unregister(struct device *dev); 74 void fpga_mgr_unregister(struct device *dev);
71 75
@@ -75,62 +79,58 @@ device."
75 79
76How to write an image buffer to a supported FPGA 80How to write an image buffer to a supported FPGA
77================================================ 81================================================
78/* Include to get the API */
79#include <linux/fpga/fpga-mgr.h> 82#include <linux/fpga/fpga-mgr.h>
80 83
81/* device node that specifies the FPGA manager to use */ 84struct fpga_manager *mgr;
82struct device_node *mgr_node = ... 85struct fpga_image_info *info;
86int ret;
83 87
84/* FPGA image is in this buffer. count is size of the buffer. */ 88/*
85char *buf = ... 89 * Get a reference to FPGA manager. The manager is not locked, so you can
86int count = ... 90 * hold onto this reference without it preventing programming.
91 *
92 * This example uses the device node of the manager. Alternatively, use
93 * fpga_mgr_get(dev) instead if you have the device.
94 */
95mgr = of_fpga_mgr_get(mgr_node);
87 96
88/* struct with information about the FPGA image to program. */ 97/* struct with information about the FPGA image to program. */
89struct fpga_image_info info; 98info = fpga_image_info_alloc(dev);
90 99
91/* flags indicates whether to do full or partial reconfiguration */ 100/* flags indicates whether to do full or partial reconfiguration */
92info.flags = 0; 101info->flags = FPGA_MGR_PARTIAL_RECONFIG;
93 102
94int ret; 103/*
104 * At this point, indicate where the image is. This is pseudo-code; you're
105 * going to use one of these three.
106 */
107if (image is in a scatter gather table) {
95 108
96/* Get exclusive control of FPGA manager */ 109 info->sgt = [your scatter gather table]
97struct fpga_manager *mgr = of_fpga_mgr_get(mgr_node);
98 110
99/* Load the buffer to the FPGA */ 111} else if (image is in a buffer) {
100ret = fpga_mgr_buf_load(mgr, &info, buf, count);
101
102/* Release the FPGA manager */
103fpga_mgr_put(mgr);
104
105
106How to write an image file to a supported FPGA
107==============================================
108/* Include to get the API */
109#include <linux/fpga/fpga-mgr.h>
110 112
111/* device node that specifies the FPGA manager to use */ 113 info->buf = [your image buffer]
112struct device_node *mgr_node = ... 114 info->count = [image buffer size]
113 115
114/* FPGA image is in this file which is in the firmware search path */ 116} else if (image is in a firmware file) {
115const char *path = "fpga-image-9.rbf"
116 117
117/* struct with information about the FPGA image to program. */ 118 info->firmware_name = devm_kstrdup(dev, firmware_name, GFP_KERNEL);
118struct fpga_image_info info;
119
120/* flags indicates whether to do full or partial reconfiguration */
121info.flags = 0;
122 119
123int ret; 120}
124 121
125/* Get exclusive control of FPGA manager */ 122/* Get exclusive control of FPGA manager */
126struct fpga_manager *mgr = of_fpga_mgr_get(mgr_node); 123ret = fpga_mgr_lock(mgr);
127 124
128/* Get the firmware image (path) and load it to the FPGA */ 125/* Load the buffer to the FPGA */
129ret = fpga_mgr_firmware_load(mgr, &info, path); 126ret = fpga_mgr_buf_load(mgr, &info, buf, count);
130 127
131/* Release the FPGA manager */ 128/* Release the FPGA manager */
129fpga_mgr_unlock(mgr);
132fpga_mgr_put(mgr); 130fpga_mgr_put(mgr);
133 131
132/* Deallocate the image info if you're done with it */
133fpga_image_info_free(info);
134 134
135How to support a new FPGA device 135How to support a new FPGA device
136================================ 136================================