Device Tree support for FPGA Programming
v19 cover Device Tree support for FPGA Programming
This patchset support FPGA programming under the control of Device Tree overlays.
A few patches that were acked have been left out of the patchset, but continued development has caused this patchset to swell a bit.
I'm proposing a minor change to the FPGA Manager API. The change is to substitute the 'flags' paramater with a pointer to a 'struct fpga_image_info'. The reason for this: I'm running into cases where an FPGA image has properties that affect how it is programmed into the FPGA. These properties are specific to the design in the image and would be useful to pass in a struct to the FPGA manager and bridges. The DT overlays support can populate the struct from DT properties in the overlay.
The first examples I've run against are that depending on the complexity of the design in an image, the time that a bridge takes to be enabled or disabled can vary. These patches add the timeouts for bridge enable/disable into the device tree overlay and add a FPGA image info struct to the API. Changes to the existing socfpga and zynq driver are tiny; a couple lines each. Other future additions to the FPGA image info struct may include timeout values for the FPGA to go to operating mode after programming and other bridge specifics such as width.
Rob suggested that fpga-regions be children of bridges so that is supported here. Since a region may need >1 bridge, a list additional bridges can be added with the fpga-bridges property. I've cleaned up the bindings doc to be correct DT-wise. Hopefully!
This patch set includes:
* Support fpga-regions being children of fpga-bridges
* fixes and rewrites for the FPGA Regions DT binding doc
* fpga image info struct support
* support the bridges and region built as modules
* fix the hps bridges from stomping on each others' use of a shared register. Note that the register has no other bits than those used by the hps bridge driver.
* fix a potential race condition in hps bridge driver probe
* remove an unneeded pr_err from fpga-region.c
* remove some clk_puts - incorrect due to devm_clk_get
* add altera freeze bridge
The following were acked so they are no longer in this patch set:
* bindings for Altera SOCFPGA bridges
https://patchwork.kernel.org/patch/9226093/
* bindings for Arria 10 FPGA Mgr
https://patchwork.kernel.org/patch/9226111/
* "[PATCH v3] of/overlay: add of overlay notifications"
https://lkml.org/lkml/2016/4/19/704
The patchset is dependent on:
* Pantelis Antonious's dtc changes for dynamic device tree.
https://github.com/pantoniou/dtc.git
* Pantelis' configfs interface patches and fixes
https://github.com/pantoniou/linux-beagle-track-mainline
Alan
Alan Tull (12):
fpga: add bindings document for fpga region
doc: fpga-mgr: add fpga image info to api
add bindings document for altera freeze bridge add sysfs document for fpga bridge class
fpga-mgr: add fpga image information struct
fpga: add fpga image information struct for socfpga support
fpga: add fpga image information struct for zynq support
fpga: add fpga bridge framework
fpga: fpga-region: device tree control for FPGA
ARM: socfpga: fpga bridge driver support
fpga: add altera freeze bridge support
fpga-manager: Add Socfpga Arria10 support
Documentation/ABI/testing/sysfs-class-fpga-bridge | 11 + .../bindings/fpga/altera-freeze-bridge.txt | 23 + .../devicetree/bindings/fpga/fpga-region.txt | 494 +++++++++++++++++ Documentation/fpga/fpga-mgr.txt | 32 +- drivers/fpga/Kconfig | 36 ++ drivers/fpga/Makefile | 9 + drivers/fpga/altera-fpga2sdram.c | 180 ++++++ drivers/fpga/altera-freeze-bridge.c | 273 ++++++++++ drivers/fpga/altera-hps2fpga.c | 221 ++++++++ drivers/fpga/fpga-bridge.c | 398 ++++++++++++++ drivers/fpga/fpga-mgr.c | 17 +- drivers/fpga/fpga-region.c | 603 +++++++++++++++++++++ drivers/fpga/socfpga-a10.c | 572 +++++++++++++++++++ drivers/fpga/socfpga.c | 7 +- drivers/fpga/zynq-fpga.c | 10 +- include/linux/fpga/fpga-bridge.h | 60 ++ include/linux/fpga/fpga-mgr.h | 25 +- 17 files changed, 2941 insertions(+), 30 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-bridge create mode 100644 Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt create mode 100644 Documentation/devicetree/bindings/fpga/fpga-region.txt create mode 100644 drivers/fpga/altera-fpga2sdram.c create mode 100644 drivers/fpga/altera-freeze-bridge.c create mode 100644 drivers/fpga/altera-hps2fpga.c create mode 100644 drivers/fpga/fpga-bridge.c create mode 100644 drivers/fpga/fpga-region.c create mode 100644 drivers/fpga/socfpga-a10.c create mode 100644 include/linux/fpga/fpga-bridge.h
Signature · 1 line
2.9.3
PATCH v19 1/12 fpga: add bindings document for fpga region
New bindings document for FPGA Region to support programming FPGA's under Device Tree control
---
v9: initial version added to this patchset v10: s/fpga/FPGA/g
replace DT overlay example with slightly more complicated example move to staging/simple-fpga-bus
v11: No change in this patch for v11 of the patch set
v12: Moved out of staging.
Changed to use FPGA bridges framework instead of resets for bridges.
v13: bridge at 0xff20000 -> bridge at ff200000, etc
Leave out directly talking about overlays
Remove regs and clocks directly under simple-fpga-bus in example Use common "firmware-name" binding instead of "fpga-firmware"
v14: Use firmware-name in bindings description
Call it FPGA Area
Remove bindings that specify FPGA Manager and FPGA Bridges
v15: Cleanup as per Rob's comments
Combine usage doc with bindings document
Document as being Altera specific
Additions and changes to add FPGA Bus
v16: Reworked to document FPGA Regions
rename altera-fpga-bus-fpga-area.txt -> fpga-region.txt Remove references that made it sound exclusive to Altera Remove altr, prefix from fpga-bus and fpga-area compatible strings Added Moritz' usage example with Xilinx
Cleaned up unit addresses
v17: Lots of rewrites to try to make things clearer
Clarify that overlay can be rejected if FPGA isn't programmed Add external-fpga-config binding already used in u-boot Change partial-reconfig binding to partial-fpga-config to align
with existing u-boot binding format *-fpga-config
Add a document from Xilinx' website
v18: Fix node names underscores to be hyphens
Fix copy/pasted duplicate nodes in diagram
v19: Fix more underscores
Make FPGA regions to be children of bridges
General cleanup and clarification
--- .../devicetree/bindings/fpga/fpga-region.txt | 494 +++++++++++++++++++++ 1 file changed, 494 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/fpga-region.txt
Documentation/devicetree/bindings/fpga/fpga-region.txt new file +494 -0
@@ -0,0 +1,494 @@ +FPGA Region Device Tree Binding + +Alan Tull 2016 + + CONTENTS + - Introduction + - Terminology + - Sequence + - FPGA Region + - Supported Use Models + - Device Tree Examples + - Constraints + + +Introduction +============ + +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. + +This device tree binding document 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. + + +Terminology +=========== + +Full Reconfiguration + * The entire FPGA is programmed. + +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. + +Partial Reconfiguration Region (PRR) + * Also called a "reconfigurable partition" + * A PRR is a specific section of a 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. + +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 at time + may be loaded. + * A persona may create more regions. + +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 transparantly 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. + +FPGA Manager + * An FPGA Manager is a hardware block that programs an FPGA under the control + of a host processor. + +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. + + ---------------- ---------------------------------- + | Host CPU | | FPGA | + | | | | + | ----| | ----------- -------- | + | | H | | |==>| Bridge0 |<==>| PRR0 | | + | | W | | | ----------- -------- | + | | | | | | + | | B |<=====>|<==| ----------- -------- | + | | R | | |==>| Bridge1 |<==>| PRR1 | | + | | I | | | ----------- -------- | + | | D | | | | + | | G | | | ----------- -------- | + | | E | | |==>| Bridge2 |<==>| PRR2 | | + | ----| | ----------- -------- | + | | | | + ---------------- ---------------------------------- + +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. + + +Sequence +======== + +When a DT overlay that targets a FPGA Region is applied, the FPGA Region will +do the following: + + 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. + +When the overlay is removed, the child nodes will be removed and the FPGA Region +will disable the bridges. + + +FPGA Region +=========== + +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: + + * FPGA Manager + * FPGA Bridges + * image-specific information needed to to the programming. + * child nodes + +The intended use is that a Device Tree overlay (DTO) can be used to reprogram an +FPGA while an operating system is running. + +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 a FPGA +Region, the FPGA already has been programmed. A DTO that targets a 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. + +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. + +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. + +If an FPGA Region does not specify a 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 a FPGA as well the case where +a different FPGA Manager is used for each region. + +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. + +Required properties: +- compatible : should contain "fpga-region" +- fpga-mgr : should contain a phandle to an FPGA Manager. Child FPGA Regions + inherit this property from their ancestor regions. A fpga-mgr property + in a region will override any inherited FPGA manager. +- #address-cells, #size-cells, ranges : must be present to handle address space + mapping for child nodes. + +Optional properties: +- firmware-name : 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 a FPGA region, it is a + request to program the FPGA with that image. +- fpga-bridges : 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 a fpga-bridge, the list should not + contain the parent bridge. +- partial-fpga-config : boolean, set if partial reconfiguration is to be done, + otherwise full reconfiguration is done. +- external-fpga-config : boolean, set if the FPGA has already been configured + prior to OS boot up. +- region-unfreeze-timeout-us : The maximum time in microseconds to wait for + bridges to successfully become enabled after the region has been + programmed. +- region-freeze-timeout-us : The maximum time in microseconds to wait for + bridges to successfully become disabled before the region has been + programmed. +- child nodes : devices in the FPGA after programming. + +In the example below, when an overlay is applied targeting fpga-region0, +fpga_mgr is used to program the FPGA. Two bridges are controlled during +programming: the parent fpga_bridge0 and fpga_bridge1. Because the region is +the child of fpga_bridge0, only fpga_bridge1 needs to be specified in the +fpga-bridges property. During programming, these bridges are disabled, the +firmware specified in the overlay is loaded to the FPGA using the FPGA manager +specified in the region. If FPGA programming succeeds, the bridges are +reenabled and the overlay makes it into the live device tree. The child devices +are then populated. If FPGA programming fails, the bridges are left disabled +and the overlay is rejected. The overlay's ranges property maps the lwhps +bridge's region (0xff200000) and the hps bridge's region (0xc0000000) for use by +the two child devices. + +Example: +Base tree contains: + + fpga_mgr: fpga-mgr at ff706000 { + compatible = "altr,socfpga-fpga-mgr"; + reg = <0xff706000 0x1000 + 0xffb90000 0x20>; + interrupts = <0 175 4>; + }; + + fpga_bridge0: fpga-bridge at ff400000 { + compatible = "altr,socfpga-lwhps2fpga-bridge"; + reg = <0xff400000 0x100000>; + resets = <&rst LWHPS2FPGA_RESET>; + clocks = <&l4_main_clk>; + + #address-cells = <1>; + #size-cells = <1>; + ranges; + + fpga_region0: fpga-region0 { + compatible = "fpga-region"; + fpga-mgr = <&fpga_mgr>; + }; + }; + + fpga_bridge1: fpga-bridge at ff500000 { + compatible = "altr,socfpga-hps2fpga-bridge"; + reg = <0xff500000 0x10000>; + resets = <&rst HPS2FPGA_RESET>; + clocks = <&l4_main_clk>; + }; + +Overlay contains: + +/dts-v1/ /plugin/; +/ { + fragment at 0 { + target = <&fpga_region0>; + #address-cells = <1>; + #size-cells = <1>; + __overlay__ { + #address-cells = <1>; + #size-cells = <1>; + + firmware-name = "soc_system.rbf"; + fpga-bridges = <&fpga_bridge1>; + ranges = <0x20000 0xff200000 0x100000>, + <0x0 0xc0000000 0x20000000>; + + gpio at 10040 { + compatible = "altr,pio-1.0"; + reg = <0x10040 0x20>; + altr,gpio-bank-width = <4>; + #gpio-cells = <2>; + clocks = <2>; + gpio-controller; + }; + + onchip-memory { + device_type = "memory"; + compatible = "altr,onchipmem-15.1"; + reg = <0x0 0x10000>; + }; + }; + }; +}; + + +Supported Use Models +==================== + +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 a FPGA device. + + * 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. + + * 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. + + * 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 a FPGA region for each + PRR. + +Device Tree Examples +==================== + +The intention of this section is to give some simple examples, focusing on +the placement of the elements detailed above, especially: + * FPGA Manager + * FPGA Bridges + * FPGA Region + * ranges + * target-path or target + +For the purposes of this section, I'm dividing the Device Tree into two parts, +each with its own requirements. The two parts are: + * The live DT prior to the overlay being added + * The DT overlay + +The live Device Tree must contain an FPGA Region, an FPGA Manager, and any FPGA +Bridges. The FPGA Region's "fpga-mgr" property specifies the manager by phandle +to handle programming the FPGA. If the FPGA Region is the child of another FPGA +Region, the parent's FPGA Manager is used. If FPGA Bridges need to be involved, +they are specified in the FPGA Region by the "fpga-bridges" property. During +FPGA programming, the FPGA Region will disable the bridges that are in its +"fpga-bridges" list and will re-enable them after FPGA programming has +succeeded. + +The Device Tree Overlay will contain: + * "target-path" or "target" + The insertion point where the the contents of the overlay will go into the + live tree. target-path is a full path, while target is a phandle. + * "ranges" + The address space mapping from processor to FPGA bus(ses). + * "firmware-name" + Specifies the name of the FPGA image file on the firmware search + path. The search path is described in the firmware class documentation. + * "partial-fpga-config" + This binding is a boolean and should be present if partial reconfiguration + is to be done. + * child nodes corresponding to hardware that will be loaded in this region of + the FPGA. + +Device Tree Example: Full Reconfiguration without Bridges +========================================================= + +Live Device Tree contains: + fpga_mgr0: fpga-mgr at f8007000 { + compatible = "xlnx,zynq-devcfg-1.0"; + reg = <0xf8007000 0x100>; + interrupt-parent = <&intc>; + interrupts = <0 8 4>; + clocks = <&clkc 12>; + clock-names = "ref_clk"; + syscon = <&slcr>; + }; + + fpga_region0: fpga-region0 { + compatible = "fpga-region"; + fpga-mgr = <&fpga_mgr0>; + #address-cells = <0x1>; + #size-cells = <0x1>; + ranges; + }; + +DT Overlay contains: +/dts-v1/ /plugin/; +/ { +fragment at 0 { + target = <&fpga_region0>; + #address-cells = <1>; + #size-cells = <1>; + __overlay__ { + #address-cells = <1>; + #size-cells = <1>; + + firmware-name = "zynq-gpio.bin"; + + gpio1: gpio at 40000000 { + compatible = "xlnx,xps-gpio-1.00.a"; + reg = <0x40000000 0x10000>; + gpio-controller; + #gpio-cells = <0x2>; + xlnx,gpio-width= <0x6>; + }; + }; +}; + +Device Tree Example: Full Reconfiguration to add PRR's +====================================================== + +The base FPGA Region is specified similar to the first example above. + +This example programs the FPGA to have two regions that can later be partially +configured. Each region has its own bridge in the FPGA fabric. + +DT Overlay contains: +/dts-v1/ /plugin/; +/ { + fragment at 0 { + target = <&fpga_region0>; + #address-cells = <1>; + #size-cells = <1>; + __overlay__ { + #address-cells = <1>; + #size-cells = <1>; + + firmware-name = "base.rbf"; + + fpga-bridge at 4400 { + compatible = "altr,freeze-bridge"; + reg = <0x4400 0x10>; + + fpga_region1: fpga-region1 { + compatible = "fpga-region"; + #address-cells = <0x1>; + #size-cells = <0x1>; + ranges; + }; + }; + + fpga-bridge at 4420 { + compatible = "altr,freeze-bridge"; + reg = <0x4420 0x10>; + + fpga_region2: fpga-region2 { + compatible = "fpga-region"; + #address-cells = <0x1>; + #size-cells = <0x1>; + ranges; + }; + }; + }; + }; +}; + +Device Tree Example: Partial Reconfiguration +============================================ + +This example reprograms one of the PRR's set up in the previous example. + +The sequence that occurs when this overlay is similar to the above, the only +differences are that the FPGA is partially reconfigured due to the +"partial-fpga-config" boolean and the only bridge that is controlled during +programming is the FPGA based bridge of fpga_region1. + +/dts-v1/ /plugin/; +/ { + fragment at 0 { + target = <&fpga_region1>; + #address-cells = <1>; + #size-cells = <1>; + __overlay__ { + #address-cells = <1>; + #size-cells = <1>; + + firmware-name = "soc_image2.rbf"; + partial-fpga-config; + + gpio at 10040 { + compatible = "altr,pio-1.0"; + reg = <0x10040 0x20>; + clocks = <0x2>; + altr,gpio-bank-width = <0x4>; + resetvalue = <0x0>; + #gpio-cells = <0x2>; + gpio-controller; + }; + }; + }; +}; + +Constraints +=========== + +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. + +A persona must have boundary connections that line up with those of the partion +or region it is designed to go into. + +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. + +-- +[1] www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug_partrecon.pdf +[2] tspace.library.utoronto.ca/bitstream/1807/67932/1/Byma_Stuart_A_201411_MAS_thesis.pdf +[3] http://www.xilinx.com/support/documentation/sw_manuals/xilinx14_1/ug702.pdf
Signature · 1 line
2.9.3
Re: [PATCH v19 01/12] fpga: add bindings document for fpga region
Quoted 42 lines · Alan Tull
New bindings document for FPGA Region to support programming FPGA's under Device Tree control
Signed-off-by Alan Tull <[email protected]>Signed-off-by Moritz Fischer <[email protected]>---
v9: initial version added to this patchset v10: s/fpga/FPGA/greplace DT overlay example with slightly more complicated example move to staging/simple-fpga-bus
v11: No change in this patch for v11 of the patch set
v12: Moved out of staging.
Changed to use FPGA bridges framework instead of resets for bridges.
v13: bridge at0xff20000-> bridge atff200000, etc
Leave out directly talking about overlays
Remove regs and clocks directly under simple-fpga-bus in example Use common "firmware-name" binding instead of "fpga-firmware"
v14: Use firmware-name in bindings description
Call it FPGA Area
Remove bindings that specify FPGA Manager and FPGA Bridges
v15: Cleanup as per Rob's comments
Combine usage doc with bindings document
Document as being Altera specific
Additions and changes to add FPGA Bus
v16: Reworked to document FPGA Regions
rename altera-fpga-bus-fpga-area.txt -> fpga-region.txt Remove references that made it sound exclusive to Altera Remove altr, prefix from fpga-bus and fpga-area compatible strings Added Moritz' usage example with Xilinx
Cleaned up unit addresses
v17: Lots of rewrites to try to make things clearer
Clarify that overlay can be rejected if FPGA isn't programmed Add external-fpga-config binding already used in u-boot Change partial-reconfig binding to partial-fpga-config to align
with existing u-boot binding format *-fpga-config
Add a document from Xilinx' website
v18: Fix node names underscores to be hyphens
Fix copy/pasted duplicate nodes in diagram
v19: Fix more underscores
Make FPGA regions to be children of bridges
General cleanup and clarification
Quoted 4 lines
--- .../devicetree/bindings/fpga/fpga-region.txt | 494 +++++++++++++++++++++ 1 file changed, 494 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/fpga-region.txt
Nice job.
Rob
Re: [PATCH v19 01/12] fpga: add bindings document for fpga region
Quoted 48 lines · Rob Herring
Quoted 42 lines · Alan Tull
New bindings document for FPGA Region to support programming FPGA's under Device Tree control
Signed-off-by Alan Tull <[email protected]>Signed-off-by Moritz Fischer <[email protected]>---
v9: initial version added to this patchset v10: s/fpga/FPGA/greplace DT overlay example with slightly more complicated example move to staging/simple-fpga-bus
v11: No change in this patch for v11 of the patch set
v12: Moved out of staging.
Changed to use FPGA bridges framework instead of resets for bridges.
v13: bridge at0xff20000-> bridge atff200000, etc
Leave out directly talking about overlays
Remove regs and clocks directly under simple-fpga-bus in example Use common "firmware-name" binding instead of "fpga-firmware"
v14: Use firmware-name in bindings description
Call it FPGA Area
Remove bindings that specify FPGA Manager and FPGA Bridges
v15: Cleanup as per Rob's comments
Combine usage doc with bindings document
Document as being Altera specific
Additions and changes to add FPGA Bus
v16: Reworked to document FPGA Regions
rename altera-fpga-bus-fpga-area.txt -> fpga-region.txt Remove references that made it sound exclusive to Altera Remove altr, prefix from fpga-bus and fpga-area compatible strings Added Moritz' usage example with Xilinx
Cleaned up unit addresses
v17: Lots of rewrites to try to make things clearer
Clarify that overlay can be rejected if FPGA isn't programmed Add external-fpga-config binding already used in u-boot Change partial-reconfig binding to partial-fpga-config to align
with existing u-boot binding format *-fpga-config
Add a document from Xilinx' website
v18: Fix node names underscores to be hyphens
Fix copy/pasted duplicate nodes in diagram
v19: Fix more underscores
Make FPGA regions to be children of bridges
General cleanup and clarificationQuoted 4 lines
--- .../devicetree/bindings/fpga/fpga-region.txt | 494 +++++++++++++++++++++ 1 file changed, 494 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/fpga-region.txt
Quoted 6 lines
Reviewed-by Rob Herring <[email protected]>Nice job.
Rob
Thanks, Rob! I'll add your reviewed-by in v20 just to make it even.
Besides that, squashing some patches and some minor changes for the Arria10 FPGA manager support.
Alan
PATCH v19 2/12 doc: fpga-mgr: add fpga image info to api
In reply to Alan TullThis patch adds a minor change in the FPGA Mangager API to hold information that is specific to an FPGA image file. This change is expected to bring little, if any, pain.
An FPGA image file will have particulars that affect how the image is programmed to the FPGA. One example is that current 'flags' currently has one bit which shows whether the FPGA image was built for full reconfiguration or partial reconfiguration. Another example is timeout values for enabling or disabling the bridges in the FPGA. As the complexity of the FPGA design increases, the bridges in the FPGA may take longer times to enable or disable.
This patch documents the change in the FPGA Manager API functions, replacing the 'u32 flag' parameter with a pointer to struct fpga_image_info.
---
v19: Added in v19 of this patchset
--- Documentation/fpga/fpga-mgr.txt | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-)
Documentation/fpga/fpga-mgr.txt +21 -11
@@ -18,21 +18,25 @@ API Functions: To program the FPGA from a file or from a buffer: ------------------------------------------------- - int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, + int fpga_mgr_buf_load(struct fpga_manager *mgr, + struct fpga_image_info *info, const char *buf, size_t count); Load the FPGA from an image which exists as a buffer in memory. - int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, + int fpga_mgr_firmware_load(struct fpga_manager *mgr, + struct fpga_image_info *info, const char *image_name); Load the FPGA from an image which exists as a file. The image file must be on -the firmware search path (see the firmware class documentation). - -For both these functions, flags == 0 for normal full reconfiguration or -FPGA_MGR_PARTIAL_RECONFIG for partial reconfiguration. If successful, the FPGA -ends up in operating mode. Return 0 on success or a negative error code. +the firmware search path (see the firmware class documentation). If successful, +the FPGA ends up in operating mode. Return 0 on success or a negative error +code. +A FPGA design contained in a FPGA image file will likely have particulars that +affect how the image is programmed to the FPGA. These are contained in struct +fpga_image_info. Currently the only such particular is a single flag bit +indicating whether the image is for full or partial reconfiguration. To get/put a reference to a FPGA manager: -----------------------------------------
@@ -70,8 +74,11 @@ struct device_node *mgr_node = ... char *buf = ... int count = ... +/* struct with information about the FPGA image to program. */ +struct fpga_image_info info; + /* flags indicates whether to do full or partial reconfiguration */ -int flags = 0; +info.flags = 0; int ret;
@@ -79,7 +86,7 @@ int ret; struct fpga_manager *mgr = of_fpga_mgr_get(mgr_node); /* Load the buffer to the FPGA */ -ret = fpga_mgr_buf_load(mgr, flags, buf, count); +ret = fpga_mgr_buf_load(mgr, &info, buf, count); /* Release the FPGA manager */ fpga_mgr_put(mgr);
@@ -96,8 +103,11 @@ struct device_node *mgr_node = ... /* FPGA image is in this file which is in the firmware search path */ const char *path = "fpga-image-9.rbf" +/* struct with information about the FPGA image to program. */ +struct fpga_image_info info; + /* flags indicates whether to do full or partial reconfiguration */ -int flags = 0; +info.flags = 0; int ret;
@@ -105,7 +115,7 @@ int ret; struct fpga_manager *mgr = of_fpga_mgr_get(mgr_node); /* Get the firmware image (path) and load it to the FPGA */ -ret = fpga_mgr_firmware_load(mgr, flags, path); +ret = fpga_mgr_firmware_load(mgr, &info, path); /* Release the FPGA manager */ fpga_mgr_put(mgr);
Signature · 1 line
2.9.3
PATCH v19 3/12 add bindings document for altera freeze bridge
In reply to Alan TullAdd bindings document for the Altera Freeze Bridge. A Freeze Bridge is used to gate traffic to/from a region of a FPGA such that that region can be reprogrammed. The Freeze Bridge exist in FPGA fabric that is not currently being reconfigured.
---
v19: Added in v19 of patchset, uses fpga image info struct
--- .../bindings/fpga/altera-freeze-bridge.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +23 -0
@@ -0,0 +1,23 @@ +Altera Freeze Bridge Controller Driver + +The Altera Freeze Bridge Controller manages one or more freeze bridges. +The controller can freeze/disable the bridges which prevents signal +changes from passing through the bridge. The controller can also +unfreeze/enable the bridges which allows traffic to pass through the +bridge normally. + +Required properties: +- compatible : Should contain "altr,freeze-bridge-controller" +- regs : base address and size for freeze bridge module + +Optional properties: +- bridge-enable : 0 if driver should disable bridge at startup + 1 if driver should enable bridge at startup + Default is to leave bridge in current state. + +Example: + freeze_controller at 100000450 { + compatible = "altr,freeze-bridge-controller"; + regs = <0x1000 0x10>; + bridge-enable = <0>; + };
Signature · 1 line
2.9.3
Rob Herring
maintainerRe: [PATCH v19 03/12] add bindings document for altera freeze bridge
Quoted 20 lines · Alan Tull
Add bindings document for the Altera Freeze Bridge. A Freeze Bridge is used to gate traffic to/from a region of a FPGA such that that region can be reprogrammed. The Freeze Bridge exist in FPGA fabric that is not currently being reconfigured.
Signed-off-by Alan Tull <[email protected]>Signed-off-by Matthew Gerlach <[email protected]>---
v19: Added in v19 of patchset, uses fpga image info struct--- .../bindings/fpga/altera-freeze-bridge.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txtDocumentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +0
-0
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt line 10
Quoted 10 lines
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +10
-0@@ -0,0 +1,23 @@ +Altera Freeze Bridge Controller Driver + +The Altera Freeze Bridge Controller manages one or more freeze bridges. +The controller can freeze/disable the bridges which prevents signal +changes from passing through the bridge. The controller can also +unfreeze/enable the bridges which allows traffic to pass through the +bridge normally. + +Required properties: +- compatible : Should contain "altr,freeze-bridge-controller"
Only one version of the h/w?
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt line 19
Quoted 9 lines
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +9
-0+- regs : base address and size for freeze bridge module + +Optional properties: +- bridge-enable : 0 if driver should disable bridge at startup + 1 if driver should enable bridge at startup + Default is to leave bridge in current state. + +Example: + freeze_controller at 100000450 {
Underscore...
Quoted 11 lines
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +4
-0+ compatible = "altr,freeze-bridge-controller"; + regs = <0x1000 0x10>; + bridge-enable = <0>; + };Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v19 03/12] add bindings document for altera freeze bridge
Quoted 25 lines · Rob Herring
Quoted 24 lines · Alan Tull
Add bindings document for the Altera Freeze Bridge. A Freeze Bridge is used to gate traffic to/from a region of a FPGA such that that region can be reprogrammed. The Freeze Bridge exist in FPGA fabric that is not currently being reconfigured.
Signed-off-by Alan Tull <[email protected]>Signed-off-by Matthew Gerlach <[email protected]>---
v19: Added in v19 of patchset, uses fpga image info struct--- .../bindings/fpga/altera-freeze-bridge.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txtDocumentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +4
-0@@ -0,0 +1,23 @@ +Altera Freeze Bridge Controller Driver + +The Altera Freeze Bridge Controller manages one or more freeze bridges. +The controller can freeze/disable the bridges which prevents signal
Quoted 8 lines
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt line 10
Quoted 6 lines
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +6
-0+changes from passing through the bridge. The controller can also +unfreeze/enable the bridges which allows traffic to pass through the +bridge normally. + +Required properties: +- compatible : Should contain "altr,freeze-bridge-controller"Only one version of the h/w?
The h/w has a version register. Currently the driver reads the reg and exits if rev != 2. Future version support can be keyed off this register.
Quoted 12 lines
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt line 19
Quoted 10 lines
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +9
-0+- regs : base address and size for freeze bridge module + +Optional properties: +- bridge-enable : 0 if driver should disable bridge at startup + 1 if driver should enable bridge at startup + Default is to leave bridge in current state. + +Example: + freeze_controller at 100000450 {Underscore...
Yes.
Quoted 13 lines
Quoted 12 lines
Documentation/devicetree/bindings/fpga/altera-freeze-bridge.txt new file +4
-0+ compatible = "altr,freeze-bridge-controller"; + regs = <0x1000 0x10>; + bridge-enable = <0>; + };Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v19 4/12 add sysfs document for fpga bridge class
In reply to Alan TullAdd documentation for new FPGA bridge class's sysfs interface.
--
v15: Document added in v15 of patch set
v16: No change to this patch in v16 of patch set
v17: No change to this patch in v17 of patch set
v18: No change to this patch in v18 of patch set
v19: No change to this patch in this version of patch set
--- Documentation/ABI/testing/sysfs-class-fpga-bridge | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-bridge
Documentation/ABI/testing/sysfs-class-fpga-bridge new file +11 -0
@@ -0,0 +1,11 @@ +What: /sys/class/fpga_bridge/<bridge>/name +Date: January 2016 +KernelVersion: 4.5 +Contact: Alan Tull <[email protected]> +Description: Name of low level FPGA bridge driver. + +What: /sys/class/fpga_bridge/<bridge>/state +Date: January 2016 +KernelVersion: 4.5 +Contact: Alan Tull <[email protected]> +Description: Show bridge state as "enabled" or "disabled"
Signature · 1 line
2.9.3
Re: [PATCH v19 04/12] add sysfs document for fpga bridge class
Quoted 3 lines · Alan Tull
Add documentation for new FPGA bridge class's sysfs interface.
Signed-off-by Alan Tull <[email protected]>
PATCH v19 5/12 fpga-mgr: add fpga image information struct
In reply to Alan TullThis patch adds a minor change in the FPGA Mangager API to hold information that is specific to an FPGA image file. This change is expected to bring little, if any, pain.
An FPGA image file will have particulars that affect how the image is programmed to the FPGA. One example is that current 'flags' currently has one bit which shows whether the FPGA image was built for full reconfiguration or partial reconfiguration. Another example is timeout values for enabling or disabling the bridges in the FPGA. As the complexity of the FPGA design increases, the bridges in the FPGA may take longer times to enable or disable.
This patch adds a new 'struct fpga_image_info', moves the current 'u32 flags' to it. Two other image-specific u32's are added for the bridge enable/disable timeouts. The FPGA Manager API functions are changed, replacing the 'u32 flag' parameter with a pointer to struct fpga_image_info. Subsequent patches fix the existing low level FPGA manager drivers.
---
v19: Added in v19 of this patchset
--- drivers/fpga/fpga-mgr.c | 17 +++++++++-------- include/linux/fpga/fpga-mgr.h | 23 +++++++++++++++++++---- 2 files changed, 28 insertions(+), 12 deletions(-)
drivers/fpga/fpga-mgr.c +9 -8
@@ -32,7 +32,7 @@ static struct class *fpga_mgr_class;/** * fpga_mgr_buf_load - load fpga from image in buffer * @mgr: fpga manager -* @flags: flags setting fpga confuration modes +* @info: fpga image specific information * @buf: buffer contain fpga image * @count: byte count of buf *
@@ -43,8 +43,8 @@ static struct class *fpga_mgr_class;* * Return: 0 on success, negative error code otherwise. */ -int fpga_mgr_buf_load (struct fpga_manager *mgr,u32 flags,const char *buf, -size_t count) +int fpga_mgr_buf_load (struct fpga_manager *mgr,struct fpga_image_info *info, +const char *buf,size_t count) {struct device *dev = &mgr->dev;int ret;
@@ -55,7 +55,7 @@ int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf,* ready to receive an FPGA image. */ mgr->state =FPGA_MGR_STATE_WRITE_INIT ; - ret = mgr->mops->write_init (mgr, flags, buf, count); + ret = mgr->mops->write_init (mgr, info, buf, count);if (ret) {dev_err (dev,"Error preparing FPGA for writing\n" ); mgr->state =FPGA_MGR_STATE_WRITE_INIT_ERR ;
@@ -78,7 +78,7 @@ int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf,* steps to finish and set the FPGA into operating mode. */ mgr->state =FPGA_MGR_STATE_WRITE_COMPLETE ; - ret = mgr->mops->write_complete (mgr, flags); + ret = mgr->mops->write_complete (mgr, info);if (ret) {dev_err (dev,"Error after writing image data to FPGA\n" ); mgr->state =FPGA_MGR_STATE_WRITE_COMPLETE_ERR ;
@@ -93,7 +93,7 @@ EXPORT_SYMBOL_GPL(fpga_mgr_buf_load);/** * fpga_mgr_firmware_load - request firmware and load to fpga * @mgr: fpga manager -* @flags: flags setting fpga confuration modes +* @info: fpga image specific information * @image_name: name of image file on the firmware search path * * Request an FPGA image using the firmware class, then write out to the FPGA.
@@ -103,7 +103,8 @@ EXPORT_SYMBOL_GPL(fpga_mgr_buf_load);* * Return: 0 on success, negative error code otherwise. */ -int fpga_mgr_firmware_load (struct fpga_manager *mgr,u32 flags, +int fpga_mgr_firmware_load (struct fpga_manager *mgr, +struct fpga_image_info *info,const char *image_name) {struct device *dev = &mgr->dev;
@@ -121,7 +122,7 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags,return ret; } - ret =fpga_mgr_buf_load (mgr, flags, fw->data, fw->size); + ret =fpga_mgr_buf_load (mgr, info, fw->data, fw->size);release_firmware (fw);
include/linux/fpga/fpga-mgr.h +19 -4
@@ -69,6 +69,18 @@ enum fpga_mgr_states {#define FPGA_MGR_PARTIAL_RECONFIG BIT(0)/** +* struct fpga_image_info - information specific to a FPGA image +* @flags: boolean flags as defined above +* @enable_timeout_us: maximum time to enable traffic through bridge (uSec) +* @disable_timeout_us: maximum time to disable traffic through bridge (uSec) +*/ +struct fpga_image_info { +u32 flags; +u32 enable_timeout_us; +u32 disable_timeout_us; +}; + +/** * struct fpga_manager_ops - ops for low level fpga manager drivers * @state: returns an enum value of the FPGA's state * @write_init: prepare the FPGA to receive confuration data
@@ -82,10 +94,12 @@ enum fpga_mgr_states {*/ struct fpga_manager_ops {enum fpga_mgr_states (*state)(struct fpga_manager *mgr); -int (*write_init)(struct fpga_manager *mgr,u32 flags, +int (*write_init)(struct fpga_manager *mgr, +struct fpga_image_info *info,const char *buf,size_t count);int (*write)(struct fpga_manager *mgr,const char *buf,size_t count); -int (*write_complete)(struct fpga_manager *mgr,u32 flags); +int (*write_complete)(struct fpga_manager *mgr, +struct fpga_image_info *info);void (*fpga_remove)(struct fpga_manager *mgr); };
@@ -109,10 +123,11 @@ struct fpga_manager {#define to_fpga_manager (d) container_of(d, struct fpga_manager, dev) -int fpga_mgr_buf_load (struct fpga_manager *mgr,u32 flags, +int fpga_mgr_buf_load (struct fpga_manager *mgr,struct fpga_image_info *info,const char *buf,size_t count); -int fpga_mgr_firmware_load (struct fpga_manager *mgr,u32 flags, +int fpga_mgr_firmware_load (struct fpga_manager *mgr, +struct fpga_image_info *info,const char *image_name);struct fpga_manager *of_fpga_mgr_get (struct device_node *node);
Signature · 1 line
2.9.3
Re: [PATCH v19 05/12] fpga-mgr: add fpga image information struct
Hi Alan,
generally ok with the change.
drivers/fpga/fpga-mgr.c static struct class *fpga_mgr_class; · line 47
Quoted 4 lines · Alan Tull
drivers/fpga/fpga-mgr.c +2
-2-int fpga_mgr_buf_load (struct fpga_manager *mgr,u32 flags,const char *buf, -size_t count) +int fpga_mgr_buf_load (struct fpga_manager *mgr,struct fpga_image_info *info, +const char *buf,size_t count)
Doesn't this break the both socfpga and zynq if [6/12] and [7/12] are not part of this commit?
i.e shouldn't 5,6 and 7 be a single commit?
Cheers,
Moritz
Re: [PATCH v19 05/12] fpga-mgr: add fpga image information struct
On Wed, Sep 28, 2016 at 6:41 PM, Moritz Fischer
<[email protected]> wrote:
Hi Moritz,
Quoted 3 lines
Hi Alan,
generally ok with the change.
Cool!
Quoted 11 lines · Alan Tull
drivers/fpga/fpga-mgr.c static struct class *fpga_mgr_class; · line 47
Quoted 5 lines
drivers/fpga/fpga-mgr.c +2
-2-int fpga_mgr_buf_load (struct fpga_manager *mgr,u32 flags,const char *buf, -size_t count) +int fpga_mgr_buf_load (struct fpga_manager *mgr,struct fpga_image_info *info, +const char *buf,size_t count)Doesn't this break the both socfpga and zynq if [6/12] and [7/12] are not part of this commit?
i.e shouldn't 5,6 and 7 be a single commit?
Yeah, squashing those would improve bisectability.
Alan
aka atull
Quoted 3 lines
Cheers,
Moritz
Re: [PATCH v19 05/12] fpga-mgr: add fpga image information struct
Quoted 22 lines · Alan Tull
On Wed, Sep 28, 2016 at 6:41 PM, Moritz Fischer
<[email protected]> wrote:
Hi Moritz,Quoted 3 lines
Hi Alan,
generally ok with the change.
Cool!
Quoted 11 lines · Alan Tull
drivers/fpga/fpga-mgr.c static struct class *fpga_mgr_class; · line 47
Quoted 5 lines
drivers/fpga/fpga-mgr.c +2
-2-int fpga_mgr_buf_load (struct fpga_manager *mgr,u32 flags,const char *buf, -size_t count) +int fpga_mgr_buf_load (struct fpga_manager *mgr,struct fpga_image_info *info, +const char *buf,size_t count)Doesn't this break the both socfpga and zynq if [6/12] and [7/12] are not part of this commit?
i.e shouldn't 5,6 and 7 be a single commit?
Quoted 1 line
Yeah, squashing those would improve bisectability.
Improve? :-)
Definitely this needs to be the part of this commit.
M
PATCH v19 6/12 fpga: add fpga image information struct for socfpga support
In reply to Alan TullMinor changes to the Altera SoCFPGA FPGA Manager support driver due to FPGA Manager framework API changes for the new fpga image information struct.
---
v19: Added in v19 of this patchset
--- drivers/fpga/socfpga.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/fpga/socfpga.c +4 -3
@@ -407,13 +407,14 @@ static int socfpga_fpga_reset(struct fpga_manager *mgr)/* * Prepare the FPGA to receive the configuration data. */ -static int socfpga_fpga_ops_configure_init (struct fpga_manager *mgr,u32 flags, +static int socfpga_fpga_ops_configure_init (struct fpga_manager *mgr, +struct fpga_image_info *info,const char *buf,size_t count) {struct socfpga_fpga_priv *priv = mgr->priv;int ret; -if (flags &FPGA_MGR_PARTIAL_RECONFIG ) { +if (info->flags &FPGA_MGR_PARTIAL_RECONFIG ) {dev_err (&mgr->dev,"Partial reconfiguration not supported.\n" );return -EINVAL ; }
@@ -478,7 +479,7 @@ static int socfpga_fpga_ops_configure_write(struct fpga_manager *mgr, }static int socfpga_fpga_ops_configure_complete (struct fpga_manager *mgr, -u32 flags) +struct fpga_image_info *info) {struct socfpga_fpga_priv *priv = mgr->priv;u32 status;
Signature · 1 line
2.9.3
PATCH v19 7/12 fpga: add fpga image information struct for zynq support
In reply to Alan TullMinor changes to the Xilinx Zynq FPGA Manager support driver due to FPGA Manager framework API changes for the new fpga image information struct.
---
v19: Added in v19 of this patchset
--- drivers/fpga/zynq-fpga.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/fpga/zynq-fpga.c +6 -4
@@ -175,7 +175,8 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)return IRQ_HANDLED ; } -static int zynq_fpga_ops_write_init (struct fpga_manager *mgr,u32 flags, +static int zynq_fpga_ops_write_init (struct fpga_manager *mgr, +struct fpga_image_info *info,const char *buf,size_t count) {struct zynq_fpga_priv *priv;
@@ -189,7 +190,7 @@ static int zynq_fpga_ops_write_init(struct fpga_manager *mgr, u32 flags,return err;/* don't globally reset PL if we're doing partial reconfig */ -if (!(flags &FPGA_MGR_PARTIAL_RECONFIG )) { +if (!(info->flags &FPGA_MGR_PARTIAL_RECONFIG )) {/* assert AXI interface resets */ regmap_write (priv->slcr,SLCR_FPGA_RST_CTRL_OFFSET ,FPGA_RST_ALL_MASK );
@@ -343,7 +344,8 @@ out_free:return err; } -static int zynq_fpga_ops_write_complete (struct fpga_manager *mgr,u32 flags) +static int zynq_fpga_ops_write_complete (struct fpga_manager *mgr, +struct fpga_image_info *info) {struct zynq_fpga_priv *priv = mgr->priv;int err;
@@ -364,7 +366,7 @@ static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr, u32 flags)return err;/* for the partial reconfig case we didn't touch the level shifters */ -if (!(flags &FPGA_MGR_PARTIAL_RECONFIG )) { +if (!(info->flags &FPGA_MGR_PARTIAL_RECONFIG )) {/* enable level shifters from PL to PS */ regmap_write (priv->slcr,SLCR_LVL_SHFTR_EN_OFFSET ,LVL_SHFTR_ENABLE_PL_TO_PS );
Signature · 1 line
2.9.3
PATCH v19 8/12 fpga: add fpga bridge framework
In reply to Alan TullThis framework adds API functions for enabling/
disabling FPGA bridges under kernel control.
This allows the Linux kernel to disable FPGA bridges during FPGA reprogramming and to enable FPGA bridges when FPGA reprogramming is done. This framework is be manufacturer-agnostic, allowing it to be used in interfaces that use the FPGA Manager Framework to reprogram FPGA's.
The functions are:
* of_fpga_bridge_get
* fpga_bridge_put
Get/put an exclusive reference to a FPGA bridge.
* fpga_bridge_enable
* fpga_bridge_disable
Enable/Disable traffic through a bridge.
* fpga_bridge_register
* fpga_bridge_unregister
Register/unregister a device-specific low level FPGA Bridge driver.
Get an exclusive reference to a bridge and add it to a list:
* fpga_bridge_get_to_list
To enable/disable/put a set of bridges that are on a list:
* fpga_bridges_enable
* fpga_bridges_disable
* fpga_bridges_put
---
v2: Minor cleanup v12: Bump version to line up with simple fpga bus
Remove sysfs
Improve get/put functions, get the low level driver too. Clean up class implementation
Add kernel doc documentation
Rename (un)register_fpga_bridge -> fpga_bridge_(un)register
v13: Add inlined empty functions for if not CONFIG_FPGA_BRIDGE
Clean up debugging
Remove unneeded #include in .h
Remove unnecessary prints
Remove 'label' DT binding.
Document the mutex
v14: Allow bridges with no ops
*const* struct fpga_bridge_ops
Add functions to git/put/enable/disable list of bridges Add list node to struct fpga_bridge
Do of_node_get/put in of_fpga_bridge_get()
Add r/o attributes: name and state
v15: No change in this patch for v15 of this patch set
v16: Remove of_get_fpga_bus function
v17: No change to this patch in v17 of patch set
v18: No change to this patch in v18 of patch set
v19: Use fpga image info struct
Support fpga image specific timeouts
Support child fpga-regions by doing of_platform_populate make a tristate in Kconfig
--- drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 3 + drivers/fpga/fpga-bridge.c | 398 +++++++++++++++++++++++++++++++++++++++ include/linux/fpga/fpga-bridge.h | 60 ++++++ 4 files changed, 468 insertions(+) create mode 100644 drivers/fpga/fpga-bridge.c create mode 100644 include/linux/fpga/fpga-bridge.h
drivers/fpga/Kconfig +7 -0
@@ -25,6 +25,13 @@ config FPGA_MGR_ZYNQ_FPGA help FPGA manager driver support for Xilinx Zynq FPGAs. +config FPGA_BRIDGE + tristate "FPGA Bridge Framework" + depends on OF + help + Say Y here if you want to support bridges connected between host + processors and FPGAs or between FPGAs. + endif # FPGA endmenu
drivers/fpga/Makefile +3 -0
@@ -8,3 +8,6 @@ obj-$(CONFIG_FPGA) += fpga-mgr.o # FPGA Manager Drivers obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o + +# FPGA Bridge Drivers +obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o
drivers/fpga/fpga-bridge.c new file +398 -0
398 lines not on this page · raw message
include/linux/fpga/fpga-bridge.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v19 9/12 fpga: fpga-region: device tree control for FPGA
In reply to Alan TullFPGA Regions support programming FPGA under control of the Device Tree.
---
v9: initial version (this patch added during rest of patchset's v9) v10: request deferral if fpga mgr or bridges not available yet
cleanup as fpga manager core goes into the real kernel Don't assume bridges are disabled before programming FPGA Don't hang onto reference for fpga manager
Move to staging/simple-fpga-bus
v11: No change in this patch for v11 of the patch set
v12: Moved out of staging.
Use fpga bridges framework.
v13: If no bridges are specified, assume we don't need any.
Clean up debug messages
Some dev_info -> dev_dbg
Remove unneeded #include
Fix size of array of pointers
Don't need to specify .owner
Use common binding: firmware-name
v14: OK it's not a simple bus. Call it "FPGA Area"
Remove bindings that specify FPGA manager and FPGA bridges Use parent FPGA bridge and bridges that are its peers Use ancestor FPGA Manager
v15: Add altr,fpga-bus implementation
Change compatible string "fpga-area" -> "altr,fpga-area"
v16: Much changes as FPGA Areas and Busses become FPGA Regions
Add reconfig notifier, don't rely on simple-bus
v17: Use new overlay notifier instead of reconfig notifier
Add external_fpga_config property used in u-boot Change partial-reconfig binding to partial-fpga-config to be
similar to *-fpga-config bindings used in u-boot
v18: No change to this patch in v18 of patch set
v19: add fpga image information struct
support region as child of fpga bridge
remove message about not finding region
Make a tristate in the Kconfig
Add dependency on bridges in Kconfig
--- drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 3 + drivers/fpga/fpga-region.c | 603 ++++++++++++++++++++++++++++++++++++++++++ include/linux/fpga/fpga-mgr.h | 2 + 4 files changed, 615 insertions(+) create mode 100644 drivers/fpga/fpga-region.c
drivers/fpga/Kconfig +7 -0
@@ -13,6 +13,13 @@ config FPGA if FPGA +config FPGA_REGION + tristate "FPGA Region" + depends on OF && FPGA_BRIDGE + help + FPGA Regions allow loading FPGA images under control of + the Device Tree. + config FPGA_MGR_SOCFPGA tristate "Altera SOCFPGA FPGA Manager" depends on ARCH_SOCFPGA
drivers/fpga/Makefile +3 -0
@@ -11,3 +11,6 @@ obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o # FPGA Bridge Drivers obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o + +# High Level Interfaces +obj-$(CONFIG_FPGA_REGION) += fpga-region.o
drivers/fpga/fpga-region.c new file +603 -0
603 lines not on this page · raw message
include/linux/fpga/fpga-mgr.h +2 -0
@@ -65,8 +65,10 @@ enum fpga_mgr_states {/* * FPGA Manager flags * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported +* FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting */ #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) +#define FPGA_MGR_EXTERNAL_CONFIG BIT(1)/** * struct fpga_image_info - information specific to a FPGA image
Signature · 1 line
2.9.3
PATCH v19 10/12 ARM: socfpga: fpga bridge driver support
In reply to Alan TullSupports Altera SOCFPGA bridges:
* fpga2sdram
* fpga2hps
* hps2fpga
* lwhps2fpga
Allows enabling/disabling the bridges through the FPGA Bridge Framework API functions.
The fpga2sdram driver only supports enabling and disabling of the ports that been configured early on. This is due to a hardware limitation where the read, write, and command ports on the fpga2sdram bridge can only be reconfigured while there are no transactions to the sdram, i.e. when running out of OCRAM before the kernel boots.
Device tree property 'init-val' configures the driver to enable or disable the bridge during probe. If the property does not exist, the driver will leave the bridge in its current state.
---
v2: Use resets instead of directly writing reset registers v12: Bump version to align with simple-fpga-bus version
Get rid of the sysfs interface
fpga2sdram: get configuration stored in handoff register
v13: Remove unneeded WARN_ON
Change property from init-val to bridge-enable Checkpatch cleanup
Fix email address
v14: use module_platform_driver
remove unused struct field and some #defines don't really need exclamation points on error msgs *const* struct fpga_bridge_ops
v15: No change in this patch for v15 of this patch set
v16: No change in this patch for v16 of this patch set
v17: No change to this patch for v17 of this patch set
v18: Eliminate need to specify reset names since only one reset
v19: Set bridge state before registering driver with framework
Include fix for drivers sharing the l3_remap_value reg use devm_clk_get
make tristate in Kconfig
documentation of handoff registers
--- drivers/fpga/Kconfig | 7 ++ drivers/fpga/Makefile | 1 + drivers/fpga/altera-fpga2sdram.c | 180 +++++++++++++++++++++++++++++++ drivers/fpga/altera-hps2fpga.c | 221 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 409 insertions(+) create mode 100644 drivers/fpga/altera-fpga2sdram.c create mode 100644 drivers/fpga/altera-hps2fpga.c
drivers/fpga/Kconfig +7 -0
@@ -39,6 +39,13 @@ config FPGA_BRIDGE Say Y here if you want to support bridges connected between host processors and FPGAs or between FPGAs. +config SOCFPGA_FPGA_BRIDGE + tristate "Altera SoCFPGA FPGA Bridges" + depends on ARCH_SOCFPGA && FPGA_BRIDGE + help + Say Y to enable drivers for FPGA bridges for Altera SOCFPGA + devices. + endif # FPGA endmenu
drivers/fpga/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o # FPGA Bridge Drivers obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o +obj-$(CONFIG_SOCFPGA_FPGA_BRIDGE) += altera-hps2fpga.o altera-fpga2sdram.o # High Level Interfaces obj-$(CONFIG_FPGA_REGION) += fpga-region.o
drivers/fpga/altera-fpga2sdram.c new file +180 -0
180 lines not on this page · raw message
drivers/fpga/altera-hps2fpga.c new file +221 -0
221 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v19 11/12 fpga: add altera freeze bridge support
In reply to Alan TullAdd a low level driver for Altera Freeze Bridges to the FPGA Bridge framework. A freeze bridge is a bridge that exists in the FPGA fabric to isolate one region of the FPGA from the busses while that one region is being reprogrammed.
---
v19: added in v19 of patchset as it needs for fpga info struct
--- drivers/fpga/Kconfig | 9 ++ drivers/fpga/Makefile | 1 + drivers/fpga/altera-freeze-bridge.c | 273 ++++++++++++++++++++++++++++++++++++ 3 files changed, 283 insertions(+) create mode 100644 drivers/fpga/altera-freeze-bridge.c
drivers/fpga/Kconfig +9 -0
@@ -46,6 +46,15 @@ config SOCFPGA_FPGA_BRIDGE Say Y to enable drivers for FPGA bridges for Altera SOCFPGA devices. +config ALTERA_FREEZE_BRIDGE + tristate "Altera FPGA Freeze Bridge" + depends on ARCH_SOCFPGA && FPGA_BRIDGE + help + Say Y to enable drivers for Altera FPGA Freeze bridges. A + freeze bridge is a bridge that exists in the FPGA fabric to + isolate one region of the FPGA from the busses while that + region is being reprogrammed. + endif # FPGA endmenu
drivers/fpga/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o # FPGA Bridge Drivers obj-$(CONFIG_FPGA_BRIDGE) += fpga-bridge.o obj-$(CONFIG_SOCFPGA_FPGA_BRIDGE) += altera-hps2fpga.o altera-fpga2sdram.o +obj-$(CONFIG_ALTERA_FREEZE_BRIDGE) += altera-freeze-bridge.o # High Level Interfaces obj-$(CONFIG_FPGA_REGION) += fpga-region.o
drivers/fpga/altera-freeze-bridge.c new file +273 -0
273 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v19 12/12 fpga-manager: Add Socfpga Arria10 support
In reply to Alan TullAdd low level driver to support reprogramming FPGAs for Altera SoCFPGA Arria10.
---
v19: Added to this patchset as has been changed to use
fpga image information struct
a checkpatch fix of a block comment
do not use clk_put because we are using devm_clk_get
--- drivers/fpga/Kconfig | 6 + drivers/fpga/Makefile | 1 + drivers/fpga/socfpga-a10.c | 572 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 579 insertions(+) create mode 100644 drivers/fpga/socfpga-a10.c
drivers/fpga/Kconfig +6 -0
@@ -26,6 +26,12 @@ config FPGA_MGR_SOCFPGA help FPGA manager driver support for Altera SOCFPGA. +config FPGA_MGR_SOCFPGA_A10 + tristate "Altera SoCFPGA Arria10" + depends on ARCH_SOCFPGA + help + FPGA manager driver support for Altera Arria10 SoCFPGA. + config FPGA_MGR_ZYNQ_FPGA tristate "Xilinx Zynq FPGA" depends on HAS_DMA
drivers/fpga/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_FPGA) += fpga-mgr.o # FPGA Manager Drivers obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o +obj-$(CONFIG_FPGA_MGR_SOCFPGA_A10) += socfpga-a10.o obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o # FPGA Bridge Drivers
drivers/fpga/socfpga-a10.c new file +572 -0
572 lines not on this page · raw message
Signature · 1 line
2.9.3
Re: [PATCH v19 12/12] fpga-manager: Add Socfpga Arria10 support
Hi Alan,
Quoted 10 lines · Alan Tull
drivers/fpga/socfpga-a10.c new file +10
-0+static void socfpga_a10_fpga_generate_dclks (struct a10_fpga_priv *priv, +u32 count) +{ +u32 val; +unsigned int i; + +/* Clear any existing DONE status. */ +regmap_write (priv->regmap,A10_FPGAMGR_DCLKSTAT_OFST , +A10_FPGAMGR_DCLKSTAT_DCLKDONE ); +
drivers/fpga/socfpga-a10.c line 158
Quoted 10 lines
drivers/fpga/socfpga-a10.c new file +10
-0+/* Issue the DCLK regmap. */ +regmap_write (priv->regmap,A10_FPGAMGR_DCLKCNT_OFST , count); + +/* wait till the dclkcnt done */ +for (i =0 ; i <100 ; i++) { +regmap_read (priv->regmap,A10_FPGAMGR_DCLKSTAT_OFST , &val); +if (val) +break ; +udelay (1 ); + }
It's quite new, but regmap_read_poll_timeout() might be a good fit here?
drivers/fpga/socfpga-a10.c line 176
Quoted 12 lines
drivers/fpga/socfpga-a10.c new file +12
-0+static int socfpga_a10_fpga_encrypted (struct fpga_manager *mgr, +u32 *buf32,size_t buf32_size) +{ +int encrypt; + +if (buf32_size <70 ) +return -EINVAL ; + + encrypt = ((buf32[69 ] >>2 ) &3 ) !=0 ; + +dev_dbg (&mgr->dev,"header word %d = %08x encrypt=%d\n" , +69 , buf32[69 ], encrypt);
Maybe a named constants for magic 69 / 70 value :)
Quoted 5 lines
drivers/fpga/socfpga-a10.c new file +5
-0+static int socfpga_a10_fpga_compressed (struct fpga_manager *mgr, +u32 *buf32,size_t buf32_size) +{ +int compress; +
drivers/fpga/socfpga-a10.c line 195
Quoted 10 lines
drivers/fpga/socfpga-a10.c new file +10
-0+if (buf32_size <230 ) +return -EINVAL ; + + compress = !((buf32[229 ] >>1 ) &1 ); + +dev_dbg (&mgr->dev,"header word %d = %08x compress=%d\n" , +229 , buf32[229 ], compress); + +return compress; +}
Same here, a comment on 229/230 would work too I guess.
Quoted 4 lines
drivers/fpga/socfpga-a10.c new file +4
-0+/* Start the FPGA programming by initialize the FPGA Manager */ +static int socfpga_a10_fpga_write_init (struct fpga_manager *mgr, +struct fpga_image_info *info, +const char *buf,size_t count)
drivers/fpga/socfpga-a10.c line 312
Quoted 10 lines
drivers/fpga/socfpga-a10.c new file +10
-0+{ +struct a10_fpga_priv *priv = mgr->priv; +unsigned int cfg_width; +u32 msel, stat, mask; +int ret; + +if (info->flags &FPGA_MGR_PARTIAL_RECONFIG ) + cfg_width =CFGWDTH_16 ; +else +return -EINVAL ;
So we can *only* do partial reconfig? Am I missing something here?
drivers/fpga/socfpga-a10.c line 373
Quoted 2 lines
drivers/fpga/socfpga-a10.c new file +2
-0+/* Do some dclks, wait for pr_ready */ +socfpga_a10_fpga_generate_dclks (priv,0x7ff );
Maybe a named constant?
Cheers,
Moritz
Re: [PATCH v19 12/12] fpga-manager: Add Socfpga Arria10 support
Quoted 18 lines · Moritz Fischer
Hi Alan,
Quoted 14 lines · Alan Tull
drivers/fpga/socfpga-a10.c new file +14
-0+static void socfpga_a10_fpga_generate_dclks (struct a10_fpga_priv *priv, +u32 count) +{ +u32 val; +unsigned int i; + +/* Clear any existing DONE status. */ +regmap_write (priv->regmap,A10_FPGAMGR_DCLKSTAT_OFST , +A10_FPGAMGR_DCLKSTAT_DCLKDONE ); + +/* Issue the DCLK regmap. */ +regmap_write (priv->regmap,A10_FPGAMGR_DCLKCNT_OFST , count); + +/* wait till the dclkcnt done */
Quoted 8 lines
drivers/fpga/socfpga-a10.c line 158
Quoted 6 lines
drivers/fpga/socfpga-a10.c new file +6
-0+for (i =0 ; i <100 ; i++) { +regmap_read (priv->regmap,A10_FPGAMGR_DCLKSTAT_OFST , &val); +if (val) +break ; +udelay (1 ); + }It's quite new, but
regmap_read_poll_timeout()might be a good fit here?
Yes
Quoted 14 lines
drivers/fpga/socfpga-a10.c line 176
Quoted 13 lines
drivers/fpga/socfpga-a10.c new file +12
-0+static int socfpga_a10_fpga_encrypted (struct fpga_manager *mgr, +u32 *buf32,size_t buf32_size) +{ +int encrypt; + +if (buf32_size <70 ) +return -EINVAL ; + + encrypt = ((buf32[69 ] >>2 ) &3 ) !=0 ; + +dev_dbg (&mgr->dev,"header word %d = %08x encrypt=%d\n" , +69 , buf32[69 ], encrypt);Maybe a named constants for magic 69 / 70 value :)
Sure
Quoted 18 lines
Quoted 6 lines
drivers/fpga/socfpga-a10.c new file +5
-0+static int socfpga_a10_fpga_compressed (struct fpga_manager *mgr, +u32 *buf32,size_t buf32_size) +{ +int compress; +drivers/fpga/socfpga-a10.c line 195
Quoted 10 lines
drivers/fpga/socfpga-a10.c new file +10
-0+if (buf32_size <230 ) +return -EINVAL ; + + compress = !((buf32[229 ] >>1 ) &1 ); + +dev_dbg (&mgr->dev,"header word %d = %08x compress=%d\n" , +229 , buf32[229 ], compress); + +return compress; +}Same here, a comment on 229/230 would work too I guess.
Quoted 16 lines
Quoted 4 lines
drivers/fpga/socfpga-a10.c new file +4
-0+/* Start the FPGA programming by initialize the FPGA Manager */ +static int socfpga_a10_fpga_write_init (struct fpga_manager *mgr, +struct fpga_image_info *info, +const char *buf,size_t count)drivers/fpga/socfpga-a10.c line 312
Quoted 10 lines
drivers/fpga/socfpga-a10.c new file +10
-0+{ +struct a10_fpga_priv *priv = mgr->priv; +unsigned int cfg_width; +u32 msel, stat, mask; +int ret; + +if (info->flags &FPGA_MGR_PARTIAL_RECONFIG ) + cfg_width =CFGWDTH_16 ; +else +return -EINVAL ;So we can *only* do partial reconfig? Am I missing something here?
Correct, only PR for now.
Quoted 5 lines
drivers/fpga/socfpga-a10.c line 373
Quoted 3 lines
drivers/fpga/socfpga-a10.c new file +2
-0+/* Do some dclks, wait for pr_ready */ +socfpga_a10_fpga_generate_dclks (priv,0x7ff );Maybe a named constant?
OK. Thanks for the review!
Alan
Quoted 4 lines
Cheers,
Moritz