misc: Add Lattice XP2 FPGA internal flash programming via SPI
PATCH 1/1 misc: Add Lattice XP2 FPGA internal flash programming via SPI
This option enables support for programming of the FPGA's internal flash of the Lattice XP2 FPGA family via SPI. The newly programmed bitstream will also be loaded into the internal SRAM (refresh).
Note: The XP2 needs at least 3 clocks to be sent to the FPGA with inactive CS for some commands. Since the MPC5200 PSC SPI controller does not support de-activating the CS, we need to re-configure the PSC port from SPI to GPIO and generate the clocks with inactive CS this way. After generating these clocks, the PSC is configured to SPI controller again. So this current implementation is very SPI controller specific and this driver will only work on the MPC5200 PSC SPI controller.
Here an example on my custom MPC5200 based board:
$ echo 1 > /sys/class/firmware/lattice-xp2.bit/loading $ cat a3m071-fpga.jed > /sys/class/firmware/lattice-xp2.bit/data $ echo 0 > /sys/class/firmware/lattice-xp2.bit/loading
leads to these messages:
lattice-xp2 spi1.0: Security fuse will be set!
lattice-xp2 spi1.0: FPGA Lattice XP2-17 detected
lattice-xp2 spi1.0: FPGA data verified!
lattice-xp2 spi1.0: FPGA security fuse programmed
lattice-xp2 spi1.0: FPGA DONE fuse programmed
lattice-xp2 spi1.0: FPGA successfully refreshed!
---
I know that the re-configuration of the pins (SPI vs GPIO) as described above could/should be done in a "clean way" via pinctrl. But currently there is no pinctrl support for MPC52xx and the scope of this project doesn't really allow me to implement this infrastructure. Perhaps somebody else will find the time to do this later. But I'm pretty sure that this driver is "as-is" helpful for other users/developers.
Stefan
drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/lattice-xp2-config.c | 827 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 840 insertions(+) create mode 100644 drivers/misc/lattice-xp2-config.c
drivers/misc/Kconfig +12 -0
@@ -518,6 +518,18 @@ config LATTICE_ECP3_CONFIG If unsure, say N. +config LATTICE_XP2_CONFIG + tristate "Lattice XP2 FPGA internal flash programming via SPI" + depends on SPI && SYSFS && PPC_MPC52xx + select FW_LOADER + default n + help + This option enables support for programming of the FPGA's internal + flash of the Lattice XP2 FPGA family via SPI. The newly programmed + bitstream will also be loaded into the internal SRAM (refresh). + + If unsure, say N. + config SRAM bool "Generic on-chip SRAM driver" depends on HAS_IOMEM
drivers/misc/Makefile +1 -0
@@ -52,4 +52,5 @@ obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/ obj-$(CONFIG_INTEL_MEI) += mei/ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o +obj-$(CONFIG_LATTICE_XP2_CONFIG) += lattice-xp2-config.o obj-$(CONFIG_SRAM) += sram.o
drivers/misc/lattice-xp2-config.c new file +827 -0
827 lines not on this page · raw message
Signature · 1 line
1.8.2.3