imx6ul evk board spi not work

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx6ul evk board spi not work

1,098 Views
tony-tony
Contributor III

Hi.

 I use imx6ul evk demo board to test spi interface, (ECSPI4)

the dts is :

.....

ecspi4 {
pinctrl_ecspi4: ecspi4grp {
fsl,pins = <
MX6UL_PAD_ENET2_TX_CLK__ECSPI4_MISO 0x000010B0
MX6UL_PAD_ENET2_TX_DATA1__ECSPI4_SCLK 0x000010B0
MX6UL_PAD_ENET2_TX_EN__ECSPI4_MOSI 0x000010B0
>;
};
pinctrl_ecspi4_cs: ecspi4_csgrp {
fsl,pins = <
MX6UL_PAD_UART5_TX_DATA__GPIO1_IO30 0x000010B0
>;
};
};

.....

&ecspi4 {
fsl,spi-num-chipselects = <1>;
pinctrl-names = "default";
cs-gpios = <&gpio1 30 0>;
pinctrl-0 = <&pinctrl_ecspi4 &pinctrl_ecspi4_cs>;
status = "okay";

spi0: spidev@0 {
compatible = "spidev";
spi-max-frequency = <2000000>;
reg = <0>;
};
};

Then use imx-test test demo to test the spi.

it shows:

root@imx6ulevk:/usr/test# ./spi_test -D 2 -s 1000000 -b 8 E6E0
Execute data transfer test: 2 4 E[ 56.155739] tony--tony---spi_imx_setup
6E0
[ 56.161517] tony--tony---spi_imx_setup
[ 56.165357] tony--tony---spi_imx_setup
spi mode: 0
bits per word: 8
max speed: 10[ 56.175155] tony--tony--spi_imx_pio_transfer transfer->tx_buf[] = E6E0
00000 Hz (1000 KHz)
Corrupted data at 0 wbuf = 69 rbuf = 0
Corrupted data at 1 wbuf = 54 rbuf = 0
Corrupted data at 2 wbuf = 69 rbuf = 0
Corrupted data at 3 wbuf = 48 rbuf = 0
Data sent : E6E0
Data received :
Test FAILED.

I am not sure how can I let spi work normal.

TKS,

Labels (1)
0 Kudos
3 Replies

735 Views
igorpadykov
NXP Employee
NXP Employee

Hi tony

according to mxc_spi_test description parameter "D":

<spi_no> - CSPI Module number in [0, 1, 2]

so for ECSPI4 : "./spi_test -D 2.."  seems as wrong

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

735 Views
tony-tony
Contributor III

Hi igorpadykov:

I find the root cause, the error is stay in dts file, I should delete (the red font):

ecspi4 {
pinctrl_ecspi4: ecspi4grp {
fsl,pins = <
MX6UL_PAD_ENET2_TX_CLK__ECSPI4_MISO 0x000010B0
MX6UL_PAD_ENET2_TX_DATA1__ECSPI4_SCLK 0x000010B0
MX6UL_PAD_ENET2_TX_EN__ECSPI4_MOSI 0x000010B0
>;
};
pinctrl_ecspi4_cs: ecspi4_csgrp {
fsl,pins = <
MX6UL_PAD_UART5_TX_DATA__GPIO1_IO30 0x000010B0
>;
};
};

Then it is ok now.

Then I find another question,  cs-gpios = <&gpio1 30 0>; this pin can't be requested, because it will ignore while check if gpio is valid.  So we can't use general gpio as SPI CS pin ?

0 Kudos

735 Views
tony-tony
Contributor III

I also try to write another driver code to test spi,  it can call the function which register in spi-imx.c, but use Oscilloscope to check the pin, it shows nothing.

-----------------------------------

unsigned char buffer[]="TONY-TONY";

static int spi_probe(struct spi_device *spi)
{
int status = 0;
printk("tony ==== spi probe!!\n");

spi->bits_per_word = 8;
spi->mode = SPI_MODE_1;
spi->chip_select = 0;
status = spi_setup(spi);

printk("spi->max_speed_hz=%d\n",spi->max_speed_hz);

if (status < 0)
{
printk(KERN_ERR "SPI setup failed, err %d\n", status);
spi_dev = NULL;
goto err;
}
spi_dev = spi;

printk("start send data\n");
while(1){
spi_write_reg(buffer,9);
msleep(500);
}
return status;

err:
printk(KERN_INFO "tmspi prob failed !\n");
return status;
}

==========================================================

0 Kudos