Skip to contentSkip to conversation

Add support for ARRI FPGA configuration

PATCH Superseded Anatolij Gustschin 1 participant 6 messages Nov 27, 2018 – Dec 5, 2018

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add support for ARRI FPGA configuration

This series adds drivers and FPGA manager support required for FT232H based ARRI FPGA configuration adapters.

Patch 1/3 adds FT232H interface driver (for ARRI USB PIDs) implementing commonly used FTDI USB transfer operations and ACBUS/MPSSE GPIO controllers. Depending on USB PIDs it creates platform devices for MPSSE SPI bus with attached SPI slaves or platform devices for ARRI FPP FPGA manager.

Patch 2/3 adds MPSSE SPI controller driver which registers an FTDI USB-SPI bus with attached SPI slaves from description in platform data, so existing SPI protocol drivers can be used for these slave devices (in our case altera-ps-spi). Via interface driver in patch 1/3 it is easily possible to add support for other slave devices using custom USB PIDs (e.g. spi-nor flash W25Q32 with m25p80 driver has beed used for testing MPSSE SPI controller driver).

Patch 3/3 adds FPGA manager driver for ARRI FPP adapters for FPGA configuration via Altera fast passive parallel interface.

Changes since v2:
Patch 1/3
- use unsigned type for baudrate and clk divider calculation (don't mix signed/unsigned types)
- switch to unsigned int for 'encoded_divisor'
- use DIV_ROUND_CLOSEST() in ftdi_to_clkbits()
- update error messages in ftdi_convert_baudrate()
- update return code check of ftdi_to_clkbits()
- fix boolconv coccinelle warning
- add and use macro for MPSSE GPIOs number
- update struct mpsse_spi_platform_data to drop pin description fields and add mpsse_spi_dev_data struct instead. This allows easier pin description and init for multiple SPI devices with multiple control pins. Pass pin description via platform_data of spi_bus_info for esier IO pin init code in MPSSE driver. Update spi_board_info table accordingly
- keep Makefile entry sorted

Patch 2/3
- keep Makefile entry sorted
- make the entire comment block a C++ one
- don't use magic number for the size of the lookup table
- use sizeof() instead of magic number for the buffer size
- rework gpio chip select function to use it as .set_cs()
- convert to use transfer_one instead of transfer_one_message
- update dev_*() to use MPSSE platform device prefix
- s/spi_master/spi_controller
- use u16 for chip_select vars and update dev_dbg format
- use unsigned type for index vars
- reduce arguments number for ftdi_spi_tx()/ftdi_spi_rx()
- fix ftdi_spi_tx() to send all buffer data correctly even if the USB driver signals transfer of less data than requested
- update ftdi_spi_init_io() to differentiate between platform data for devices using MPSSE I/O pins and other SPI devices (e.g. using flash_platform_data, mmc_spi_platform_data, etc.). This makes the driver more generic and allows using multiple SPI slaves on the MPSSE bus
- reduce !xfer->len checks

Patch 3/3
fix 'specified bound 8 equals destination size' gcc 8 warning

Changes since v1:
Patch 1/3
- add myself as a maintainer for these drivers
- update copyright line to include 2018
- include required linux headers
- fix gcc 7.3.0 build warnings -Wunused-const-variable=
- make ftdi functions and spi_board_info struct static
- use KBUILD_MODNAME in drivers struct
- use dev_err() for error messages instead of dev_info()
- drop not needed output about number of used MPSSE pins since it is constant (not configurable)
- remove ftdi function prototypes from header ft232h-intf.h as these are not exported anymore
- update comments (don't use kernel-doc format as we do not export symbols anymore and functions are "static")

Patch 2/3
- fix build breakage when building with ARCH=i386 allmodconfig
- add checks for ops->lock/ops->unlock presence in pdata
- update copyright line to include 2018
- remove printing numbers in parentheses (%d)

Patch 3/3
- update copyright line to include 2018
- add sysfs ABI documentation

Changes since initial version (MFD based):
- don't use MFD framework
- don't use original FT232H USB PID (it is too generic and collides with existing ftdi_sio driver)
- don't add separate CBUS GPIO driver based on FT232H MFD device
- redesign/rework the drivers as described under [4]
- add basic FT232H interface driver under drivers/usb/misc/
- use custom reserved USB PIDs in the USB driver for adapter devices
- add notes about borrowed protocol code from libftdi to commit log and header file
- add MPSSE SPI controller driver supporting USB-SPI bus with dynamically added SPI slaves from description in platform data (the initial attempt didn't include USB SPI bus support for PS- SPI FPGA configuration via USB)
- rework FPP fpga manager driver based on new FT232H interface driver and extend it according to CPLD changes for additional support of new hardware revision B.

Anatolij Gustschin (3):
usb: misc: add driver for FT232H based FPGA configuration devices
spi: add FTDI MPSSE SPI controller driver
fpga: Add fpga manager driver for ARRI Altera FPP

 .../ABI/testing/sysfs-driver-ftdi-fifo-fpp    |    7 +
 MAINTAINERS                                   |    8 +
 drivers/fpga/Kconfig                          |    7 +
 drivers/fpga/Makefile                         |    1 +
 drivers/fpga/ftdi-fifo-fpp.c                  |  594 +++++++
 drivers/spi/Kconfig                           |    7 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/spi-ftdi-mpsse.c                  |  651 ++++++++
 drivers/usb/misc/Kconfig                      |    9 +
 drivers/usb/misc/Makefile                     |    1 +
 drivers/usb/misc/ft232h-intf.c                | 1467 +++++++++++++++++
 include/linux/usb/ft232h-intf.h               |  206 +++
 12 files changed, 2959 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-ftdi-fifo-fpp
 create mode 100644 drivers/fpga/ftdi-fifo-fpp.c
 create mode 100644 drivers/spi/spi-ftdi-mpsse.c
 create mode 100644 drivers/usb/misc/ft232h-intf.c
 create mode 100644 include/linux/usb/ft232h-intf.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/3 usb: misc: add driver for FT232H based FPGA configuration devices

Add USB interface driver for ARRI FPGA configuration devices based on FTDI FT232H chip. Depending on USB PID the driver registers different platform devices describing an FPGA configuration interface.

One FPGA configuration interface type is the usual SPI bus with additional control and status GPIOs. For this interface type the FTDI MPSSE mode is utilized to support SPI bus and GPIO-L/H pins for SPI bus chipselect and SPI slave device I/O. Subsequent patch adds an MPSSE SPI controller driver for USB-SPI bus support. The actual FPGA configuration driver for SPI bus is already available in the FPGA manager framework (altera-ps-spi module).

Another FPGA configuration interface type is the FT245 FIFO (connected via CPLD) with additional control and status GPIOs on FT232H ACBUS. This interface is used to configure FPGAs using Altera fast passive parallel (FPP) interface. Subsequent patch will add an FPP FPGA manager driver for it.

The FTDI protocol code and prototypes was borrowed from libftdi.

---
 MAINTAINERS                     |    8 +
 drivers/usb/misc/Kconfig        |    9 +
 drivers/usb/misc/Makefile       |    1 +
 drivers/usb/misc/ft232h-intf.c  | 1467 +++++++++++++++++++++++++++++++
 include/linux/usb/ft232h-intf.h |  206 +++++
 5 files changed, 1691 insertions(+)
 create mode 100644 drivers/usb/misc/ft232h-intf.c
 create mode 100644 include/linux/usb/ft232h-intf.h
MAINTAINERS +8 -0
index 380e43f585d3..b87ba647f94a 100644
@@ -15406,6 +15406,14 @@ S:	Maintained
 F:	Documentation/usb/acm.txt
 F:	drivers/usb/class/cdc-acm.*
 
+USB ARRI FPGA CONFIGURATION ADAPTER DRIVER
+M:	Anatolij Gustschin <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/usb/misc/ft232h-intf.c
+F:	drivers/spi/spi-ftdi-mpsse.c
+F:	include/linux/usb/ft232h-intf.h
+
 USB AR5523 WIRELESS DRIVER
 M:	Pontus Fuchs <[email protected]>
 L:	[email protected]
drivers/usb/misc/Kconfig +9 -0
index 68d2f2cd17dd..41304ac7f0e3 100644
@@ -275,3 +275,12 @@ config USB_CHAOSKEY
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called chaoskey.
+
+config USB_FT232H_INTF
+	tristate "FTDI FT232H FPGA configuration interface driver"
+	help
+	  Enable driver support for the FT232H based USB-GPIO/SPI/FIFO
+	  interface adapter for FPGA configuration. Additional drivers
+	  such as spi-ftdi-mpsse, altera-ps-spi, ftdi-fifo-fpp and
+	  fpga-mgr must be enabled in order to use the functionality of
+	  the device.
drivers/usb/misc/Makefile +1 -0
index 109f54f5b9aa..af935effb019 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_USB_CYTHERM)		+= cytherm.o
 obj-$(CONFIG_USB_EMI26)			+= emi26.o
 obj-$(CONFIG_USB_EMI62)			+= emi62.o
 obj-$(CONFIG_USB_EZUSB_FX2)		+= ezusb.o
+obj-$(CONFIG_USB_FT232H_INTF)		+= ft232h-intf.o
 obj-$(CONFIG_USB_FTDI_ELAN)		+= ftdi-elan.o
 obj-$(CONFIG_USB_IDMOUSE)		+= idmouse.o
 obj-$(CONFIG_USB_IOWARRIOR)		+= iowarrior.o
drivers/usb/misc/ft232h-intf.c new file +1467 -0

1,467 lines not on this page · raw message

include/linux/usb/ft232h-intf.h new file +206 -0

206 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 2/3 spi: add FTDI MPSSE SPI controller driver

In reply to Anatolij Gustschin

Add SPI bus controller driver for FTDI MPSSE mode. This driver is supposed to be used together with the FT232H interface driver for FPGA configuration in drivers/usb/misc/ft232h-intf.c which adds an mpsse spi platform device describing USB SPI bus with attached SPI slave devices.

---
 drivers/spi/Kconfig          |   7 +
 drivers/spi/Makefile         |   1 +
 drivers/spi/spi-ftdi-mpsse.c | 651 +++++++++++++++++++++++++++++++++++
 3 files changed, 659 insertions(+)
 create mode 100644 drivers/spi/spi-ftdi-mpsse.c
drivers/spi/Kconfig +7 -0
index 7d3a5c94727e..2cb24e28c485 100644
@@ -259,6 +259,13 @@ config SPI_FSL_LPSPI
 	help
 	  This enables Freescale i.MX LPSPI controllers in master mode.
 
+config SPI_FTDI_MPSSE
+	tristate "FTDI MPSSE SPI controller"
+	depends on USB_FT232H_INTF || COMPILE_TEST
+	help
+	  FT232H supports SPI in MPSSE mode. This driver provides MPSSE
+	  SPI controller in master mode.
+
 config SPI_GPIO
 	tristate "GPIO-based bitbanging SPI Master"
 	depends on GPIOLIB || COMPILE_TEST
drivers/spi/Makefile +1 -0
index 3575205c5c27..065240a02b31 100644
@@ -45,6 +45,7 @@ obj-$(CONFIG_SPI_FSL_LIB)		+= spi-fsl-lib.o
 obj-$(CONFIG_SPI_FSL_ESPI)		+= spi-fsl-espi.o
 obj-$(CONFIG_SPI_FSL_LPSPI)		+= spi-fsl-lpspi.o
 obj-$(CONFIG_SPI_FSL_SPI)		+= spi-fsl-spi.o
+obj-$(CONFIG_SPI_FTDI_MPSSE)		+= spi-ftdi-mpsse.o
 obj-$(CONFIG_SPI_GPIO)			+= spi-gpio.o
 obj-$(CONFIG_SPI_IMG_SPFI)		+= spi-img-spfi.o
 obj-$(CONFIG_SPI_IMX)			+= spi-imx.o
drivers/spi/spi-ftdi-mpsse.c new file +651 -0

651 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH v3 2/3] spi: add FTDI MPSSE SPI controller driver

Hi Mark,

Quoted 5 lines · On Tue, 27 Nov 2018 18:54:37 +0100 Anatolij Gustschin [email protected] wrote:

Add SPI bus controller driver for FTDI MPSSE mode. This driver is supposed to be used together with the FT232H interface driver for FPGA configuration in drivers/usb/misc/ft232h-intf.c which adds an mpsse spi platform device describing USB SPI bus with attached SPI slave devices.

I suppose this patch should go via Greg's usb tree as part of the series, once acked. I've addressed comments in v3, is it okay now?

Thanks,
Anatolij

#4 lore raw

PATCH v3 3/3 fpga: Add fpga manager driver for ARRI Altera FPP

In reply to Anatolij Gustschin

Add FPGA manager driver for loading ARRI Altera FPGAs via fast passive parallel (FPP) interface using FTDI FT232H chip.

---
 .../ABI/testing/sysfs-driver-ftdi-fifo-fpp    |   7 +
 drivers/fpga/Kconfig                          |   7 +
 drivers/fpga/Makefile                         |   1 +
 drivers/fpga/ftdi-fifo-fpp.c                  | 594 ++++++++++++++++++
 4 files changed, 609 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-ftdi-fifo-fpp
 create mode 100644 drivers/fpga/ftdi-fifo-fpp.c
Documentation/ABI/testing/sysfs-driver-ftdi-fifo-fpp new file +7 -0
new file mode 100644
index 000000000000..084e691d0983
@@ -0,0 +1,7 @@
+What:		/sys/bus/platform/devices/ftdi-fifo-fpp-mgr.N/cfg_mode
+Date:		Nov 2018
+Kernel Version:	4.21
+Contact:	Anatolij Gustschin <[email protected]>
+Description:
+		Contains either "fifo" or "bitbang" and controls if fifo
+		of bitbang configuration mode is used in the driver.
drivers/fpga/Kconfig +7 -0
index 205042b441ea..584866a27c35 100644
@@ -59,6 +59,13 @@ config FPGA_MGR_ALTERA_CVP
 	  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_FTDI_FIFO_FPP
+	tristate "Altera FPP over FT232H FIFO"
+	depends on USB_FT232H_INTF
+	help
+	  FPGA manager driver support for Altera fast passive parallel
+	  interface (FPP) over FT232H FT245 FIFO.
+
 config FPGA_MGR_ZYNQ_FPGA
 	tristate "Xilinx Zynq FPGA"
 	depends on ARCH_ZYNQ || COMPILE_TEST
drivers/fpga/Makefile +1 -0
index 7a2d73ba7122..8c1d714bd440 100644
@@ -9,6 +9,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_FTDI_FIFO_FPP)	+= ftdi-fifo-fpp.o
 obj-$(CONFIG_FPGA_MGR_ICE40_SPI)	+= ice40-spi.o
 obj-$(CONFIG_FPGA_MGR_MACHXO2_SPI)	+= machxo2-spi.o
 obj-$(CONFIG_FPGA_MGR_SOCFPGA)		+= socfpga.o
drivers/fpga/ftdi-fifo-fpp.c new file +594 -0

594 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH v3 3/3] fpga: Add fpga manager driver for ARRI Altera FPP

Hi Alan,

Quoted 2 lines · On Tue, 27 Nov 2018 18:54:38 +0100 Anatolij Gustschin [email protected] wrote:

Add FPGA manager driver for loading ARRI Altera FPGAs via fast passive parallel (FPP) interface using FTDI FT232H chip.

Ping. Is this patch okay? I suppose that it will go via usb tree as part of the whole series (you send fpga driver patches to Greg anyway). Can you ack this patch or is there something that should be changed? I'd like to see it merged in v4.21, so if there are issues with this patch, I'll try to address it before it is to late.

Thanks,
Anatolij