I have a board that has an NXP iMX8M-Plus processor and an Intel Arria 10 GX FPGA on it.
I want to configure the FPGA using the iMX8M-Plus processor through passive serial interface of the FPGA. I use custom yocto based image which has Linux Kernel v5.4 for the system and I have noticed that this kernel has special drivers for the operation that I needed and the driver is in ./drivers/fpga/altera-ps-spi.c file.
I added following line to Linux Kernel defconfig before compiling to include the driver:
CONFIG_FPGA_MGR_ALTERA_PS_SPI=y
And changed Device Tree file as explained here ./Documentation/devicetree/bindings/fpga/altera-passive-serial.txt in the Kernel source code by adding following lines:
/ {
...
...
altera_region {
compatible = "fpga-region";
fpga-mgr = <&altera_spi>;
firmware-name = "test.rbf";
#address-cells = <0x1>;
#size-cells = <0x1>;
};
};
/* Verdin SPI_1 */
&ecspi1 {
status = "okay";
altera_spi: altera-spi@0 {
compatible = "altr,fpga-arria10-passive-serial";
spi-max-frequency = <80000000>;
reg = <0>;
nconfig-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
nstat-gpios = <&gpio4 31 GPIO_ACTIVE_LOW>;
confd-gpios = <&gpio4 20 GPIO_ACTIVE_LOW>;
};
};
So far it is ok, the linux boots properly and I have following folder under /sys/class/fpga_manager folder.
root@localhost:/sys/class/fpga_manager/fpga0# ll
total 0
-r--r--r-- 1 root root 4096 Sep 23 12:38 consumers
lrwxrwxrwx 1 root root 0 Sep 23 12:38 device -> ../../../spi1.0
-r--r--r-- 1 root root 4096 Sep 23 12:38 name
lrwxrwxrwx 1 root root 0 Sep 23 12:38 of_node -> ../../../../../../../../../../firmware/devicetree/base/soc@0/bus@30800000/spi@30820000/altera_spi@0
drwxr-xr-x 2 root root 0 Sep 20 10:45 power
-r--r--r-- 1 root root 4096 Sep 23 12:38 state
-r--r--r-- 1 root root 4096 Sep 23 12:38 status
lrwxrwxrwx 1 root root 0 Sep 20 10:44 subsystem -> ../../../../../../../../../../class/fpga_manager
-r--r--r-- 1 root root 4096 Sep 23 12:38 suppliers
-rw-r--r-- 1 root root 4096 Sep 20 10:44 uevent
My problem starts here. Basically I couldn't find any documentation or an example about how to use this driver. I have an rbf file generated by Quartus and simply I should be able to send this file to the FPGA over this driver. Do you have any idea about what should be the next step that I need to follow?
Thank you.
compatible = "fpga-region";node in the device tree (see the bindings). That could be fully populated in the original device tree, or left mostly empty to be filled in by a device tree overlay. But the mostly empty version should at least have afpga-mgrproperty set to the phandle of your FPGA manager node:fpga-mgr = <&altera_spi>;and have#address-cells,#size-cellsand mayberangesproperties.of_fpga_mgr_get()orfpga_mgr_get()to get a reference to the FPGA manager,of_fpga_bridge_get_to_list()orfpga_bridge_get_to_list()to get references to the bridges,fpga_mgr_lock()to lock the manager,fpga_bridges_disable()to disable the bridges,fpga_mgr_firmware_load()orfpga_mgr_load()to load the firmware, [continued in next comment]fpga_bridges_enable()to re-enable the bridges,fpga_mgr_unlock()to unlock the FPGA manager,fpga_bridges_put()to put references to the bridges,fpga_mgr_put()to put reference to FPGA manager.