~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/driver-api/fpga/fpga-programming.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/driver-api/fpga/fpga-programming.rst (Version linux-6.12-rc7) and /Documentation/driver-api/fpga/fpga-programming.rst (Version linux-5.3.18)


  1 In-kernel API for FPGA Programming                  1 In-kernel API for FPGA Programming
  2 ==================================                  2 ==================================
  3                                                     3 
  4 Overview                                            4 Overview
  5 --------                                            5 --------
  6                                                     6 
  7 The in-kernel API for FPGA programming is a co      7 The in-kernel API for FPGA programming is a combination of APIs from
  8 FPGA manager, bridge, and regions.  The actual      8 FPGA manager, bridge, and regions.  The actual function used to
  9 trigger FPGA programming is fpga_region_progra !!   9 trigger FPGA programming is :c:func:`fpga_region_program_fpga()`.
 10                                                    10 
 11 fpga_region_program_fpga() uses functionality  !!  11 :c:func:`fpga_region_program_fpga()` uses functionality supplied by
 12 the FPGA manager and bridges.  It will:            12 the FPGA manager and bridges.  It will:
 13                                                    13 
 14  * lock the region's mutex                         14  * lock the region's mutex
 15  * lock the mutex of the region's FPGA manager     15  * lock the mutex of the region's FPGA manager
 16  * build a list of FPGA bridges if a method ha     16  * build a list of FPGA bridges if a method has been specified to do so
 17  * disable the bridges                             17  * disable the bridges
 18  * program the FPGA using info passed in :c:ex !!  18  * program the FPGA using info passed in :c:member:`fpga_region->info`.
 19  * re-enable the bridges                           19  * re-enable the bridges
 20  * release the locks                               20  * release the locks
 21                                                    21 
 22 The struct fpga_image_info specifies what FPGA     22 The struct fpga_image_info specifies what FPGA image to program.  It is
 23 allocated/freed by fpga_image_info_alloc() and !!  23 allocated/freed by :c:func:`fpga_image_info_alloc()` and freed with
 24 fpga_image_info_free()                         !!  24 :c:func:`fpga_image_info_free()`
 25                                                    25 
 26 How to program an FPGA using a region              26 How to program an FPGA using a region
 27 -------------------------------------              27 -------------------------------------
 28                                                    28 
 29 When the FPGA region driver probed, it was giv     29 When the FPGA region driver probed, it was given a pointer to an FPGA manager
 30 driver so it knows which manager to use.  The      30 driver so it knows which manager to use.  The region also either has a list of
 31 bridges to control during programming or it ha     31 bridges to control during programming or it has a pointer to a function that
 32 will generate that list.  Here's some sample c     32 will generate that list.  Here's some sample code of what to do next::
 33                                                    33 
 34         #include <linux/fpga/fpga-mgr.h>           34         #include <linux/fpga/fpga-mgr.h>
 35         #include <linux/fpga/fpga-region.h>        35         #include <linux/fpga/fpga-region.h>
 36                                                    36 
 37         struct fpga_image_info *info;              37         struct fpga_image_info *info;
 38         int ret;                                   38         int ret;
 39                                                    39 
 40         /*                                         40         /*
 41          * First, alloc the struct with inform     41          * First, alloc the struct with information about the FPGA image to
 42          * program.                                42          * program.
 43          */                                        43          */
 44         info = fpga_image_info_alloc(dev);         44         info = fpga_image_info_alloc(dev);
 45         if (!info)                                 45         if (!info)
 46                 return -ENOMEM;                    46                 return -ENOMEM;
 47                                                    47 
 48         /* Set flags as needed, such as: */        48         /* Set flags as needed, such as: */
 49         info->flags = FPGA_MGR_PARTIAL_RECONFI     49         info->flags = FPGA_MGR_PARTIAL_RECONFIG;
 50                                                    50 
 51         /*                                         51         /*
 52          * Indicate where the FPGA image is. T     52          * Indicate where the FPGA image is. This is pseudo-code; you're
 53          * going to use one of these three.        53          * going to use one of these three.
 54          */                                        54          */
 55         if (image is in a scatter gather table     55         if (image is in a scatter gather table) {
 56                                                    56 
 57                 info->sgt = [your scatter gath     57                 info->sgt = [your scatter gather table]
 58                                                    58 
 59         } else if (image is in a buffer) {         59         } else if (image is in a buffer) {
 60                                                    60 
 61                 info->buf = [your image buffer     61                 info->buf = [your image buffer]
 62                 info->count = [image buffer si     62                 info->count = [image buffer size]
 63                                                    63 
 64         } else if (image is in a firmware file     64         } else if (image is in a firmware file) {
 65                                                    65 
 66                 info->firmware_name = devm_kst     66                 info->firmware_name = devm_kstrdup(dev, firmware_name,
 67                                                    67                                                    GFP_KERNEL);
 68                                                    68 
 69         }                                          69         }
 70                                                    70 
 71         /* Add info to region and do the progr     71         /* Add info to region and do the programming */
 72         region->info = info;                       72         region->info = info;
 73         ret = fpga_region_program_fpga(region)     73         ret = fpga_region_program_fpga(region);
 74                                                    74 
 75         /* Deallocate the image info if you're     75         /* Deallocate the image info if you're done with it */
 76         region->info = NULL;                       76         region->info = NULL;
 77         fpga_image_info_free(info);                77         fpga_image_info_free(info);
 78                                                    78 
 79         if (ret)                                   79         if (ret)
 80                 return ret;                        80                 return ret;
 81                                                    81 
 82         /* Now enumerate whatever hardware has     82         /* Now enumerate whatever hardware has appeared in the FPGA. */
 83                                                    83 
 84 API for programming an FPGA                        84 API for programming an FPGA
 85 ---------------------------                        85 ---------------------------
 86                                                    86 
 87 * fpga_region_program_fpga() -  Program an FPG !!  87 * :c:func:`fpga_region_program_fpga` —  Program an FPGA
 88 * fpga_image_info() -  Specifies what FPGA ima !!  88 * :c:type:`fpga_image_info` —  Specifies what FPGA image to program
 89 * fpga_image_info_alloc() -  Allocate an FPGA  !!  89 * :c:func:`fpga_image_info_alloc()` —  Allocate an FPGA image info struct
 90 * fpga_image_info_free() -  Free an FPGA image !!  90 * :c:func:`fpga_image_info_free()` —  Free an FPGA image info struct
 91                                                    91 
 92 .. kernel-doc:: drivers/fpga/fpga-region.c         92 .. kernel-doc:: drivers/fpga/fpga-region.c
 93    :functions: fpga_region_program_fpga            93    :functions: fpga_region_program_fpga
 94                                                    94 
 95 FPGA Manager flags                                 95 FPGA Manager flags
 96                                                    96 
 97 .. kernel-doc:: include/linux/fpga/fpga-mgr.h      97 .. kernel-doc:: include/linux/fpga/fpga-mgr.h
 98    :doc: FPGA Manager flags                        98    :doc: FPGA Manager flags
 99                                                    99 
100 .. kernel-doc:: include/linux/fpga/fpga-mgr.h     100 .. kernel-doc:: include/linux/fpga/fpga-mgr.h
101    :functions: fpga_image_info                    101    :functions: fpga_image_info
102                                                   102 
103 .. kernel-doc:: drivers/fpga/fpga-mgr.c           103 .. kernel-doc:: drivers/fpga/fpga-mgr.c
104    :functions: fpga_image_info_alloc              104    :functions: fpga_image_info_alloc
105                                                   105 
106 .. kernel-doc:: drivers/fpga/fpga-mgr.c           106 .. kernel-doc:: drivers/fpga/fpga-mgr.c
107    :functions: fpga_image_info_free               107    :functions: fpga_image_info_free
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php