News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

No Access to AXI4-lite quad spi device in petalinux

Started by Rolf Kary-Ehlers, April 29, 2015, 03:39:14 PM

Previous topic - Next topic

Rolf Kary-Ehlers

Hello,

after the import of a HDF-File from vivado Version 2014.4 I get the following entry in the device tree file pl.dtsi:

/ {
amba_pl: amba_pl {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges ;
axi_quad_spi_0: axi_quad_spi@41e00000 {
compatible = "xlnx,xps-spi-2.00.a";
num-cs = <0x2>;
reg = <0x41e00000 0x10000>;
};

/* ... other items ... */
};
};


Unfortunately I do not see a device in the peatlinux Image after system startup.
So I tried to implement a device named "spi_config" within the device tree source code:



axi_quad_spi_0: axi_quad_spi@41e00000 {
compatible = "xlnx,xps-spi-2.00.a";
num-cs = <0x2>;
reg = <0x41e00000 0x10000>;

spi_config@0 {
compatible = "xlnx,xps-spi-2.00.a";
spi-max-frequency = <12500000>;
                reg = <0>;
};
};


I can see this device in the device tree in Linux under "/sys/devices/soc0/amba_pl/41e00000.axi_quadspi" as "spi_config0" node.
I would like to get access to the spi device in "/dev/", but it is not there.

In the kernel configuration of petalinux I changed the following items:

# Other I2C/SMBus bus drivers
#
# CONFIG_I2C_STUB is not set
# CONFIG_I2C_DEBUG_CORE is not set
# CONFIG_I2C_DEBUG_ALGO is not set
# CONFIG_I2C_DEBUG_BUS is not set
CONFIG_SPI=y
# CONFIG_SPI_DEBUG is not set
CONFIG_SPI_MASTER=y

#
# SPI Master Controller Drivers
#
# CONFIG_SPI_ALTERA is not set
CONFIG_SPI_BITBANG=y
CONFIG_SPI_CADENCE=y
CONFIG_SPI_GPIO=y
# CONFIG_SPI_FSL_SPI is not set
# CONFIG_SPI_OC_TINY is not set
# CONFIG_SPI_PL022 is not set
# CONFIG_SPI_PXA2XX_PCI is not set
# CONFIG_SPI_ROCKCHIP is not set
# CONFIG_SPI_SC18IS602 is not set
# CONFIG_SPI_XCOMM is not set
CONFIG_SPI_XILINX=y
CONFIG_SPI_ZYNQ_QSPI=y
# CONFIG_SPI_ZYNQ_QSPI_DUAL_STACKED is not set
# CONFIG_SPI_DESIGNWARE is not set

#
# SPI Protocol Masters
#
CONFIG_SPI_SPIDEV=y
# CONFIG_SPI_TLE62X0 is not set
# CONFIG_SPMI is not set
# CONFIG_HSI is not set


Then I changed the string "compatible" to "xlnx,xps-spi-2.00.b" and other compatible ID´s I found within the path:
"/opt/petalinux/petalinux-v2014.4-final/components/Linux-kernel/xlnx-3.17/Drivers/spi", but it did not help.

How can I get Access to this device?
- Is the Driver missing?
- Is the compatible ID wrong.
- Do I need addditional information in the device tree?

I hope anyone can help me.

Kind regards
Rolf


Antti Lukats

#1
what you probably want is the user space spi driver for axi_spi?
this must be declared properly in device tree, or nothing much shows up

http://www.wiki.xilinx.com/Linux+SPI+Driver

some info there

Rolf Kary-Ehlers

Hi,

thanks for your reply.
I have already seen this link, you sent to me, but I do not need a flash or an eeprom device.

I need a driver for a simple spi device to control a MUX (realized by a shift register MC74HC589A), an ADC or a DAC device.
It shall just send commands or receive data from these devices.
The device we are using in vivado is "AXI Quad SPI v3.2" Vivado Design Suite PG153.

Where can I find documentation about the parameters to specify the device like in the described devices?
EEPROM Parameter:

            xlnx,family = "virtex4";
            xlnx,fifo-exist = <0x1>;
            xlnx,num-ss-bits = <0x1>;
            xlnx,num-transfer-bits = <0x8>;
            xlnx,sck-ratio = <0x20>;

Flash Parameter

            xlnx,fifo-depth = <0x100>;
            xlnx,instance = "axi_quad_spi_inst";
            xlnx,num-ss-bits = <0x1>;
            xlnx,num-transfer-bits = <0x8>;
            xlnx,s-axi4-addr-width = <0x18>;
            xlnx,s-axi4-data-width = <0x20>;
            xlnx,s-axi4-id-width = <0x4>;
            xlnx,sck-ratio = <0x2>;
            xlnx,sck-ratio1 = <0x1>;
            xlnx,spi-mem-addr-bits = <0x18>;
            xlnx,spi-memory = <0x2>;
            xlnx,spi-mode = <0x2>;
            xlnx,sub-family = "kintex7";
            xlnx,type-of-axi4-interface = <0x0>;
            xlnx,use-startup = <0x1>;
            xlnx,xip-mode = <0x0>;


I just need some more documentation for the parameters.

Best regards,
Rolf

Antti Lukats

#3
This question is 100% pure linux question, in no way related to Trenz electronics products, it is also not related to xilinx or vivado. Your question is "linux basics"

1) if you want to control shift regiser on SPI, you should use shift register based GPIO driver, then its all there for you, so that should be mostly menu config
petalinux-config -c kernel

UUPS, you want paralle in serial out shift register? in linux is only otherway around gpio driver available 74x164

so you need to use generic user space spidev

for adc dac on spi

2) in system-top.dts

add spi aliases, this handy, if you dont do it the devices get random numbers assigned

/ {
    aliases {
        spi0 = &spi0;
        spi1 = &spi1;
    };

later add entries for your adc dac

&spi0 {
    num-cs = <2>;
    /** DAC on SPI0 Chipselect 0 */   
    dac:spidev@0{
        compatible="spidev";
        reg = <0>;
        spi-max-frequency= <3125000>;
    };
    /** ADC on SPI0 Chipselect 1 */   
    adc:spidev@1{
        compatible="spidev";
        reg = <1>;
        spi-max-frequency= <3125000>;
    };
};

Hope this explains a bit how to get started. But again, this is generic LINUX knowledge, not related to FPGA modules, we can only provide limited support for generic questions.

The above is all you need todo basically, no need to modd other params





Rolf Kary-Ehlers

Hello Antti,

thank you for your help. I works now, the SPI device in the FPGA-Design was not connected to an interrupt controller.

The linux Xinlinx SPI driver needs the interrupt to get initialized. After successfull initialisation the spidev device driver was also initialized.

Now we see the devices in /dev an have Access to the device.

best regards
Rolf

Antti Lukats

You mean the SPI Master controller IP Interrupt was not connected?

Yes this may cause the driver to not load.

Rolf Kary-Ehlers

Yes,
now it looks like this:


axi_quad_spi_0: axi_quad_spi@41e00000 {
compatible = "xlnx,xps-spi-2.00.a";
interrupt-parent = <&intc>;
interrupts = <0 33 1>;
num-cs = <0x2>;
reg = <0x41e00000 0x10000>;
};



&axi_quad_spi_0 {
        xlnx,family = "zynq";
xlnx,sub-family = "zynq";
xlnx,instance = "axi_quad_spi_inst";
xlnx,type-of-axi4-interface = <0x0>;
xlnx,spi-mem-addr-bits = <0x18>;
xlnx,xip-mode = <0x0>;
xlnx,fifo-depth = <0x0>;
xlnx,fifo-exist = <0x0>;
xlnx,sck-ratio = <0x8>;
xlnx,sck-ratio1 = <0x1>;
xlnx,num-ss-bits = <0x2>;
xlnx,num-transfer-bits = <0x20>;
xlnx,spi-mode = <0x0>;
xlnx,use-startup = <0x0>;
xlnx,spi-memory = <0x1>;
xlnx,s-axi-addr-width = <0x7>;
xlnx,s-axi-data-width = <0x20>;
xlnx,s-axi4-addr-width = <0x18>;
xlnx,s-axi4-data-width = <0x20>;
xlnx,s-axi4-id-width = <0x1>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <1>;

config_1:spidev@0 {
compatible = "rohm,dh2228fv";
reg = <0>;
spi-max-frequency = <12500000>;
};
config_2:spidev@1 {
compatible = "rohm,dh2228fv";
reg = <1>;
spi-max-frequency = <12500000>;
};
};


Thanks :)