Add Efinix FPGA configuration support
Subsystems (2)
v6 cover Add Efinix FPGA configuration support
From: Ian Dannapel <[email protected]>
Hi all,
This is v6 of the series adding support for programming Efinix FPGAs over SPI using the fpga-mgr subsystem.
The series adds DT bindings for the Efinix SPI configuration interface and a new FPGA manager driver implementing passive SPI configuration.
Testing:
- Verified on a custom board with an Efinix Trion T13 FPGA
- Tested full bitstream configuration over SPI at 25 MHz
Changes since v5:
dt-bindings: vendor-prefix: Add prefix for Efinix, Inc.
- fixed trailer formatting
dt-bindings: fpga: Add Efinix SPI programming bindings
- renamed the binding from efinix,trion-spi.yaml to efinix,trion-config.yaml
- replaced the generic fallback approach with a family fallback scheme
- made efinix,trion-config the required fallback for Titanium and Topaz
- updated the example to use the new compatible naming
- added an example showing the fallback-compatible form
- removed driver-limitation wording from the binding description
fpga-mgr: Add Efinix SPI programming driver
- renamed compatibles from *-spi to *-config
- aligned the driver with the fallback-compatible scheme
- removed direct OF matching for Titanium and Topaz so binding happens via the Trion fallback compatible
- moved Kconfig and Makefile entries to the end of the FPGA manager sections
- fixed kernel-doc style multi-line comments
- documented why chip select must stay asserted across reset and bitstream transfer
- removed the redundant bus_locked state
- reordered probe initialization
Ian Dannapel (3):
dt-bindings: vendor-prefix: Add prefix for Efinix, Inc.
dt-bindings: fpga: Add Efinix SPI programming bindings
fpga-mgr: Add Efinix SPI programming driver
.../bindings/fpga/efinix,trion-config.yaml | 96 +++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 1 + drivers/fpga/efinix-spi.c | 263 ++++++++++++++++++ 5 files changed, 369 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/efinix,trion-config.yaml create mode 100644 drivers/fpga/efinix-spi.c
Signature · 1 line
2.43.0
PATCH v6 1/3 dt-bindings: vendor-prefix: Add prefix for Efinix, Inc.
From: Ian Dannapel <[email protected]>
Add entry for Efinix, Inc. (https://www.efinixinc.com/)
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -481,6 +481,8 @@ patternProperties: description: Emtop Embedded Solutions "^eeti,.*": description: eGalax_eMPIA Technology Inc + "^efinix,.*": + description: Efinix, Inc. "^egnite,.*": description: egnite GmbH "^einfochips,.*":
Signature · 1 line
2.43.0
PATCH v6 2/3 dt-bindings: fpga: Add Efinix SPI programming bindings
In reply to [email protected]From: Ian Dannapel <[email protected]>
Add device tree bindings documentation for configuring Efinix FPGA using serial SPI passive programming mode.
--- .../bindings/fpga/efinix,trion-config.yaml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/efinix,trion-config.yaml
Documentation/devicetree/bindings/fpga/efinix,trion-config.yaml new file +96 -0
@@ -0,0 +1,96 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/fpga/efinix,trion-config.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Efinix SPI FPGA Manager + +maintainers: + - Ian Dannapel <[email protected]> + +description: | + Efinix FPGAs (Trion, Topaz, and Titanium families) support loading bitstreams + through "SPI Passive Mode". + Additional pin hogs for bus width configuration should be set + elsewhere, if necessary. + + References: + - https://www.efinixinc.com/docs/an006-configuring-trion-fpgas-v6.3.pdf + - https://www.efinixinc.com/docs/an033-configuring-titanium-fpgas-v2.8.pdf + - https://www.efinixinc.com/docs/an061-configuring-topaz-fpgas-v1.1.pdf + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + oneOf: + - items: + - enum: + - efinix,titanium-config + - efinix,topaz-config + - const: efinix,trion-config + - const: efinix,trion-config + + spi-cpha: true + + spi-cpol: true + + spi-max-frequency: + maximum: 25000000 + + reg: + maxItems: 1 + + reset-gpios: + description: + reset and re-configuration trigger pin (low active) + maxItems: 1 + + cdone-gpios: + description: + optional configuration done status pin (high active) + maxItems: 1 + +required: + - compatible + - reg + - reset-gpios + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + spi { + #address-cells = <1>; + #size-cells = <0>; + cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>; + fpga-mgr@0 { + compatible = "efinix,trion-config"; + reg = <0>; + spi-max-frequency = <25000000>; + spi-cpha; + spi-cpol; + reset-gpios = <&gpio4 17 GPIO_ACTIVE_LOW>; + cdone-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>; + }; + }; + - | + #include <dt-bindings/gpio/gpio.h> + spi { + #address-cells = <1>; + #size-cells = <0>; + cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>; + fpga-mgr@0 { + compatible = "efinix,titanium-config", "efinix,trion-config"; + reg = <0>; + spi-max-frequency = <25000000>; + spi-cpha; + spi-cpol; + reset-gpios = <&gpio4 17 GPIO_ACTIVE_LOW>; + cdone-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>; + }; + }; +...
Signature · 1 line
2.43.0
Re: [PATCH v6 2/3] dt-bindings: fpga: Add Efinix SPI programming bindings
Quoted 11 lines · On Fri, 27 Mar 2026 12:48:40 +0100, [email protected] wrote:
From: Ian Dannapel <[email protected]>
Add device tree bindings documentation for configuring Efinix FPGA using serial SPI passive programming mode.
Signed-off-by Ian Dannapel <[email protected]>--- .../bindings/fpga/efinix,trion-config.yaml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/efinix,trion-config.yaml
PATCH v6 3/3 fpga-mgr: Add Efinix SPI programming driver
In reply to [email protected]From: Ian Dannapel <[email protected]>
Add a new driver for loading binary firmware to configuration RAM using "SPI passive mode" on Efinix FPGAs.
Efinix passive SPI configuration requires chip select to remain asserted from reset until the complete bitstream and trailing idle clocks have been transferred, so the driver keeps CS active with cs_change and locks the SPI bus for the duration of configuration.
--- drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 1 + drivers/fpga/efinix-spi.c | 263 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 271 insertions(+) create mode 100644 drivers/fpga/efinix-spi.c
drivers/fpga/Kconfig +7 -0
@@ -288,6 +288,13 @@ config FPGA_MGR_LATTICE_SYSCONFIG_SPI FPGA manager driver support for Lattice FPGAs programming over slave SPI sysCONFIG interface. +config FPGA_MGR_EFINIX_SPI + tristate "Efinix FPGA configuration over SPI" + depends on SPI + help + FPGA manager driver support for Efinix FPGAs configuration over SPI + (passive mode only). + source "drivers/fpga/tests/Kconfig" endif # FPGA
drivers/fpga/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_FPGA_MGR_VERSAL_FPGA) += versal-fpga.o obj-$(CONFIG_FPGA_MGR_MICROCHIP_SPI) += microchip-spi.o obj-$(CONFIG_FPGA_MGR_LATTICE_SYSCONFIG) += lattice-sysconfig.o obj-$(CONFIG_FPGA_MGR_LATTICE_SYSCONFIG_SPI) += lattice-sysconfig-spi.o +obj-$(CONFIG_FPGA_MGR_EFINIX_SPI) += efinix-spi.o obj-$(CONFIG_ALTERA_PR_IP_CORE) += altera-pr-ip-core.o obj-$(CONFIG_ALTERA_PR_IP_CORE_PLAT) += altera-pr-ip-core-plat.o
drivers/fpga/efinix-spi.c new file +263 -0
263 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v6 3/3] fpga-mgr: Add Efinix SPI programming driver
drivers/fpga/Makefile obj-$(CONFIG_FPGA_MGR_VERSAL_FPGA) += versal-fpga.o · line 29
Quoted 11 lines
drivers/fpga/Makefile +1
-0@@ -24,6 +24,7 @@ obj-$(CONFIG_FPGA_MGR_VERSAL_FPGA) += versal-fpga.o obj-$(CONFIG_FPGA_MGR_MICROCHIP_SPI) += microchip-spi.o obj-$(CONFIG_FPGA_MGR_LATTICE_SYSCONFIG) += lattice-sysconfig.o obj-$(CONFIG_FPGA_MGR_LATTICE_SYSCONFIG_SPI) += lattice-sysconfig-spi.o +obj-$(CONFIG_FPGA_MGR_EFINIX_SPI) += efinix-spi.o obj-$(CONFIG_ALTERA_PR_IP_CORE) += altera-pr-ip-core.o obj-$(CONFIG_ALTERA_PR_IP_CORE_PLAT) += altera-pr-ip-core-plat.o
This is the tail of "FPGA Manager Drivers", move it here.
...
drivers/fpga/Makefile obj-$(CONFIG_FPGA_MGR_VERSAL_FPGA) += versal-fpga.o
Quoted 5 lines
drivers/fpga/Makefile +5
-0+static int efinix_spi_write_init(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t count) +{ + struct device *dev = &mgr->dev;
Why do you make this change? This is just one-time usage, and in some other functions you don't make the same change. Please delete it.
Quoted 26 lines
drivers/fpga/Makefile +26
-0+ struct efinix_spi_conf *conf = mgr->priv; + struct spi_transfer assert_cs = { + .cs_change = 1, + }; + struct spi_message message; + int ret; + + if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { + dev_err(dev, "Partial reconfiguration not supported\n"); + return -EOPNOTSUPP; + } + + /* + * Efinix passive SPI configuration requires chip select to stay + * asserted from reset until the bitstream is fully clocked in. + * Lock the SPI bus so no other device can toggle CS between the + * reset pulse and the write/complete transfers. + */ + spi_bus_lock(conf->spi->controller); + spi_message_init_with_transfers(&message, &assert_cs, 1); + ret = spi_sync_locked(conf->spi, &message); + if (ret) { + spi_bus_unlock(conf->spi->controller); + return ret; + } +
drivers/fpga/Makefile
Quoted 10 lines
drivers/fpga/Makefile +10
-0+ /* Reset with CS asserted */ + efinix_spi_reset(conf); + + return 0; +} + +static int efinix_spi_write(struct fpga_manager *mgr, const char *buf, + size_t count) +{ + struct device *dev = &mgr->dev;
ditto.
drivers/fpga/Makefile
Quoted 4 lines
drivers/fpga/Makefile +4
-0+ struct spi_transfer write_xfer = { + .tx_buf = buf, + .len = count, + .cs_change = 1, /* Keep CS asserted */
Move this comment to its first appearance.
...
drivers/fpga/Makefile
Quoted 10 lines
drivers/fpga/Makefile +10
-0+static const struct of_device_id efinix_spi_of_match[] = { + { .compatible = "efinix,trion-config", }, + {} +}; +MODULE_DEVICE_TABLE(of, efinix_spi_of_match); + +static const struct spi_device_id efinix_ids[] = { + { "trion-config", 0 }, + { "titanium-config", 0 }, + { "topaz-config", 0 },
Since you've trimmed of_match_table, any reason to keep 3 spi_device_ids? IIUC you could keep them in sync.
Re: [PATCH v6 3/3] fpga-mgr: Add Efinix SPI programming driver
Hi,
thanks for the quick review.
Quoted 14 lines · Xu Yilun
drivers/fpga/Makefile obj-$(CONFIG_FPGA_MGR_VERSAL_FPGA) += versal-fpga.o · line 29
Quoted 12 lines
drivers/fpga/Makefile +1
-0@@ -24,6 +24,7 @@ obj-$(CONFIG_FPGA_MGR_VERSAL_FPGA) += versal-fpga.o obj-$(CONFIG_FPGA_MGR_MICROCHIP_SPI) += microchip-spi.o obj-$(CONFIG_FPGA_MGR_LATTICE_SYSCONFIG) += lattice-sysconfig.o obj-$(CONFIG_FPGA_MGR_LATTICE_SYSCONFIG_SPI) += lattice-sysconfig-spi.o +obj-$(CONFIG_FPGA_MGR_EFINIX_SPI) += efinix-spi.o obj-$(CONFIG_ALTERA_PR_IP_CORE) += altera-pr-ip-core.o obj-$(CONFIG_ALTERA_PR_IP_CORE_PLAT) += altera-pr-ip-core-plat.oThis is the tail of "FPGA Manager Drivers", move it here.
All right
Quoted 11 lines
...
drivers/fpga/Makefile
Quoted 5 lines
drivers/fpga/Makefile +5
-0+static int efinix_spi_write_init(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t count) +{ + struct device *dev = &mgr->dev;Why do you make this change? This is just one-time usage, and in some other functions you don't make the same change. Please delete it.
Will revert it
Quoted 49 lines
Quoted 27 lines
drivers/fpga/Makefile +26
-0+ struct efinix_spi_conf *conf = mgr->priv; + struct spi_transfer assert_cs = { + .cs_change = 1, + }; + struct spi_message message; + int ret; + + if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { + dev_err(dev, "Partial reconfiguration not supported\n"); + return -EOPNOTSUPP; + } + + /* + * Efinix passive SPI configuration requires chip select to stay + * asserted from reset until the bitstream is fully clocked in. + * Lock the SPI bus so no other device can toggle CS between the + * reset pulse and the write/complete transfers. + */ + spi_bus_lock(conf->spi->controller); + spi_message_init_with_transfers(&message, &assert_cs, 1); + ret = spi_sync_locked(conf->spi, &message); + if (ret) { + spi_bus_unlock(conf->spi->controller); + return ret; + } +drivers/fpga/Makefile
Quoted 10 lines
drivers/fpga/Makefile +10
-0+ /* Reset with CS asserted */ + efinix_spi_reset(conf); + + return 0; +} + +static int efinix_spi_write(struct fpga_manager *mgr, const char *buf, + size_t count) +{ + struct device *dev = &mgr->dev;ditto.
drivers/fpga/Makefile
Quoted 4 lines
drivers/fpga/Makefile +4
-0+ struct spi_transfer write_xfer = { + .tx_buf = buf, + .len = count, + .cs_change = 1, /* Keep CS asserted */Move this comment to its first appearance.
...
Quoted 13 lines
drivers/fpga/Makefile
Quoted 10 lines
drivers/fpga/Makefile +10
-0+static const struct of_device_id efinix_spi_of_match[] = { + { .compatible = "efinix,trion-config", }, + {} +}; +MODULE_DEVICE_TABLE(of, efinix_spi_of_match); + +static const struct spi_device_id efinix_ids[] = { + { "trion-config", 0 }, + { "titanium-config", 0 }, + { "topaz-config", 0 },Since you've trimmed
of_match_table, any reason to keep 3spi_device_ids? IIUC you could keep them in sync.
I don't see any reason to have other IDs, will drop them.
I would also rename the file from efinix-spi.c to efinix-config.c to match the dt bindings
Quoted 6 lines · On Fri, Mar 27, 2026 at 12:48:38PM +0100, [email protected] wrote:
From: Ian Dannapel <[email protected]>
Hi all,
This is v6 of the series adding support for programming Efinix FPGAs over SPI using the fpga-mgr subsystem.
Sorry, I'm on vacation and cannot make it in v7.0-rc, though I assume it should be neat as a v6.
Will try to merge it in v7.1-rc, thanks.