Skip to contentSkip to conversation

simple fpga bus and fpga bridge framework

PATCH Superseded [email protected] 2 participants 9 messages Nov 3, 2015 – Nov 20, 2015

Subsystems (3)

v13 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

v13 cover simple fpga bus and fpga bridge framework

From: Alan Tull <[email protected]>

These patches are too late for this merge window; I'm submitting them for those who are reviewing, especially the bindings.

Changes since v12:
Change DT property from "init-val" to "bridge-enable"
Use proposed DT common property "firmware-name" instead of "fpga-firmware" Clean up cruft from simple-fpga-bus DT bindings example Support Simple FPGA Bus when FPGA Bridges are compiled out. Cleanup and nits

The Simple FPGA Bus provides a manufacturer-agnostic interface for reprogramming FPGAs using Device Tree Overlays. It uses the FPGA Bridge Framework and the upstreamed FPGA Manager Framework. In the case where FPGA Bridges are not needed, they don't need to be specified in the DT and can compiled out, if desired.

Alan Tull (6):
fpga: add usage documentation for simple fpga bus
fpga: add bindings document for simple fpga bus
fpga: add simple-fpga-bus
fpga: add fpga bridge framework
ARM: socfpga: add bindings document for fpga bridge drivers
ARM: socfpga: fpga bridge driver support

 .../bindings/fpga/altera-fpga2sdram-bridge.txt     |  15 +
 .../bindings/fpga/altera-hps2fpga-bridge.txt       |  31 ++
 .../devicetree/bindings/fpga/simple-fpga-bus.txt   |  74 +++++
 Documentation/fpga/simple-fpga-bus.txt             |  58 ++++
 drivers/fpga/Kconfig                               |  21 ++
 drivers/fpga/Makefile                              |   7 +
 drivers/fpga/altera-fpga2sdram.c                   | 185 ++++++++++++
 drivers/fpga/altera-hps2fpga.c                     | 233 +++++++++++++++
 drivers/fpga/fpga-bridge.c                         | 229 +++++++++++++++
 drivers/fpga/simple-fpga-bus.c                     | 323 +++++++++++++++++++++
 include/linux/fpga/fpga-bridge.h                   |  74 +++++
 11 files changed, 1250 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fpga/altera-fpga2sdram-bridge.txt
 create mode 100644 Documentation/devicetree/bindings/fpga/altera-hps2fpga-bridge.txt
 create mode 100644 Documentation/devicetree/bindings/fpga/simple-fpga-bus.txt
 create mode 100644 Documentation/fpga/simple-fpga-bus.txt
 create mode 100644 drivers/fpga/altera-fpga2sdram.c
 create mode 100644 drivers/fpga/altera-hps2fpga.c
 create mode 100644 drivers/fpga/fpga-bridge.c
 create mode 100644 drivers/fpga/simple-fpga-bus.c
 create mode 100644 include/linux/fpga/fpga-bridge.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v13 1/6 fpga: add usage documentation for simple fpga bus

From: Alan Tull <[email protected]>

Add a document spelling out usage of the simple fpga bus.

---

v9:  Initial version of this patch in patchset
v10: s/fpga/FPGA/g

improve formatting
some rewriting
move to staging/simple-fpga-bus
v11: No change in this patch for v11 of the patch set
v12: Moved out of staging
Small changes due to using FPGA bridge framework and not representing the bridges as resets.
v13: Fix some nits

---
 Documentation/fpga/simple-fpga-bus.txt | 58 ++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/fpga/simple-fpga-bus.txt
Documentation/fpga/simple-fpga-bus.txt new file +58 -0
new file mode 100644
index 0000000..9b04826
@@ -0,0 +1,58 @@
+Simple FPGA Bus
+
+Alan Tull 2015
+
+Overview
+========
+
+The simple FPGA bus adds device tree overlay support for FPGAs.  Loading a DT
+overlay will result in the FPGA getting programmed with an image, its bridges
+will be released, and the DT populated for nodes below the simple-fpga-bus.
+This results in drivers getting probed for the hardware that just got added.
+This is intended to support the FPGA usage where the FPGA has hardware that
+requires drivers.  Removing the overlay will result in the drivers getting
+removed and the bridges being disabled.
+
+The simple FPGA bus will need to disable and enable bridges that will only
+affect the child devices that are below the bus.  If partial reconfiguration
+is to be done, then bridges will need to be added within the FPGA design to
+protect the rest of the bus when one part of the FPGA design is being
+reconfigured.
+
+
+Sequence
+========
+
+Load the DT overlay.  One way to do that from user space is to use Pantelis'
+DT-Overlay configfs interface.
+
+This causes the simple FPGA bus to be probed and will do the following:
+ 1. Disable the FPGA bridges.
+ 2. Call the FPGA manager core to program the FPGA.
+ 3. Release the FPGA bridges.
+ 4. Call of_platform_populate resulting in device drivers getting probed.
+
+
+Requirements
+============
+
+ 1. An FPGA image that has a hardware block or blocks that use drivers that are
+    supported in the kernel.
+ 2. A device tree overlay (example is in the simple-fpga-bus bindings document).
+ 3. A FPGA manager driver supporting writing the FPGA.
+ 4. FPGA bridge drivers.
+
+The DT overlay includes bindings (documented in bindings/simple-fpga-bus.txt)
+that specify:
+ * Which FPGA manager to use.
+ * Which image file to load.
+ * Flags indicating whether this this image is for full reconfiguration or
+   partial.
+ * A list of FPGA bridges.
+ * Child nodes specifying the devices that will be added with appropriate
+   compatible strings, etc.
+
+Since this code uses the firmware interface to get the image and DT overlay,
+they currently have to be files on the file system.  It doesn't have to be that
+way forever as DT bindings could be added to point to other sources for the
+image.
Signature · 1 line
1.9.1
#2 lore raw

PATCH v13 2/6 fpga: add bindings document for simple fpga bus

In reply to [email protected]

From: Alan Tull <[email protected]>

New bindings document for simple fpga bus.

---

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@0xff20000 -> bridge@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"

---
 .../devicetree/bindings/fpga/simple-fpga-bus.txt   | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fpga/simple-fpga-bus.txt
Documentation/devicetree/bindings/fpga/simple-fpga-bus.txt new file +74 -0
new file mode 100644
index 0000000..9646c09
@@ -0,0 +1,74 @@
+Simple FPGA Bus
+===============
+
+A Simple FPGA Bus is a bus that handles configuring an FPGA and its bridges
+before populating the devices below its node.
+
+Required properties:
+- compatible : should contain "simple-fpga-bus"
+- #address-cells, #size-cells, ranges: must be present to handle address space
+  mapping for children.
+
+Optional properties:
+- fpga-mgr : should contain a phandle to a FPGA manager.
+- fpga-firmware : should contain the name of a FPGA image file located on the
+  firmware search path.
+- partial-reconfig : boolean property should be defined if partial
+  reconfiguration of the FPGA is to be done, otherwise full reconfiguration
+  is done.
+- fpga-bridges : should contain a list of bridges that the bus will disable
+  before programming the FPGA and then enable after the FPGA has been
+  programmed.
+
+Example:
+
+/dts-v1/;
+/plugin/;
+/ {
+	fragment@0 {
+		target-path="/soc";
+		__overlay__ {
+			#address-cells = <1>;
+	                #size-cells = <1>;
+
+			bridge@ff200000 {
+				compatible = "simple-fpga-bus";
+
+				#address-cells = <0x2>;
+				#size-cells = <0x1>;
+
+				ranges = <0x00000000 0x00000000 0xc0000000 0x00010000>,
+					 <0x00000001 0x00020000 0xff220000 0x00000008>,
+					 <0x00000001 0x00010040 0xff210040 0x00000020>;
+
+				fpga-mgr = <&hps_0_fpgamgr>;
+				firmware-name = "soc_system.rbf";
+
+				fpga-bridges = <&hps_fpgabridge0>, <&hps_fpgabridge1>, <&hps_fpgabridge2>;
+
+				onchip_memory2_0: memory@000000000 {
+					device_type = "memory";
+					compatible = "ALTR,onchipmem-15.1";
+					reg = <0x00000000 0x00000000 0x00010000>;
+				};
+
+				jtag_uart: serial@100020000 {
+					compatible = "altr,juart-15.1", "altr,juart-1.0";
+					reg = <0x00000001 0x00020000 0x00000008>;
+					interrupt-parent = <&intc>;
+					interrupts = <0 42 4>;
+				};
+
+				led_pio: gpio@100010040 {
+					compatible = "altr,pio-15.1", "altr,pio-1.0";
+					reg = <0x00000001 0x00010040 0x00000020>;
+					altr,gpio-bank-width = <4>;
+					resetvalue = <0>;
+					#gpio-cells = <2>;
+					gpio-controller;
+				};
+			};
+		};
+	};
+};
+
Signature · 1 line
1.9.1
#3 lore raw

PATCH v13 3/6 fpga: add simple-fpga-bus

In reply to [email protected]

From: Alan Tull <[email protected]>

The Simple FPGA bus uses the FPGA Manager Framework and the FPGA Bridge Framework to provide a manufactorer-agnostic interface for reprogramming FPGAs that is Device Tree Overlays-based.

When a Device Tree Overlay containing a Simple FPGA Bus is applied, the Simple FPGA Bus will be probed and will:
* Disable the FPGA bridges specified in the overlay
* Reprogram a specified FPGA with a specified image file
* Enable the specified FPGA bridges
* Populate the child devices

Removing the Device Tree Overlay is also supported.

This supports fpga use where hardware blocks on a fpga will need drivers.

---

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

---
 drivers/fpga/Kconfig           |   7 +
 drivers/fpga/Makefile          |   3 +
 drivers/fpga/simple-fpga-bus.c | 323 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 333 insertions(+)
 create mode 100644 drivers/fpga/simple-fpga-bus.c
drivers/fpga/Kconfig +7 -0
index c9b9fdf..5fcf60a 100644
@@ -13,6 +13,13 @@ config FPGA
 
 if FPGA
 
+config SIMPLE_FPGA_BUS
+       bool "Simple FPGA Bus"
+       depends on OF
+       help
+         Simple FPGA Bus allows loading FPGA images under control of
+	 Device Tree.
+
 config FPGA_MGR_SOCFPGA
 	tristate "Altera SOCFPGA FPGA Manager"
 	depends on ARCH_SOCFPGA
drivers/fpga/Makefile +3 -0
index 8d83fc6..9b55ae0 100644
@@ -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
+
+# High Level Interfaces
+obj-$(CONFIG_SIMPLE_FPGA_BUS)		+= simple-fpga-bus.o
drivers/fpga/simple-fpga-bus.c new file +323 -0

323 lines not on this page · raw message

Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH v13 4/6 fpga: add fpga bridge framework

In reply to [email protected]

From: Alan Tull <[email protected]>

This 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 FPGAs.

The functions are:
* of_fpga_bridge_get
* fpga_bridge_put
Get/put a 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.

---

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

---
 drivers/fpga/Kconfig             |   7 ++
 drivers/fpga/Makefile            |   3 +
 drivers/fpga/fpga-bridge.c       | 229 +++++++++++++++++++++++++++++++++++++++
 include/linux/fpga/fpga-bridge.h |  74 +++++++++++++
 4 files changed, 313 insertions(+)
 create mode 100644 drivers/fpga/fpga-bridge.c
 create mode 100644 include/linux/fpga/fpga-bridge.h
drivers/fpga/Kconfig +7 -0
index 5fcf60a..6383b47 100644
@@ -31,6 +31,13 @@ config FPGA_MGR_ZYNQ_FPGA
 	help
 	  FPGA manager driver support for Xilinx Zynq FPGAs.
 
+config FPGA_BRIDGE
+       bool "FPGA Bridge Drivers"
+       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
index 9b55ae0..5e9e0e1 100644
@@ -9,5 +9,8 @@ obj-$(CONFIG_FPGA)			+= fpga-mgr.o
 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
+
 # High Level Interfaces
 obj-$(CONFIG_SIMPLE_FPGA_BUS)		+= simple-fpga-bus.o
drivers/fpga/fpga-bridge.c new file +229 -0

229 lines not on this page · raw message

include/linux/fpga/fpga-bridge.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH v13 4/6] fpga: add fpga bridge framework

Hi Alan,

while trying to implement something that works for Zynq along these lines I stumbled upon some minor stuff.

drivers/fpga/fpga-bridge.c line 124

Quoted 4 lines · On Tue, Nov 3, 2015 at 9:11 AM, <[email protected]> wrote:

+ * Return: 0 on success, negative error code otherwise.
+ */

drivers/fpga/fpga-bridge.c new file +2 -0
+int fpga_bridge_register(struct device *dev, const char *name,
+                        struct fpga_bridge_ops *br_ops, void *priv)

const struct fpga_bridge_ops

include/linux/fpga/fpga-bridge.h line 71

Quoted 2 lines
include/linux/fpga/fpga-bridge.h new file +2 -0
+int fpga_bridge_register(struct device *dev, const char *name,
+                        struct fpga_bridge_ops *br_ops, void *priv);

const struct fpga_bridge_ops

Cheers,

Moritz

author
#6 lore raw

Re: [PATCH v13 4/6] fpga: add fpga bridge framework

Quoted 14 lines · Moritz Fischer

Hi Alan,

while trying to implement something that works for Zynq along these lines I stumbled upon some minor stuff.

drivers/fpga/fpga-bridge.c line 124

Quoted 4 lines · On Tue, Nov 3, 2015 at 9:11 AM, <[email protected]> wrote:

+ * Return: 0 on success, negative error code otherwise.
+ */

drivers/fpga/fpga-bridge.c new file +2 -0
+int fpga_bridge_register(struct device *dev, const char *name,
+                        struct fpga_bridge_ops *br_ops, void *priv)

const struct fpga_bridge_ops

Quoted 8 lines

include/linux/fpga/fpga-bridge.h line 71

Quoted 2 lines
include/linux/fpga/fpga-bridge.h new file +2 -0
+int fpga_bridge_register(struct device *dev, const char *name,
+                        struct fpga_bridge_ops *br_ops, void *priv);

const struct fpga_bridge_ops

Cheers,

Moritz

Hi Moritz,

Thanks!

Alan

#7 lore raw

PATCH v13 5/6 ARM: socfpga: add bindings document for fpga bridge drivers

In reply to [email protected]

From: Alan Tull <[email protected]>

Add bindings documentation for Altera SOCFPGA bridges:
* fpga2sdram
* fpga2hps
* hps2fpga
* lwhps2fpga

---

v2:  separate into 2 documents for the 2 drivers
v12: bump version to line up with simple-fpga-bus version

remove Linux specific notes such as references to sysfs move non-DT specific documentation elsewhere
remove bindings that would have been used to pass configuration clean up formatting
v13: Remove 'label' property
Change property from init-val to bridge-enable
Fix email address

---
 .../bindings/fpga/altera-fpga2sdram-bridge.txt     | 15 +++++++++++
 .../bindings/fpga/altera-hps2fpga-bridge.txt       | 31 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fpga/altera-fpga2sdram-bridge.txt
 create mode 100644 Documentation/devicetree/bindings/fpga/altera-hps2fpga-bridge.txt
Documentation/devicetree/bindings/fpga/altera-fpga2sdram-bridge.txt new file +15 -0
new file mode 100644
index 0000000..81e2f06
@@ -0,0 +1,15 @@
+Altera FPGA To SDRAM Bridge Driver
+
+Required properties:
+- compatible		: Should contain "altr,socfpga-fpga2sdram-bridge"
+
+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:
+	fpga2sdram_br: fpgabridge@3 {
+		compatible = "altr,socfpga-fpga2sdram-bridge";
+		bridge-enable = <0>;
+	};
Documentation/devicetree/bindings/fpga/altera-hps2fpga-bridge.txt new file +31 -0
new file mode 100644
index 0000000..67c28b0
@@ -0,0 +1,31 @@
+Altera FPGA/HPS Bridge Driver
+
+Required properties:
+- compatible	: Should contain one of:
+		  "altr,socfpga-hps2fpga-bridge",
+		  "altr,socfpga-lwhps2fpga-bridge", or
+		  "altr,socfpga-fpga2hps-bridge"
+- clocks	: Clocks used by this 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 its current state.
+
+Example:
+	hps_fpgabridge0: fpgabridge@0 {
+		compatible = "altr,socfpga-hps2fpga-bridge";
+		clocks = <&l4_main_clk>;
+		bridge-enable = <1>;
+	};
+
+	hps_fpgabridge1: fpgabridge@1 {
+		compatible = "altr,socfpga-lwhps2fpga-bridge";
+		clocks = <&l4_main_clk>;
+		bridge-enable = <0>;
+	};
+
+	hps_fpgabridge2: fpgabridge@2 {
+		compatible = "altr,socfpga-fpga2hps-bridge";
+		clocks = <&l4_main_clk>;
+	};
Signature · 1 line
1.9.1
#8 lore raw

PATCH v13 6/6 ARM: socfpga: fpga bridge driver support

In reply to [email protected]

From: Alan Tull <[email protected]>

Supports 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

---
 drivers/fpga/Kconfig             |   7 ++
 drivers/fpga/Makefile            |   1 +
 drivers/fpga/altera-fpga2sdram.c | 185 +++++++++++++++++++++++++++++++
 drivers/fpga/altera-hps2fpga.c   | 233 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 426 insertions(+)
 create mode 100644 drivers/fpga/altera-fpga2sdram.c
 create mode 100644 drivers/fpga/altera-hps2fpga.c
drivers/fpga/Kconfig +7 -0
index 6383b47..ccbacd0 100644
@@ -38,6 +38,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
+	bool "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
index 5e9e0e1..93c7aff 100644
@@ -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_SIMPLE_FPGA_BUS)		+= simple-fpga-bus.o
drivers/fpga/altera-fpga2sdram.c new file +185 -0

185 lines not on this page · raw message

drivers/fpga/altera-hps2fpga.c new file +233 -0

233 lines not on this page · raw message

Signature · 1 line
1.9.1