patches for fpga
Subsystems (5)
v2 cover patches for fpga
Hi Greg,
This is a repost of last weeks patches, fixing the warnings. I've also added the Altera CvP driver which has been reviewed on the lists. I pushed these to my kernel.org git repo for testing (which I should have done in the first place) on Monday and the robot hasn't complained.
Changes from v1:
* Drop "fpga: allow to compile-test Altera FPGA bridge drivers"
* take v13 of the Altera ps-spi set with a one line Kconfig change to fix a warning.
* Add the Altera CvP set
Alan
Anatolij Gustschin (3):
fpga: Add flag to indicate SPI bitstream is bit-reversed
fpga: Add flag to indicate bitstream needs decompression fpga manager: Add Altera CvP driver
Joel Holdsworth (1):
of: Add vendor prefix for Lattice Semiconductor
Joshua Clayton (5):
doc: dt: document altera-passive-serial binding fpga manager: Add altera-ps-spi driver for Altera FPGAs
ARM: dts: imx6q-evi: support altera-ps-spi
lib: add bitrev8x4()
fpga-manager: altera-ps-spi: use bitrev8x4
Moritz Fischer (1):
dt-bindings: fpga: Add bindings document for Xilinx LogiCore PR
Decoupler
Vincent Legoll (1):
Make FPGA a menuconfig to ease disabling it all
Documentation/ABI/testing/sysfs-driver-altera-cvp | 8 + .../bindings/fpga/altera-passive-serial.txt | 29 ++ .../bindings/fpga/xilinx-pr-decoupler.txt | 36 ++ .../devicetree/bindings/vendor-prefixes.txt | 1 + arch/arm/boot/dts/imx6q-evi.dts | 16 + drivers/fpga/Kconfig | 20 +- drivers/fpga/Makefile | 2 + drivers/fpga/altera-cvp.c | 500 +++++++++++++++++++++ drivers/fpga/altera-ps-spi.c | 308 +++++++++++++ include/linux/bitrev.h | 19 + include/linux/fpga/fpga-mgr.h | 4 + 11 files changed, 938 insertions(+), 5 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-altera-cvp create mode 100644 Documentation/devicetree/bindings/fpga/altera-passive-serial.txt create mode 100644 Documentation/devicetree/bindings/fpga/xilinx-pr-decoupler.txt create mode 100644 drivers/fpga/altera-cvp.c create mode 100644 drivers/fpga/altera-ps-spi.c
Signature · 1 line
2.7.4
PATCH v2 1/11 dt-bindings: fpga: Add bindings document for Xilinx LogiCore PR Decoupler
From: Moritz Fischer <[email protected]>
This adds the binding documentation for the Xilinx LogiCORE PR Decoupler soft core.
Signed off-by: Alan Tull <[email protected]>
--- .../bindings/fpga/xilinx-pr-decoupler.txt | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/xilinx-pr-decoupler.txt
Documentation/devicetree/bindings/fpga/xilinx-pr-decoupler.txt new file +36 -0
@@ -0,0 +1,36 @@ +Xilinx LogiCORE Partial Reconfig Decoupler Softcore + +The Xilinx LogiCORE Partial Reconfig Decoupler manages one or more +decouplers / fpga bridges. +The controller can decouple/disable the bridges which prevents signal +changes from passing through the bridge. The controller can also +couple / enable the bridges which allows traffic to pass through the +bridge normally. + +The Driver supports only MMIO handling. A PR region can have multiple +PR Decouplers which can be handled independently or chained via decouple/ +decouple_status signals. + +Required properties: +- compatible : Should contain "xlnx,pr-decoupler-1.00" followed by + "xlnx,pr-decoupler" +- regs : base address and size for decoupler module +- clocks : input clock to IP +- clock-names : should contain "aclk" + +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. + +See Documentation/devicetree/bindings/fpga/fpga-region.txt for generic bindings. + +Example: + fpga-bridge@100000450 { + compatible = "xlnx,pr-decoupler-1.00", + "xlnx-pr-decoupler"; + regs = <0x10000045 0x10>; + clocks = <&clkc 15>; + clock-names = "aclk"; + bridge-enable = <0>; + };
Signature · 1 line
2.7.4
PATCH v2 2/11 Make FPGA a menuconfig to ease disabling it all
In reply to Alan TullFrom: Vincent Legoll <[email protected]>
No need to get into the submenu to disable all FPGA-related config entries
--- drivers/fpga/Kconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/fpga/Kconfig +1 -5
@@ -2,9 +2,7 @@ # FPGA framework configuration # -menu "FPGA Configuration Support" - -config FPGA +menuconfig FPGA tristate "FPGA Configuration Framework" help Say Y here if you want support for configuring FPGAs from the
@@ -106,5 +104,3 @@ config XILINX_PR_DECOUPLER being reprogrammed during partial reconfig. endif # FPGA - -endmenu
Signature · 1 line
2.7.4
PATCH v2 3/11 fpga: Add flag to indicate SPI bitstream is bit-reversed
In reply to Alan TullFrom: Anatolij Gustschin <[email protected]>
Add a flag that is passed to the write_init() callback, indicating that the SPI bitstream starts with LSB first. SPI controllers usually send data with MSB first. If an FPGA expects bitstream data as LSB first, the data must be reversed either by the SPI controller or by the driver.
Alternatively the bitstream could be prepared as bit-reversed to avoid the bit-swapping while sending. This flag indicates such bit-reversed SPI bitstream. The low-level driver will deal with the flag and perform bit-reversing if needed.
--- include/linux/fpga/fpga-mgr.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/fpga/fpga-mgr.h +2 -0
@@ -67,10 +67,12 @@ 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 +* FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first */ #define FPGA_MGR_PARTIAL_RECONFIG BIT(0)#define FPGA_MGR_EXTERNAL_CONFIG BIT(1)#define FPGA_MGR_ENCRYPTED_BITSTREAM BIT(2) +#define FPGA_MGR_BITSTREAM_LSB_FIRST BIT(3)/** * struct fpga_image_info - information specific to a FPGA image
Signature · 1 line
2.7.4
PATCH v2 4/11 doc: dt: document altera-passive-serial binding
In reply to Alan TullFrom: Joshua Clayton <[email protected]>
Describe an altera-passive-serial devicetree entry, required features
--- .../bindings/fpga/altera-passive-serial.txt | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/altera-passive-serial.txt
Documentation/devicetree/bindings/fpga/altera-passive-serial.txt new file +29 -0
@@ -0,0 +1,29 @@ +Altera Passive Serial SPI FPGA Manager + +Altera FPGAs support a method of loading the bitstream over what is +referred to as "passive serial". +The passive serial link is not technically SPI, and might require extra +circuits in order to play nicely with other SPI slaves on the same bus. + +See https://www.altera.com/literature/hb/cyc/cyc_c51013.pdf + +Required properties: +- compatible: Must be one of the following: + "altr,fpga-passive-serial", + "altr,fpga-arria10-passive-serial" +- reg: SPI chip select of the FPGA +- nconfig-gpios: config pin (referred to as nCONFIG in the manual) +- nstat-gpios: status pin (referred to as nSTATUS in the manual) + +Optional properties: +- confd-gpios: confd pin (referred to as CONF_DONE in the manual) + +Example: + fpga: fpga@0 { + compatible = "altr,fpga-passive-serial"; + spi-max-frequency = <20000000>; + reg = <0>; + nconfig-gpios = <&gpio4 9 GPIO_ACTIVE_LOW>; + nstat-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>; + confd-gpios = <&gpio4 12 GPIO_ACTIVE_LOW>; + };
Signature · 1 line
2.7.4
PATCH v2 5/11 fpga manager: Add altera-ps-spi driver for Altera FPGAs
In reply to Alan TullFrom: Joshua Clayton <[email protected]>
altera-ps-spi loads FPGA firmware over SPI, using the "passive serial" interface on Altera Arria 10, Cyclone V or Stratix V FPGAs.
This is one of the simpler ways to set up an FPGA at runtime. The signal interface is close to unidirectional SPI with lsb first.
--- drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 1 + drivers/fpga/altera-ps-spi.c | 297 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 305 insertions(+) create mode 100644 drivers/fpga/altera-ps-spi.c
drivers/fpga/Kconfig +7 -0
@@ -24,6 +24,13 @@ config FPGA_MGR_ICE40_SPI help FPGA manager driver support for Lattice iCE40 FPGAs over SPI. +config FPGA_MGR_ALTERA_PS_SPI + tristate "Altera FPGA Passive Serial over SPI" + depends on SPI + help + FPGA manager driver support for Altera Arria/Cyclone/Stratix + using the passive serial interface over SPI. + config FPGA_MGR_SOCFPGA tristate "Altera SOCFPGA FPGA Manager" depends on ARCH_SOCFPGA || COMPILE_TEST
drivers/fpga/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_FPGA) += fpga-mgr.o # FPGA Manager Drivers +obj-$(CONFIG_FPGA_MGR_ALTERA_PS_SPI) += altera-ps-spi.o obj-$(CONFIG_FPGA_MGR_ICE40_SPI) += ice40-spi.o obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o obj-$(CONFIG_FPGA_MGR_SOCFPGA_A10) += socfpga-a10.o
drivers/fpga/altera-ps-spi.c new file +297 -0
297 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 6/11 ARM: dts: imx6q-evi: support altera-ps-spi
In reply to Alan TullFrom: Joshua Clayton <[email protected]>
Add support for Altera FPGA connected to an spi port to the evi devicetree file
--- arch/arm/boot/dts/imx6q-evi.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/boot/dts/imx6q-evi.dts +16 -0
@@ -94,6 +94,15 @@ pinctrl-names = "default"; pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_ecspi1cs>; status = "okay"; + + fpga: fpga@0 { + compatible = "altr,fpga-passive-serial"; + spi-max-frequency = <20000000>; + reg = <0>; + pinctrl-0 = <&pinctrl_fpgaspi>; + nconfig-gpios = <&gpio4 9 GPIO_ACTIVE_LOW>; + nstat-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>; + }; }; &ecspi3 {
@@ -319,6 +328,13 @@ >; }; + pinctrl_fpgaspi: fpgaspigrp { + fsl,pins = < + MX6QDL_PAD_KEY_ROW1__GPIO4_IO09 0x1b0b0 + MX6QDL_PAD_KEY_ROW2__GPIO4_IO11 0x1b0b0 + >; + }; + pinctrl_gpminand: gpminandgrp { fsl,pins = < MX6QDL_PAD_NANDF_CLE__NAND_CLE 0xb0b1
Signature · 1 line
2.7.4
PATCH v2 7/11 lib: add bitrev8x4()
In reply to Alan TullFrom: Joshua Clayton <[email protected]>
Add a function to reverse bytes within a 32 bit word. Operate on a u32 rather than individual bytes.
--- include/linux/bitrev.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/linux/bitrev.h +19 -0
@@ -29,6 +29,8 @@ static inline u32 __bitrev32(u32 x)#endif /* CONFIG_HAVE_ARCH_BITREVERSE */ +#define __bitrev8x4 (x) (__bitrev32(swab32(x))) +#define __constant_bitrev32 (x) \ ({ \ u32 __x = x; \
@@ -50,6 +52,15 @@ static inline u32 __bitrev32(u32 x) __x; \ }) +#define __constant_bitrev8x4 (x) \ +({ \ + u32 __x = x; \ + __x = ((__x & (u32)0xF0F0F0F0UL) >> 4) | ((__x & (u32)0x0F0F0F0FUL) << 4); \ + __x = ((__x & (u32)0xCCCCCCCCUL) >> 2) | ((__x & (u32)0x33333333UL) << 2); \ + __x = ((__x & (u32)0xAAAAAAAAUL) >> 1) | ((__x & (u32)0x55555555UL) << 1); \ + __x; \ +}) +#define __constant_bitrev8 (x) \ ({ \ u8 __x = x; \
@@ -75,6 +86,14 @@ static inline u32 __bitrev32(u32 x)__bitrev16 (__x); \ }) +#define bitrev8x4 (x) \ +({ \ + u32 __x = x; \ + __builtin_constant_p(__x) ? \ + __constant_bitrev8x4(__x) : \ + __bitrev8x4(__x); \ + }) +#define bitrev8 (x) \ ({ \ u8 __x = x; \
Signature · 1 line
2.7.4
PATCH v2 8/11 fpga-manager: altera-ps-spi: use bitrev8x4
In reply to Alan TullFrom: Joshua Clayton <[email protected]>
Speed up bit reversal by using hardware bit reversal Add extra code to handle less than 4byte remnants, if any
--- drivers/fpga/altera-ps-spi.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/fpga/altera-ps-spi.c +15 -4
@@ -149,12 +149,23 @@ static int altera_ps_write_init(struct fpga_manager *mgr,static void rev_buf (char *buf,size_t len) { -const char *fw_end = (buf + len); +u32 *fw32 = (u32 *)buf; +size_t extra_bytes = (len &0x03 ); +const u32 *fw_end = (u32 *)(buf + len - extra_bytes);/* set buffer to lsb first */ -while (buf < fw_end) { - *buf =bitrev8 (*buf); - buf++; +while (fw32 < fw_end) { + *fw32 =bitrev8x4 (*fw32); + fw32++; + } + +if (extra_bytes) { + buf = (char *)fw_end; +while (extra_bytes) { + *buf =bitrev8 (*buf); + buf++; + extra_bytes--; + } } }
Signature · 1 line
2.7.4
PATCH v2 9/11 of: Add vendor prefix for Lattice Semiconductor
In reply to Alan TullFrom: Joel Holdsworth <[email protected]>
Lattice Semiconductor Corporation is a manufacturer of integrated circuits and IP products, including low-power FPGAs, video connectivity devices and millimeter wave wireless products.
Website: http://latticesemi.com
--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -173,6 +173,7 @@ kosagi Sutajio Ko-Usagi PTE Ltd. kyo Kyocera Corporation lacie LaCie lantiq Lantiq Semiconductor +lattice Lattice Semiconductor lego LEGO Systems A/S lenovo Lenovo Group Ltd. lg LG Corporation
Signature · 1 line
2.7.4
PATCH v2 10/11 fpga: Add flag to indicate bitstream needs decompression
In reply to Alan TullFrom: Anatolij Gustschin <[email protected]>
Add a flag that is passed to the write_init() callback, indicating that the bitstream is compressed.
The low-level driver will deal with the flag, or return an error, if compressed bitstreams are not supported.
--- include/linux/fpga/fpga-mgr.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/fpga/fpga-mgr.h +2 -0
@@ -68,11 +68,13 @@ enum fpga_mgr_states {* FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting * FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first +* FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed */ #define FPGA_MGR_PARTIAL_RECONFIG BIT(0)#define FPGA_MGR_EXTERNAL_CONFIG BIT(1)#define FPGA_MGR_ENCRYPTED_BITSTREAM BIT(2)#define FPGA_MGR_BITSTREAM_LSB_FIRST BIT(3) +#define FPGA_MGR_COMPRESSED_BITSTREAM BIT(4)/** * struct fpga_image_info - information specific to a FPGA image
Signature · 1 line
2.7.4
PATCH v2 11/11 fpga manager: Add Altera CvP driver
In reply to Alan TullFrom: Anatolij Gustschin <[email protected]>
Add FPGA manager driver for loading Arria-V/Cyclone-V/Stratix-V and Arria-10 FPGAs via CvP.
--- Documentation/ABI/testing/sysfs-driver-altera-cvp | 8 + drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 1 + drivers/fpga/altera-cvp.c | 500 ++++++++++++++++++++++ 4 files changed, 516 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-altera-cvp create mode 100644 drivers/fpga/altera-cvp.c
Documentation/ABI/testing/sysfs-driver-altera-cvp new file +8 -0
@@ -0,0 +1,8 @@ +What: /sys/bus/pci/drivers/altera-cvp/chkcfg +Date: May 2017 +Kernel Version: 4.13 +Contact: Anatolij Gustschin <[email protected]> +Description: + Contains either 1 or 0 and controls if configuration + error checking in altera-cvp driver is turned on or + off.
drivers/fpga/Kconfig +7 -0
@@ -24,6 +24,13 @@ config FPGA_MGR_ICE40_SPI help FPGA manager driver support for Lattice iCE40 FPGAs over SPI. +config FPGA_MGR_ALTERA_CVP + tristate "Altera Arria-V/Cyclone-V/Stratix-V CvP FPGA Manager" + depends on PCI + help + FPGA manager driver support for Arria-V, Cyclone-V, Stratix-V + and Arria 10 Altera FPGAs using the CvP interface over PCIe. + config FPGA_MGR_ALTERA_PS_SPI tristate "Altera FPGA Passive Serial over SPI" depends on SPI
drivers/fpga/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_FPGA) += fpga-mgr.o # FPGA Manager Drivers +obj-$(CONFIG_FPGA_MGR_ALTERA_CVP) += altera-cvp.o obj-$(CONFIG_FPGA_MGR_ALTERA_PS_SPI) += altera-ps-spi.o obj-$(CONFIG_FPGA_MGR_ICE40_SPI) += ice40-spi.o obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o
drivers/fpga/altera-cvp.c new file +500 -0
500 lines not on this page · raw message
Signature · 1 line
2.7.4
Hi Greg,
Quoted 7 lines · On Wed, 14 Jun 2017 10:36:24 -0500 Alan Tull [email protected] wrote:
Hi Greg,
This is a repost of last weeks patches, fixing the warnings. I've also added the Altera CvP driver which has been reviewed on the lists. I pushed these to my kernel.org git repo for testing (which I should have done in the first place) on Monday and the robot hasn't complained.
Is this series queued for merging in 4.13-rc1 ?
thanks,
Anatolij
Quoted 7 lines · Anatolij Gustschin
Hi Greg,
Quoted 2 lines · On Wed, 14 Jun 2017 10:36:24 -0500 Alan Tull [email protected] wrote:
Hi Greg,
Quoted 7 lines
Quoted 5 lines
This is a repost of last weeks patches, fixing the warnings. I've also added the Altera CvP driver which has been reviewed on the lists. I pushed these to my kernel.org git repo for testing (which I should have done in the first place) on Monday and the robot hasn't complained.
Is this series queued for merging in 4.13-rc1 ?
Nope, it missed my merge window for that, sorry. I'll queue them up to my tree after 4.13-rc1 is out. If there are any specific bugfixes in here that should go into 4.13-final, please let me know.
thanks,
greg k-h
On Tue, 4 Jul 2017 11:12:17 +0200
Greg Kroah-Hartman [email protected] wrote:
...
Quoted 5 lines
Quoted 1 line
Is this series queued for merging in 4.13-rc1 ?
Nope, it missed my merge window for that, sorry. I'll queue them up to my tree after 4.13-rc1 is out. If there are any specific bugfixes in here that should go into 4.13-final, please let me know.
Okay. No, there are no bugfixes in this series.
thanks,
Anatolij