Trenz Electronic GmbH Support Forum

Trenz Electronic Products => Trenz Electronic FPGA Modules => Topic started by: stefano on April 26, 2016, 10:01:30 AM

Title: TE0720 axi quad spi dts
Post by: stefano on April 26, 2016, 10:01:30 AM
Hi,
We have building petalinux on our TE0720 board and want to run spi example program but it freeze during sending first message.

Our dts file:

&axi_quad_spi_0 {
clock-names = "ref_clk","pclk";
clocks = <&clkc 26>,<&clkc 35>;
compatible = "xlnx,xps-spi-2.00.a";
interrupts = <0 33 1>;
interrupt-parent = <&intc>;
num-cs = <0x3>;
status = "okay";
reg = <0x41e00000 0x10000>;

spidev0:spidev@0{
compatible = "spidev";
reg = <0>;
        spi-max-frequency= <3125000>;
};
spidev1:spidev@1{
compatible = "spidev";
reg = <1>;
        spi-max-frequency= <3125000>;
};
spidev2:spidev@2{
compatible = "spidev";
reg = <2>;
        spi-max-frequency= <3125000>;
};
};


static void transfer(int fd)
{
int ret;
uint8_t tx[] ={0x80};

uint8_t rx[1];
struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long)tx,
.rx_buf = (unsigned long)rx,
.len = ARRAY_SIZE(tx),
.delay_usecs = delay,
.speed_hz = 0,
.bits_per_word = 0,
};

ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);   // -->the program freeze here
if (ret == 1)
pabort("can't send spi message");

}


Where the problem can be? Vivado schem is OK. We think that can be a device tree problem but no idea
Title: Re: TE0720 axi quad spi dts
Post by: Antti Lukats on April 26, 2016, 12:17:58 PM
it is always better to check out that the peripheral actually works using the debugger or standalone test application. If that is proven working then proceed to linux testing.
Title: Re: TE0720 axi quad spi dts
Post by: stefano on April 26, 2016, 12:20:46 PM
Standalone application works fine. We have a problem with linux app which freeze on the ioctl function
Title: Re: TE0720 axi quad spi dts
Post by: Antti Lukats on April 26, 2016, 02:42:36 PM
then try with the linux user space spi tool first before writing own code
or use devmem to check that the axi address is at least responding

Title: Re: TE0720 axi quad spi dts
Post by: stefano on April 26, 2016, 03:18:28 PM
Devices are found correctly:


root@zynq:~# ls -al /dev/spi*
crw-rw----    1 root     root      153,   0 Jan  1 00:00 /dev/spidev0.0
crw-rw----    1 root     root      153,   1 Jan  1 00:00 /dev/spidev0.1
crw-rw----    1 root     root      153,   2 Jan  1 00:00 /dev/spidev0.2


But when we try to send sth linux freeze.
echo abc > /dev/spidev0.0


We have to restart linux because the ctrl-c doesn't help.
The same problem is using ioctl function in c code

The irq in device tree is correct? Why spi can't end the transmission
Title: Re: TE0720 axi quad spi dts
Post by: Antti Lukats on April 26, 2016, 04:16:51 PM
did you test that the device axi address is correct?

if you read with devmem?

Title: Re: TE0720 axi quad spi dts
Post by: Antti Lukats on April 26, 2016, 05:05:45 PM
erm..

why are you using AXI_SPI ? and not the Zynq PS SPI? In the later case you need no IP Cores at all.. just route via emio and done
Title: Re: TE0720 axi quad spi dts
Post by: stefano on April 28, 2016, 11:58:23 AM
Ok, but we need to have spi with 3 slaves. In PS SPI we couldn't find how to config number of slaves
Title: Re: TE0720 axi quad spi dts
Post by: JH on April 28, 2016, 03:48:00 PM
Hi,

go on "MIO Configuration" and select the SPI-Core (SPI 0 or SPI 1). You can use up to 3 SS IOs.

br
John
Title: Re: TE0720 axi quad spi dts
Post by: Antti Lukats on April 28, 2016, 04:06:56 PM
in decoded mode up to 8 Chip selects are available with PS SPI