Path: blob/main/sys/contrib/device-tree/Bindings/fpga/fpga-region.txt
48375 views
FPGA Region Device Tree Binding12Alan Tull 201634CONTENTS5- Introduction6- Terminology7- Sequence8- FPGA Region9- Supported Use Models10- Device Tree Examples11- Constraints121314Introduction15============1617FPGA Regions represent FPGA's and partial reconfiguration regions of FPGA's in18the Device Tree. FPGA Regions provide a way to program FPGAs under device tree19control.2021This device tree binding document hits some of the high points of FPGA usage and22attempts to include terminology used by both major FPGA manufacturers. This23document isn't a replacement for any manufacturers specifications for FPGA24usage.252627Terminology28===========2930Full Reconfiguration31* The entire FPGA is programmed.3233Partial Reconfiguration (PR)34* A section of an FPGA is reprogrammed while the rest of the FPGA is not35affected.36* Not all FPGA's support PR.3738Partial Reconfiguration Region (PRR)39* Also called a "reconfigurable partition"40* A PRR is a specific section of an FPGA reserved for reconfiguration.41* A base (or static) FPGA image may create a set of PRR's that later may42be independently reprogrammed many times.43* The size and specific location of each PRR is fixed.44* The connections at the edge of each PRR are fixed. The image that is loaded45into a PRR must fit and must use a subset of the region's connections.46* The busses within the FPGA are split such that each region gets its own47branch that may be gated independently.4849Persona50* Also called a "partial bit stream"51* An FPGA image that is designed to be loaded into a PRR. There may be52any number of personas designed to fit into a PRR, but only one at at time53may be loaded.54* A persona may create more regions.5556FPGA Bridge57* FPGA Bridges gate bus signals between a host and FPGA.58* FPGA Bridges should be disabled while the FPGA is being programmed to59prevent spurious signals on the cpu bus and to the soft logic.60* FPGA bridges may be actual hardware or soft logic on an FPGA.61* During Full Reconfiguration, hardware bridges between the host and FPGA62will be disabled.63* During Partial Reconfiguration of a specific region, that region's bridge64will be used to gate the busses. Traffic to other regions is not affected.65* In some implementations, the FPGA Manager transparently handles gating the66buses, eliminating the need to show the hardware FPGA bridges in the67device tree.68* An FPGA image may create a set of reprogrammable regions, each having its69own bridge and its own split of the busses in the FPGA.7071FPGA Manager72* An FPGA Manager is a hardware block that programs an FPGA under the control73of a host processor.7475Base Image76* Also called the "static image"77* An FPGA image that is designed to do full reconfiguration of the FPGA.78* A base image may set up a set of partial reconfiguration regions that may79later be reprogrammed.8081---------------- ----------------------------------82| Host CPU | | FPGA |83| | | |84| ----| | ----------- -------- |85| | H | | |==>| Bridge0 |<==>| PRR0 | |86| | W | | | ----------- -------- |87| | | | | |88| | B |<=====>|<==| ----------- -------- |89| | R | | |==>| Bridge1 |<==>| PRR1 | |90| | I | | | ----------- -------- |91| | D | | | |92| | G | | | ----------- -------- |93| | E | | |==>| Bridge2 |<==>| PRR2 | |94| ----| | ----------- -------- |95| | | |96---------------- ----------------------------------9798Figure 1: An FPGA set up with a base image that created three regions. Each99region (PRR0-2) gets its own split of the busses that is independently gated by100a soft logic bridge (Bridge0-2) in the FPGA. The contents of each PRR can be101reprogrammed independently while the rest of the system continues to function.102103104Sequence105========106107When a DT overlay that targets an FPGA Region is applied, the FPGA Region will108do the following:1091101. Disable appropriate FPGA bridges.1112. Program the FPGA using the FPGA manager.1123. Enable the FPGA bridges.1134. The Device Tree overlay is accepted into the live tree.1145. Child devices are populated.115116When the overlay is removed, the child nodes will be removed and the FPGA Region117will disable the bridges.118119120FPGA Region121===========122123FPGA Regions represent FPGA's and FPGA PR regions in the device tree. An FPGA124Region brings together the elements needed to program on a running system and125add the child devices:126127* FPGA Manager128* FPGA Bridges129* image-specific information needed to to the programming.130* child nodes131132The intended use is that a Device Tree overlay (DTO) can be used to reprogram an133FPGA while an operating system is running.134135An FPGA Region that exists in the live Device Tree reflects the current state.136If the live tree shows a "firmware-name" property or child nodes under an FPGA137Region, the FPGA already has been programmed. A DTO that targets an FPGA Region138and adds the "firmware-name" property is taken as a request to reprogram the139FPGA. After reprogramming is successful, the overlay is accepted into the live140tree.141142The base FPGA Region in the device tree represents the FPGA and supports full143reconfiguration. It must include a phandle to an FPGA Manager. The base144FPGA region will be the child of one of the hardware bridges (the bridge that145allows register access) between the cpu and the FPGA. If there are more than146one bridge to control during FPGA programming, the region will also contain a147list of phandles to the additional hardware FPGA Bridges.148149For partial reconfiguration (PR), each PR region will have an FPGA Region.150These FPGA regions are children of FPGA bridges which are then children of the151base FPGA region. The "Full Reconfiguration to add PRR's" example below shows152this.153154If an FPGA Region does not specify an FPGA Manager, it will inherit the FPGA155Manager specified by its ancestor FPGA Region. This supports both the case156where the same FPGA Manager is used for all of an FPGA as well the case where157a different FPGA Manager is used for each region.158159FPGA Regions do not inherit their ancestor FPGA regions' bridges. This prevents160shutting down bridges that are upstream from the other active regions while one161region is getting reconfigured (see Figure 1 above). During PR, the FPGA's162hardware bridges remain enabled. The PR regions' bridges will be FPGA bridges163within the static image of the FPGA.164165Required properties:166- compatible : should contain "fpga-region"167- fpga-mgr : should contain a phandle to an FPGA Manager. Child FPGA Regions168inherit this property from their ancestor regions. An fpga-mgr property169in a region will override any inherited FPGA manager.170- #address-cells, #size-cells, ranges : must be present to handle address space171mapping for child nodes.172173Optional properties:174- firmware-name : should contain the name of an FPGA image file located on the175firmware search path. If this property shows up in a live device tree176it indicates that the FPGA has already been programmed with this image.177If this property is in an overlay targeting an FPGA region, it is a178request to program the FPGA with that image.179- fpga-bridges : should contain a list of phandles to FPGA Bridges that must be180controlled during FPGA programming along with the parent FPGA bridge.181This property is optional if the FPGA Manager handles the bridges.182If the fpga-region is the child of an fpga-bridge, the list should not183contain the parent bridge.184- partial-fpga-config : boolean, set if partial reconfiguration is to be done,185otherwise full reconfiguration is done.186- external-fpga-config : boolean, set if the FPGA has already been configured187prior to OS boot up.188- encrypted-fpga-config : boolean, set if the bitstream is encrypted189- region-unfreeze-timeout-us : The maximum time in microseconds to wait for190bridges to successfully become enabled after the region has been191programmed.192- region-freeze-timeout-us : The maximum time in microseconds to wait for193bridges to successfully become disabled before the region has been194programmed.195- config-complete-timeout-us : The maximum time in microseconds time for the196FPGA to go to operating mode after the region has been programmed.197- child nodes : devices in the FPGA after programming.198199In the example below, when an overlay is applied targeting fpga-region0,200fpga_mgr is used to program the FPGA. Two bridges are controlled during201programming: the parent fpga_bridge0 and fpga_bridge1. Because the region is202the child of fpga_bridge0, only fpga_bridge1 needs to be specified in the203fpga-bridges property. During programming, these bridges are disabled, the204firmware specified in the overlay is loaded to the FPGA using the FPGA manager205specified in the region. If FPGA programming succeeds, the bridges are206reenabled and the overlay makes it into the live device tree. The child devices207are then populated. If FPGA programming fails, the bridges are left disabled208and the overlay is rejected. The overlay's ranges property maps the lwhps209bridge's region (0xff200000) and the hps bridge's region (0xc0000000) for use by210the two child devices.211212Example:213Base tree contains:214215fpga_mgr: fpga-mgr@ff706000 {216compatible = "altr,socfpga-fpga-mgr";217reg = <0xff706000 0x10002180xffb90000 0x20>;219interrupts = <0 175 4>;220};221222fpga_bridge0: fpga-bridge@ff400000 {223compatible = "altr,socfpga-lwhps2fpga-bridge";224reg = <0xff400000 0x100000>;225resets = <&rst LWHPS2FPGA_RESET>;226clocks = <&l4_main_clk>;227228#address-cells = <1>;229#size-cells = <1>;230ranges;231232fpga_region0: fpga-region0 {233compatible = "fpga-region";234fpga-mgr = <&fpga_mgr>;235};236};237238fpga_bridge1: fpga-bridge@ff500000 {239compatible = "altr,socfpga-hps2fpga-bridge";240reg = <0xff500000 0x10000>;241resets = <&rst HPS2FPGA_RESET>;242clocks = <&l4_main_clk>;243};244245Overlay contains:246247/dts-v1/;248/plugin/;249250&fpga_region0 {251#address-cells = <1>;252#size-cells = <1>;253254firmware-name = "soc_system.rbf";255fpga-bridges = <&fpga_bridge1>;256ranges = <0x20000 0xff200000 0x100000>,257<0x0 0xc0000000 0x20000000>;258259gpio@10040 {260compatible = "altr,pio-1.0";261reg = <0x10040 0x20>;262altr,ngpio = <4>;263#gpio-cells = <2>;264clocks = <2>;265gpio-controller;266};267268onchip-memory {269device_type = "memory";270compatible = "altr,onchipmem-15.1";271reg = <0x0 0x10000>;272};273};274275276Supported Use Models277====================278279In all cases the live DT must have the FPGA Manager, FPGA Bridges (if any), and280a FPGA Region. The target of the Device Tree Overlay is the FPGA Region. Some281uses are specific to an FPGA device.282283* No FPGA Bridges284In this case, the FPGA Manager which programs the FPGA also handles the285bridges behind the scenes. No FPGA Bridge devices are needed for full286reconfiguration.287288* Full reconfiguration with hardware bridges289In this case, there are hardware bridges between the processor and FPGA that290need to be controlled during full reconfiguration. Before the overlay is291applied, the live DT must include the FPGA Manager, FPGA Bridges, and a292FPGA Region. The FPGA Region is the child of the bridge that allows293register access to the FPGA. Additional bridges may be listed in a294fpga-bridges property in the FPGA region or in the device tree overlay.295296* Partial reconfiguration with bridges in the FPGA297In this case, the FPGA will have one or more PRR's that may be programmed298separately while the rest of the FPGA can remain active. To manage this,299bridges need to exist in the FPGA that can gate the buses going to each FPGA300region while the buses are enabled for other sections. Before any partial301reconfiguration can be done, a base FPGA image must be loaded which includes302PRR's with FPGA bridges. The device tree should have an FPGA region for each303PRR.304305Device Tree Examples306====================307308The intention of this section is to give some simple examples, focusing on309the placement of the elements detailed above, especially:310* FPGA Manager311* FPGA Bridges312* FPGA Region313* ranges314* target-path or target315316For the purposes of this section, I'm dividing the Device Tree into two parts,317each with its own requirements. The two parts are:318* The live DT prior to the overlay being added319* The DT overlay320321The live Device Tree must contain an FPGA Region, an FPGA Manager, and any FPGA322Bridges. The FPGA Region's "fpga-mgr" property specifies the manager by phandle323to handle programming the FPGA. If the FPGA Region is the child of another FPGA324Region, the parent's FPGA Manager is used. If FPGA Bridges need to be involved,325they are specified in the FPGA Region by the "fpga-bridges" property. During326FPGA programming, the FPGA Region will disable the bridges that are in its327"fpga-bridges" list and will re-enable them after FPGA programming has328succeeded.329330The Device Tree Overlay will contain:331* "target-path" or "target"332The insertion point where the contents of the overlay will go into the333live tree. target-path is a full path, while target is a phandle.334* "ranges"335The address space mapping from processor to FPGA bus(ses).336* "firmware-name"337Specifies the name of the FPGA image file on the firmware search338path. The search path is described in the firmware class documentation.339* "partial-fpga-config"340This binding is a boolean and should be present if partial reconfiguration341is to be done.342* child nodes corresponding to hardware that will be loaded in this region of343the FPGA.344345Device Tree Example: Full Reconfiguration without Bridges346=========================================================347348Live Device Tree contains:349fpga_mgr0: fpga-mgr@f8007000 {350compatible = "xlnx,zynq-devcfg-1.0";351reg = <0xf8007000 0x100>;352interrupt-parent = <&intc>;353interrupts = <0 8 4>;354clocks = <&clkc 12>;355clock-names = "ref_clk";356syscon = <&slcr>;357};358359fpga_region0: fpga-region0 {360compatible = "fpga-region";361fpga-mgr = <&fpga_mgr0>;362#address-cells = <0x1>;363#size-cells = <0x1>;364ranges;365};366367DT Overlay contains:368369/dts-v1/;370/plugin/;371372&fpga_region0 {373#address-cells = <1>;374#size-cells = <1>;375376firmware-name = "zynq-gpio.bin";377378gpio1: gpio@40000000 {379compatible = "xlnx,xps-gpio-1.00.a";380reg = <0x40000000 0x10000>;381gpio-controller;382#gpio-cells = <0x2>;383xlnx,gpio-width= <0x6>;384};385};386387Device Tree Example: Full Reconfiguration to add PRR's388======================================================389390The base FPGA Region is specified similar to the first example above.391392This example programs the FPGA to have two regions that can later be partially393configured. Each region has its own bridge in the FPGA fabric.394395DT Overlay contains:396397/dts-v1/;398/plugin/;399400&fpga_region0 {401#address-cells = <1>;402#size-cells = <1>;403404firmware-name = "base.rbf";405406fpga-bridge@4400 {407compatible = "altr,freeze-bridge-controller";408reg = <0x4400 0x10>;409410fpga_region1: fpga-region1 {411compatible = "fpga-region";412#address-cells = <0x1>;413#size-cells = <0x1>;414ranges;415};416};417418fpga-bridge@4420 {419compatible = "altr,freeze-bridge-controller";420reg = <0x4420 0x10>;421422fpga_region2: fpga-region2 {423compatible = "fpga-region";424#address-cells = <0x1>;425#size-cells = <0x1>;426ranges;427};428};429};430431Device Tree Example: Partial Reconfiguration432============================================433434This example reprograms one of the PRR's set up in the previous example.435436The sequence that occurs when this overlay is similar to the above, the only437differences are that the FPGA is partially reconfigured due to the438"partial-fpga-config" boolean and the only bridge that is controlled during439programming is the FPGA based bridge of fpga_region1.440441/dts-v1/;442/plugin/;443444&fpga_region1 {445#address-cells = <1>;446#size-cells = <1>;447448firmware-name = "soc_image2.rbf";449partial-fpga-config;450451gpio@10040 {452compatible = "altr,pio-1.0";453reg = <0x10040 0x20>;454clocks = <0x2>;455altr,ngpio = <0x4>;456#gpio-cells = <0x2>;457gpio-controller;458};459};460461Constraints462===========463464It is beyond the scope of this document to fully describe all the FPGA design465constraints required to make partial reconfiguration work[1] [2] [3], but a few466deserve quick mention.467468A persona must have boundary connections that line up with those of the partition469or region it is designed to go into.470471During programming, transactions through those connections must be stopped and472the connections must be held at a fixed logic level. This can be achieved by473FPGA Bridges that exist on the FPGA fabric prior to the partial reconfiguration.474475--476[1] www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug_partrecon.pdf477[2] tspace.library.utoronto.ca/bitstream/1807/67932/1/Byma_Stuart_A_201411_MAS_thesis.pdf478[3] https://www.xilinx.com/support/documentation/sw_manuals/xilinx14_1/ug702.pdf479480481