fpga: Lattice MachXO2 Slave SPI FPGA Manager support
Subsystems (2)
v10 cover fpga: Lattice MachXO2 Slave SPI FPGA Manager support
Hi all,
this series adds support for the Lattice MachXO2 FPGA chip, programmed over slave SPI.
Tested on a raspberry pi3, beaglebone black (little endian mode) and imx6 hummingboard (big endian mode) + bugblat's pif2 fpga hat (machxo2 7000HC) or tinyfpga A1/A2 (machxo2 256HC / 1200HC), in SPI slave mode with varying bus speed.
Changes since v9:
* implemented machxo2_spi_state()
Paolo Pisati (2):
dt: bindings: fpga: add lattice machxo2 slave spi binding description
fpga: lattice machxo2: Add Lattice MachXO2 support
.../bindings/fpga/lattice-machxo2-spi.txt | 29 ++ drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 1 + drivers/fpga/machxo2-spi.c | 413 +++++++++++++++++++++ 4 files changed, 450 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/lattice-machxo2-spi.txt create mode 100644 drivers/fpga/machxo2-spi.c
Signature · 1 line
2.7.4
PATCH v10 1/2 dt: bindings: fpga: add lattice machxo2 slave spi binding description
Add dt binding documentation details for Lattice MachXO2 FPGA configuration over Slave SPI interface.
--- .../bindings/fpga/lattice-machxo2-spi.txt | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/fpga/lattice-machxo2-spi.txt
Documentation/devicetree/bindings/fpga/lattice-machxo2-spi.txt new file +29 -0
@@ -0,0 +1,29 @@ +Lattice MachXO2 Slave SPI FPGA Manager + +Lattice MachXO2 FPGAs support a method of loading the bitstream over +'slave SPI' interface. + +See 'MachXO2ProgrammingandConfigurationUsageGuide.pdf' on www.latticesemi.com + +Required properties: +- compatible: should contain "lattice,machxo2-slave-spi" +- reg: spi chip select of the FPGA + +Example for full FPGA configuration: + + fpga-region0 { + compatible = "fpga-region"; + fpga-mgr = <&fpga_mgr_spi>; + #address-cells = <0x1>; + #size-cells = <0x1>; + }; + + spi1: spi@2000 { + ... + + fpga_mgr_spi: fpga-mgr@0 { + compatible = "lattice,machxo2-slave-spi"; + spi-max-frequency = <8000000>; + reg = <0>; + }; + };
Signature · 1 line
2.7.4
PATCH v10 2/2 fpga: lattice machxo2: Add Lattice MachXO2 support
In reply to Paolo PisatiThis patch adds support to the FPGA manager for programming MachXO2 device’s internal flash memory, via slave SPI.
--- drivers/fpga/Kconfig | 7 + drivers/fpga/Makefile | 1 + drivers/fpga/machxo2-spi.c | 413 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 421 insertions(+) create mode 100644 drivers/fpga/machxo2-spi.c
drivers/fpga/Kconfig +7 -0
@@ -70,6 +70,13 @@ config FPGA_MGR_ICE40_SPI help FPGA manager driver support for Lattice iCE40 FPGAs over SPI. +config FPGA_MGR_MACHXO2_SPI + tristate "Lattice MachXO2 SPI" + depends on SPI + help + FPGA manager driver support for Lattice MachXO2 configuration + over slave SPI interface. + config FPGA_MGR_TS73XX tristate "Technologic Systems TS-73xx SBC FPGA Manager" depends on ARCH_EP93XX && MACH_TS72XX
drivers/fpga/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_FPGA) += fpga-mgr.o 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_MACHXO2_SPI) += machxo2-spi.o obj-$(CONFIG_FPGA_MGR_SOCFPGA) += socfpga.o obj-$(CONFIG_FPGA_MGR_SOCFPGA_A10) += socfpga-a10.o obj-$(CONFIG_FPGA_MGR_TS73XX) += ts73xx-fpga.o
drivers/fpga/machxo2-spi.c new file +413 -0
413 lines not on this page · raw message
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH v10 2/2] fpga: lattice machxo2: Add Lattice MachXO2 support
Thank you for the patch! Perhaps something to improve:
Hi Paolo,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__sparse warnings: (new ones prefixed by >>)
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
>> drivers/fpga/machxo2-spi.c:86:19: sparse: cast to restricted __be32
drivers/fpga/machxo2-spi.c:369:12: sparse: no member 'parent' in struct fpga_manager
>> drivers/fpga/machxo2-spi.c:375:33: sparse: not enough arguments for function fpga_mgr_register
>> drivers/fpga/machxo2-spi.c:382:29: sparse: incorrect type in argument 1 (different base types) @@ expected struct device *dev @@ got structstruct device *dev @@
>> drivers/fpga/machxo2-spi.c:369:12: sparse: generating address of non-lvalue (8)
drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_probe':
drivers/fpga/machxo2-spi.c:369:5: error: 'struct fpga_manager' has no member named 'parent'
mgr->parent = dev;
^~
drivers/fpga/machxo2-spi.c:375:27: error: passing argument 1 of 'fpga_mgr_register' from incompatible pointer type [-Werror=incompatible-pointer-types]
return fpga_mgr_register(mgr);
^~~
In file included from drivers/fpga/machxo2-spi.c:12:0:
include/linux/fpga/fpga-mgr.h:173:5: note: expected 'struct device *' but argument is of type 'struct fpga_manager *'
int fpga_mgr_register(struct device *dev, const char *name,
^~~~~~~~~~~~~~~~~
drivers/fpga/machxo2-spi.c:375:9: error: too few arguments to function 'fpga_mgr_register'
return fpga_mgr_register(mgr);
^~~~~~~~~~~~~~~~~
In file included from drivers/fpga/machxo2-spi.c:12:0:
include/linux/fpga/fpga-mgr.h:173:5: note: declared here
int fpga_mgr_register(struct device *dev, const char *name,
^~~~~~~~~~~~~~~~~
drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_remove':
drivers/fpga/machxo2-spi.c:382:22: error: passing argument 1 of 'fpga_mgr_unregister' from incompatible pointer type [-Werror=incompatible-pointer-types]
fpga_mgr_unregister(mgr);
^~~
In file included from drivers/fpga/machxo2-spi.c:12:0:
include/linux/fpga/fpga-mgr.h:176:6: note: expected 'struct device *' but argument is of type 'struct fpga_manager *'
void fpga_mgr_unregister(struct device *dev);
^~~~~~~~~~~~~~~~~~~
drivers/fpga/machxo2-spi.c: In function 'machxo2_spi_probe':
drivers/fpga/machxo2-spi.c:376:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^cc1: some warnings being treated as errors
vim +86 drivers/fpga/machxo2-spi.c
65
66 static int get_status(struct spi_device *spi, unsigned long *status)
67 {
68 struct spi_message msg;
69 struct spi_transfer rx, tx;
70 static const u8 cmd[] = LSC_READ_STATUS;
71 int ret;
72
73 memset(&rx, 0, sizeof(rx));
74 memset(&tx, 0, sizeof(tx));
75 tx.tx_buf = cmd;
76 tx.len = sizeof(cmd);
77 rx.rx_buf = status;
78 rx.len = 4;
79 spi_message_init(&msg);
80 spi_message_add_tail(&tx, &msg);
81 spi_message_add_tail(&rx, &msg);
82 ret = spi_sync(spi, &msg);
83 if (ret)
84 return ret;
85
> 86 *status = be32_to_cpu(*status);
87
88 return 0;
89 }
90 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v10 2/2] fpga: lattice machxo2: Add Lattice MachXO2 support
In reply to Paolo PisatiOn Tue, Apr 3, 2018 at 2:02 PM, Paolo Pisati <[email protected]> wrote:
Hi Paolo,
Looks good, except that I have to fix up the calls to fpga_mgr_register/unregister since my API changes didn't go in. I've fixed those up and pushed to a branch on my kernel org git repo to let the robots do some testing. I'll post (v11 with those fixes) after that is cleared.
We're too late for 4.17, expect it for 4.18.
Thanks,
Alan
Quoted 4 lines
This patch adds support to the FPGA manager for programming MachXO2 device’s internal flash memory, via slave SPI.
Signed-off-by Paolo Pisati <[email protected]>
Re: [PATCH v10 2/2] fpga: lattice machxo2: Add Lattice MachXO2 support
Quoted 9 lines · Alan Tull
On Tue, Apr 3, 2018 at 2:02 PM, Paolo Pisati <[email protected]> wrote:
Hi Paolo,
Looks good, except that I have to fix up the calls to fpga_mgr_register/unregister since my API changes didn't go in. I've fixed those up and pushed to a branch on my kernel org git repo to let the robots do some testing. I'll post (v11 with those fixes) after that is cleared.
Awesome Alan, thank you.
Signature · 2 lines
bye, p.