| .. | .. |
|---|
| 49 | 49 | * them in priv |
|---|
| 50 | 50 | */ |
|---|
| 51 | 51 | |
|---|
| 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); |
|---|
| 54 | 54 | if (!mgr) |
|---|
| 55 | 55 | return -ENOMEM; |
|---|
| 56 | 56 | |
|---|
| 57 | 57 | platform_set_drvdata(pdev, mgr); |
|---|
| 58 | 58 | |
|---|
| 59 | | - ret = fpga_mgr_register(mgr); |
|---|
| 60 | | - if (ret) |
|---|
| 61 | | - fpga_mgr_free(mgr); |
|---|
| 62 | | - |
|---|
| 63 | | - return ret; |
|---|
| 59 | + return fpga_mgr_register(mgr); |
|---|
| 64 | 60 | } |
|---|
| 65 | 61 | |
|---|
| 66 | 62 | static int socfpga_fpga_remove(struct platform_device *pdev) |
|---|
| .. | .. |
|---|
| 102 | 98 | and return a code of type enum fpga_mgr_states. It doesn't result in a change |
|---|
| 103 | 99 | in state. |
|---|
| 104 | 100 | |
|---|
| 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 | | - |
|---|
| 163 | 101 | API for implementing a new FPGA Manager driver |
|---|
| 164 | 102 | ---------------------------------------------- |
|---|
| 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 |
|---|
| 165 | 113 | |
|---|
| 166 | 114 | .. kernel-doc:: include/linux/fpga/fpga-mgr.h |
|---|
| 167 | 115 | :functions: fpga_manager |
|---|
| .. | .. |
|---|
| 170 | 118 | :functions: fpga_manager_ops |
|---|
| 171 | 119 | |
|---|
| 172 | 120 | .. 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 |
|---|
| 177 | 122 | |
|---|
| 178 | 123 | .. kernel-doc:: drivers/fpga/fpga-mgr.c |
|---|
| 179 | 124 | :functions: fpga_mgr_register |
|---|
| 180 | 125 | |
|---|
| 181 | 126 | .. kernel-doc:: drivers/fpga/fpga-mgr.c |
|---|
| 182 | 127 | :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 |
|---|