# FPGA Region

_Peios Kernel / Hardware and drivers / Device-tree binding reference / Fpga bindings_

> Device-tree binding reference for FPGA Region.

<!-- SPDX-License-Identifier: GPL-2.0 -->


<a id="dt-root"></a>

**Schema identifier (<code>&#36;id</code>):** <span id="dt-09f478f44eb202ea573e"><code>&#34;http&#58;&#47;&#47;devicetree&#46;org&#47;schemas&#47;fpga&#47;fpga&#45;region&#46;yaml&#35;&#34;</code></span>

**Schema dialect (<code>&#36;schema</code>):** <span id="dt-dcb375baab6014763a68"><code>&#34;http&#58;&#47;&#47;devicetree&#46;org&#47;meta&#45;schemas&#47;core&#46;yaml&#35;&#34;</code></span>

<a id="dt-e46b5a5dd81dbd751c9f"></a>

**Maintainers (<code>maintainers</code>):** <a id="dt-fbc39820abb8bb999095"></a> <span id="dt-fb78ddfc22abfc6fe56d"><code>&#34;Michal Simek &#60;michal&#46;simek&#64;amd&#46;com&#62;&#34;</code></span>

<div id="dt-6d1c5ef59f0239d38c02">
<p style="white-space: pre-wrap">CONTENTS
 - Introduction
 - Terminology
 - Sequence
 - FPGA Region
 - Supported Use Models
 - Constraints</p>
<p style="white-space: pre-wrap">Introduction
============</p>
<p style="white-space: pre-wrap">FPGA Regions represent FPGA's and partial reconfiguration regions of FPGA's in
the Device Tree.  FPGA Regions provide a way to program FPGAs under device tree
control.</p>
<p style="white-space: pre-wrap">The documentation hits some of the high points of FPGA usage and
attempts to include terminology used by both major FPGA manufacturers.  This
document isn't a replacement for any manufacturers specifications for FPGA
usage.</p>
<p style="white-space: pre-wrap">Terminology
===========</p>
<p style="white-space: pre-wrap">Full Reconfiguration
 * The entire FPGA is programmed.</p>
<pre><code>Partial Reconfiguration (PR)
 * A section of an FPGA is reprogrammed while the rest of the FPGA is not
   affected.
 * Not all FPGA's support PR.</code></pre>
<pre><code>Partial Reconfiguration Region (PRR)
 * Also called a "reconfigurable partition"
 * A PRR is a specific section of an FPGA reserved for reconfiguration.
 * A base (or static) FPGA image may create a set of PRR's that later may
   be independently reprogrammed many times.
 * The size and specific location of each PRR is fixed.
 * The connections at the edge of each PRR are fixed.  The image that is loaded
   into a PRR must fit and must use a subset of the region's connections.
 * The busses within the FPGA are split such that each region gets its own
   branch that may be gated independently.</code></pre>
<pre><code>Persona
 * Also called a "partial bit stream"
 * An FPGA image that is designed to be loaded into a PRR.  There may be
   any number of personas designed to fit into a PRR, but only one at a time
   may be loaded.
 * A persona may create more regions.</code></pre>
<pre><code>FPGA Bridge
 * FPGA Bridges gate bus signals between a host and FPGA.
 * FPGA Bridges should be disabled while the FPGA is being programmed to
   prevent spurious signals on the cpu bus and to the soft logic.
 * FPGA bridges may be actual hardware or soft logic on an FPGA.
 * During Full Reconfiguration, hardware bridges between the host and FPGA
   will be disabled.
 * During Partial Reconfiguration of a specific region, that region's bridge
   will be used to gate the busses.  Traffic to other regions is not affected.
 * In some implementations, the FPGA Manager transparently handles gating the
   buses, eliminating the need to show the hardware FPGA bridges in the
   device tree.
 * An FPGA image may create a set of reprogrammable regions, each having its
   own bridge and its own split of the busses in the FPGA.</code></pre>
<pre><code>FPGA Manager
 * An FPGA Manager is a hardware block that programs an FPGA under the control
   of a host processor.</code></pre>
<pre><code>Base Image
 * Also called the "static image"
 * An FPGA image that is designed to do full reconfiguration of the FPGA.
 * A base image may set up a set of partial reconfiguration regions that may
   later be reprogrammed.</code></pre>
<pre><code>    ----------------       ----------------------------------
    |  Host CPU    |       |             FPGA               |
    |              |       |                                |
    |          ----|       |       -----------    --------  |
    |          | H |       |   |==&gt;| Bridge0 |&lt;==&gt;| PRR0 |  |
    |          | W |       |   |   -----------    --------  |
    |          |   |       |   |                            |
    |          | B |&lt;=====&gt;|&lt;==|   -----------    --------  |
    |          | R |       |   |==&gt;| Bridge1 |&lt;==&gt;| PRR1 |  |
    |          | I |       |   |   -----------    --------  |
    |          | D |       |   |                            |
    |          | G |       |   |   -----------    --------  |
    |          | E |       |   |==&gt;| Bridge2 |&lt;==&gt;| PRR2 |  |
    |          ----|       |       -----------    --------  |
    |              |       |                                |
    ----------------       ----------------------------------</code></pre>
<p style="white-space: pre-wrap">Figure 1: An FPGA set up with a base image that created three regions.  Each
region (PRR0-2) gets its own split of the busses that is independently gated by
a soft logic bridge (Bridge0-2) in the FPGA.  The contents of each PRR can be
reprogrammed independently while the rest of the system continues to function.</p>
<p style="white-space: pre-wrap">Sequence
========</p>
<p style="white-space: pre-wrap">When a DT overlay that targets an FPGA Region is applied, the FPGA Region will
do the following:</p>
<p style="white-space: pre-wrap"> 1. Disable appropriate FPGA bridges.
 2. Program the FPGA using the FPGA manager.
 3. Enable the FPGA bridges.
 4. The Device Tree overlay is accepted into the live tree.
 5. Child devices are populated.</p>
<p style="white-space: pre-wrap">When the overlay is removed, the child nodes will be removed and the FPGA Region
will disable the bridges.</p>
<p style="white-space: pre-wrap">FPGA Region
===========</p>
<p style="white-space: pre-wrap">FPGA Regions represent FPGA's and FPGA PR regions in the device tree.  An FPGA
Region brings together the elements needed to program on a running system and
add the child devices:</p>
<p style="white-space: pre-wrap"> * FPGA Manager
 * FPGA Bridges
 * image-specific information needed to the programming.
 * child nodes</p>
<p style="white-space: pre-wrap">The intended use is that a Device Tree overlay (DTO) can be used to reprogram an
FPGA while an operating system is running.</p>
<p style="white-space: pre-wrap">An FPGA Region that exists in the live Device Tree reflects the current state.
If the live tree shows a "firmware-name" property or child nodes under an FPGA
Region, the FPGA already has been programmed.  A DTO that targets an FPGA Region
and adds the "firmware-name" property is taken as a request to reprogram the
FPGA.  After reprogramming is successful, the overlay is accepted into the live
tree.</p>
<p style="white-space: pre-wrap">The base FPGA Region in the device tree represents the FPGA and supports full
reconfiguration.  It must include a phandle to an FPGA Manager.  The base
FPGA region will be the child of one of the hardware bridges (the bridge that
allows register access) between the cpu and the FPGA.  If there are more than
one bridge to control during FPGA programming, the region will also contain a
list of phandles to the additional hardware FPGA Bridges.</p>
<p style="white-space: pre-wrap">For partial reconfiguration (PR), each PR region will have an FPGA Region.
These FPGA regions are children of FPGA bridges which are then children of the
base FPGA region.  The "Full Reconfiguration to add PRR's" example below shows
this.</p>
<p style="white-space: pre-wrap">If an FPGA Region does not specify an FPGA Manager, it will inherit the FPGA
Manager specified by its ancestor FPGA Region.  This supports both the case
where the same FPGA Manager is used for all of an FPGA as well the case where
a different FPGA Manager is used for each region.</p>
<p style="white-space: pre-wrap">FPGA Regions do not inherit their ancestor FPGA regions' bridges.  This prevents
shutting down bridges that are upstream from the other active regions while one
region is getting reconfigured (see Figure 1 above).  During PR, the FPGA's
hardware bridges remain enabled.  The PR regions' bridges will be FPGA bridges
within the static image of the FPGA.</p>
<p style="white-space: pre-wrap">Supported Use Models
====================</p>
<p style="white-space: pre-wrap">In all cases the live DT must have the FPGA Manager, FPGA Bridges (if any), and
a FPGA Region.  The target of the Device Tree Overlay is the FPGA Region.  Some
uses are specific to an FPGA device.</p>
<pre><code> * No FPGA Bridges
   In this case, the FPGA Manager which programs the FPGA also handles the
   bridges behind the scenes.  No FPGA Bridge devices are needed for full
   reconfiguration.</code></pre>
<pre><code> * Full reconfiguration with hardware bridges
   In this case, there are hardware bridges between the processor and FPGA that
   need to be controlled during full reconfiguration.  Before the overlay is
   applied, the live DT must include the FPGA Manager, FPGA Bridges, and a
   FPGA Region.  The FPGA Region is the child of the bridge that allows
   register access to the FPGA.  Additional bridges may be listed in a
   fpga-bridges property in the FPGA region or in the device tree overlay.</code></pre>
<pre><code> * Partial reconfiguration with bridges in the FPGA
   In this case, the FPGA will have one or more PRR's that may be programmed
   separately while the rest of the FPGA can remain active.  To manage this,
   bridges need to exist in the FPGA that can gate the buses going to each FPGA
   region while the buses are enabled for other sections.  Before any partial
   reconfiguration can be done, a base FPGA image must be loaded which includes
   PRR's with FPGA bridges.  The device tree should have an FPGA region for each
   PRR.</code></pre>
<p style="white-space: pre-wrap">Constraints
===========</p>
<p style="white-space: pre-wrap">It is beyond the scope of this document to fully describe all the FPGA design
constraints required to make partial reconfiguration work[1] [2] [3], but a few
deserve quick mention.</p>
<p style="white-space: pre-wrap">A persona must have boundary connections that line up with those of the partition
or region it is designed to go into.</p>
<p style="white-space: pre-wrap">During programming, transactions through those connections must be stopped and
the connections must be held at a fixed logic level.  This can be achieved by
FPGA Bridges that exist on the FPGA fabric prior to the partial reconfiguration.</p>
<p style="white-space: pre-wrap">--
[1] https://www.intel.com/programmable/technical-pdfs/683404.pdf
[2] tspace.library.utoronto.ca/bitstream/1807/67932/1/Byma_Stuart_A_201411_MAS_thesis.pdf
[3] https://docs.amd.com/v/u/en-US/ug702</p>
</div>

<a id="dt-e1f655ed0ff4d595dadc"></a>

## Properties and child nodes (<code>properties</code>)

<a id="dt-5155525ecd924660ec0a"></a>

### <code>&#36;nodename</code> — not listed as required here

**String pattern (<code>pattern</code>):** <span id="dt-0b2111a24a010949ece7"><code>&#34;&#94;fpga&#45;region&#40;&#64;&#46;&#42;&#124;&#45;&#40;&#91;0&#45;9&#93;&#124;&#91;1&#45;9&#93;&#91;0&#45;9&#93;&#43;&#41;&#41;&#63;&#36;&#34;</code></span>

<a id="dt-5c1d81699dcbe840de83"></a>

### <code>compatible</code> — required here

**Exact value (<code>const</code>):** <span id="dt-1765195bf8e86c3ccec6"><code>&#34;fpga&#45;region&#34;</code></span>

<a id="dt-9c1635fdb65d87e33d77"></a>

### <code>reg</code> — not listed as required here

**Maximum number of items (<code>maxItems</code>):** <span id="dt-71421d35675d9a533ad2"><code>1</code></span>

<a id="dt-1e6b10cf5f67a6a268f5"></a>

### <code>ranges</code> — not listed as required here

<code>true</code> — No constraints added by this property rule.

<a id="dt-2efe70314a961a652abe"></a>

### <code>&#35;address&#45;cells</code> — not listed as required here

<code>true</code> — No constraints added by this property rule.

<a id="dt-ee0e5bf71366d312f1dc"></a>

### <code>&#35;size&#45;cells</code> — not listed as required here

<code>true</code> — No constraints added by this property rule.

<a id="dt-41486407d6ce4fb322d3"></a>

### <code>config&#45;complete&#45;timeout&#45;us</code> — not listed as required here

<div id="dt-f5f63f15dca7cfa977a0">
<p style="white-space: pre-wrap">The maximum time in microseconds time for the FPGA to go to operating mode after the region has been programmed.</p>
</div>

<a id="dt-64e2d6eac7f4ae497d6e"></a>

### <code>encrypted&#45;fpga&#45;config</code> — not listed as required here

**Value type (<code>type</code>):** <span id="dt-aa17b03e8d7d1e2901e6"><code>&#34;boolean&#34;</code></span>

<div id="dt-8fe3fc3efbb89ec019ea">
<p style="white-space: pre-wrap">Set if the bitstream is encrypted.</p>
</div>

<a id="dt-8a0a4e9a3719aa979f7a"></a>

### <code>external&#45;fpga&#45;config</code> — not listed as required here

**Value type (<code>type</code>):** <span id="dt-96b90572593792ec057a"><code>&#34;boolean&#34;</code></span>

<div id="dt-20f75518931862eb57ec">
<p style="white-space: pre-wrap">Set if the FPGA has already been configured prior to OS boot up.</p>
</div>

<a id="dt-b913167a56819d67f1a5"></a>

### <code>firmware&#45;name</code> — not listed as required here

**Maximum number of items (<code>maxItems</code>):** <span id="dt-664bc4dc24f43c53b737"><code>1</code></span>

<div id="dt-0b76b2c415d449884d95">
<p style="white-space: pre-wrap">Should contain the name of an FPGA image file located on the firmware search path. If this property shows up in a live device tree it indicates that the FPGA has already been programmed with this image. If this property is in an overlay targeting an FPGA region, it is a request to program the FPGA with that image.</p>
</div>

<a id="dt-1b3e130edeed367d8daf"></a>

### <code>fpga&#45;bridges</code> — not listed as required here

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-96d7e61d98c5a3861577">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;phandle&#45;array</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-8f5710c4314b4caa4970>)</span>

<div id="dt-edc3e16cfe2792f366c2">
<p style="white-space: pre-wrap">Should contain a list of phandles to FPGA Bridges that must be controlled during FPGA programming along with the parent FPGA bridge. This property is optional if the FPGA Manager handles the bridges. If the fpga-region is  the child of an fpga-bridge, the list should not contain the parent bridge.</p>
</div>

<a id="dt-e27c827246b97ff85c7b"></a>

### <code>fpga&#45;mgr</code> — required here

**Shared schema rule (<code>&#36;ref</code>):** <span id="dt-847d1c4ce9f795ec916c">[<code>&#47;schemas&#47;types&#46;yaml&#35;&#47;definitions&#47;phandle</code>](</kernel/hardware/devicetree-bindings/dt-shared/types.md#dt-2533fa46618221e83225>)</span>

<div id="dt-735704247a31eb105dd2">
<p style="white-space: pre-wrap">Should contain a phandle to an FPGA Manager.  Child FPGA Regions inherit this property from their ancestor regions.  An fpga-mgr property in a region will override any inherited FPGA manager.</p>
</div>

<a id="dt-2434717b8356aea1b77e"></a>

### <code>partial&#45;fpga&#45;config</code> — not listed as required here

**Value type (<code>type</code>):** <span id="dt-0074d7f17d1fcd70246a"><code>&#34;boolean&#34;</code></span>

<div id="dt-a9a37bd48f33d13a01b9">
<p style="white-space: pre-wrap">Set if partial reconfiguration is to be done, otherwise full reconfiguration is done.</p>
</div>

<a id="dt-9a0acccbefa1e8b67a75"></a>

### <code>region&#45;freeze&#45;timeout&#45;us</code> — not listed as required here

<div id="dt-8c82401f97e256cf6b36">
<p style="white-space: pre-wrap">The maximum time in microseconds to wait for bridges to successfully become disabled before the region has been programmed.</p>
</div>

<a id="dt-06ec638b23153d438cbb"></a>

### <code>region&#45;unfreeze&#45;timeout&#45;us</code> — not listed as required here

<div id="dt-28ee87ce338d52a9f107">
<p style="white-space: pre-wrap">The maximum time in microseconds to wait for bridges to successfully become enabled after the region has been programmed.</p>
</div>

**Required in this object (<code>required</code>):** <a id="dt-8313173ff1c9b300d560"></a> <span id="dt-048b70ee865d6847aa3d"><code>&#34;compatible&#34;</code></span>, <span id="dt-ee7433925c1528c16b99"><code>&#34;fpga&#45;mgr&#34;</code></span>

<a id="dt-738c4b4f9e483441138b"></a>

## Properties not matched by properties or patternProperties in this schema (<code>additionalProperties</code>)

> **Value type (<code>type</code>):** <span id="dt-3363ef09170715607dca"><code>&#34;object&#34;</code></span>

<a id="dt-1a130cabaa8a47b058bf"></a>

## Examples (<code>examples</code>)

<pre id="dt-0bd6510295af0c95ff2d"><code class="language-dts">/*
 * Full Reconfiguration without Bridges with DT overlay
 */
fpga_region0: fpga-region@0 {
  compatible = "fpga-region";
  reg = &lt;0 0&gt;;
  #address-cells = &lt;1&gt;;
  #size-cells = &lt;1&gt;;
  fpga-mgr = &lt;&amp;fpga_mgr0&gt;;
  ranges = &lt;0x10000000 0x20000000 0x10000000&gt;;

  /* DT Overlay contains: &amp;fpga_region0 */
  firmware-name = "zynq-gpio.bin";
  gpio@40000000 {
    compatible = "xlnx,xps-gpio-1.00.a";
    reg = &lt;0x40000000 0x10000&gt;;
    gpio-controller;
    #gpio-cells = &lt;2&gt;;
    clocks = &lt;&amp;clk&gt;;
  };
};
</code></pre>

<pre id="dt-bae0d43ea48e35208b4a"><code class="language-dts">/*
 * Partial reconfiguration with bridge
 */
fpga_region1: fpga-region@0 {
  compatible = "fpga-region";
  reg = &lt;0 0&gt;;
  ranges;
  #address-cells = &lt;1&gt;;
  #size-cells = &lt;1&gt;;
  fpga-mgr = &lt;&amp;fpga_mgr1&gt;;
  fpga-bridges = &lt;&amp;fpga_bridge1&gt;;
  partial-fpga-config;

  /* DT Overlay contains: &amp;fpga_region1 */
  firmware-name = "zynq-gpio-partial.bin";
  clk: clock {
    compatible = "fixed-factor-clock";
    clocks = &lt;&amp;parentclk&gt;;
    #clock-cells = &lt;0&gt;;
    clock-div = &lt;2&gt;;
    clock-mult = &lt;1&gt;;
  };
  axi {
    compatible = "simple-bus";
    #address-cells = &lt;1&gt;;
    #size-cells = &lt;1&gt;;
    ranges;
    gpio@40000000 {
      compatible = "xlnx,xps-gpio-1.00.a";
      reg = &lt;0x40000000 0x10000&gt;;
      #gpio-cells = &lt;2&gt;;
      gpio-controller;
      clocks = &lt;&amp;clk&gt;;
    };
  };
};
</code></pre>

## Source notes

<details>
<summary>Annotations retained from the schema source</summary>

<p id="dt-comment-0"><strong>Line 1:</strong> <span> SPDX-License-Identifier: GPL-2.0</span></p>

</details>
