hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/Documentation/driver-api/fpga/fpga-mgr.rst
....@@ -49,18 +49,14 @@
4949 * them in priv
5050 */
5151
52
- mgr = fpga_mgr_create(dev, "Altera SOCFPGA FPGA Manager",
53
- &socfpga_fpga_ops, priv);
52
+ mgr = devm_fpga_mgr_create(dev, "Altera SOCFPGA FPGA Manager",
53
+ &socfpga_fpga_ops, priv);
5454 if (!mgr)
5555 return -ENOMEM;
5656
5757 platform_set_drvdata(pdev, mgr);
5858
59
- ret = fpga_mgr_register(mgr);
60
- if (ret)
61
- fpga_mgr_free(mgr);
62
-
63
- return ret;
59
+ return fpga_mgr_register(mgr);
6460 }
6561
6662 static int socfpga_fpga_remove(struct platform_device *pdev)
....@@ -102,66 +98,18 @@
10298 and return a code of type enum fpga_mgr_states. It doesn't result in a change
10399 in state.
104100
105
-How to write an image buffer to a supported FPGA
106
-------------------------------------------------
107
-
108
-Some sample code::
109
-
110
- #include <linux/fpga/fpga-mgr.h>
111
-
112
- struct fpga_manager *mgr;
113
- struct fpga_image_info *info;
114
- int ret;
115
-
116
- /*
117
- * Get a reference to FPGA manager. The manager is not locked, so you can
118
- * hold onto this reference without it preventing programming.
119
- *
120
- * This example uses the device node of the manager. Alternatively, use
121
- * fpga_mgr_get(dev) instead if you have the device.
122
- */
123
- mgr = of_fpga_mgr_get(mgr_node);
124
-
125
- /* struct with information about the FPGA image to program. */
126
- info = fpga_image_info_alloc(dev);
127
-
128
- /* flags indicates whether to do full or partial reconfiguration */
129
- info->flags = FPGA_MGR_PARTIAL_RECONFIG;
130
-
131
- /*
132
- * At this point, indicate where the image is. This is pseudo-code; you're
133
- * going to use one of these three.
134
- */
135
- if (image is in a scatter gather table) {
136
-
137
- info->sgt = [your scatter gather table]
138
-
139
- } else if (image is in a buffer) {
140
-
141
- info->buf = [your image buffer]
142
- info->count = [image buffer size]
143
-
144
- } else if (image is in a firmware file) {
145
-
146
- info->firmware_name = devm_kstrdup(dev, firmware_name, GFP_KERNEL);
147
-
148
- }
149
-
150
- /* Get exclusive control of FPGA manager */
151
- ret = fpga_mgr_lock(mgr);
152
-
153
- /* Load the buffer to the FPGA */
154
- ret = fpga_mgr_buf_load(mgr, &info, buf, count);
155
-
156
- /* Release the FPGA manager */
157
- fpga_mgr_unlock(mgr);
158
- fpga_mgr_put(mgr);
159
-
160
- /* Deallocate the image info if you're done with it */
161
- fpga_image_info_free(info);
162
-
163101 API for implementing a new FPGA Manager driver
164102 ----------------------------------------------
103
+
104
+* ``fpga_mgr_states`` — Values for :c:expr:`fpga_manager->state`.
105
+* struct fpga_manager — the FPGA manager struct
106
+* struct fpga_manager_ops — Low level FPGA manager driver ops
107
+* devm_fpga_mgr_create() — Allocate and init a manager struct
108
+* fpga_mgr_register() — Register an FPGA manager
109
+* fpga_mgr_unregister() — Unregister an FPGA manager
110
+
111
+.. kernel-doc:: include/linux/fpga/fpga-mgr.h
112
+ :functions: fpga_mgr_states
165113
166114 .. kernel-doc:: include/linux/fpga/fpga-mgr.h
167115 :functions: fpga_manager
....@@ -170,56 +118,10 @@
170118 :functions: fpga_manager_ops
171119
172120 .. kernel-doc:: drivers/fpga/fpga-mgr.c
173
- :functions: fpga_mgr_create
174
-
175
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
176
- :functions: fpga_mgr_free
121
+ :functions: devm_fpga_mgr_create
177122
178123 .. kernel-doc:: drivers/fpga/fpga-mgr.c
179124 :functions: fpga_mgr_register
180125
181126 .. kernel-doc:: drivers/fpga/fpga-mgr.c
182127 :functions: fpga_mgr_unregister
183
-
184
-API for programming an FPGA
185
----------------------------
186
-
187
-FPGA Manager flags
188
-
189
-.. kernel-doc:: include/linux/fpga/fpga-mgr.h
190
- :doc: FPGA Manager flags
191
-
192
-.. kernel-doc:: include/linux/fpga/fpga-mgr.h
193
- :functions: fpga_image_info
194
-
195
-.. kernel-doc:: include/linux/fpga/fpga-mgr.h
196
- :functions: fpga_mgr_states
197
-
198
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
199
- :functions: fpga_image_info_alloc
200
-
201
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
202
- :functions: fpga_image_info_free
203
-
204
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
205
- :functions: of_fpga_mgr_get
206
-
207
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
208
- :functions: fpga_mgr_get
209
-
210
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
211
- :functions: fpga_mgr_put
212
-
213
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
214
- :functions: fpga_mgr_lock
215
-
216
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
217
- :functions: fpga_mgr_unlock
218
-
219
-.. kernel-doc:: include/linux/fpga/fpga-mgr.h
220
- :functions: fpga_mgr_states
221
-
222
-Note - use :c:func:`fpga_region_program_fpga()` instead of :c:func:`fpga_mgr_load()`
223
-
224
-.. kernel-doc:: drivers/fpga/fpga-mgr.c
225
- :functions: fpga_mgr_load