spidev test on ls1012a

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

spidev test on ls1012a

Jump to solution
3,603 Views
kai_wu
Contributor III

Hi,

I configured SDHC2 port as a spi port in RCW for ls1012a.

Now I am going to test the spi functionality, the plan is to use spidev.  

  1. enable spidev in menuconfig
  2. bind the driver with spi
  3. compile the linux kernel
  4. run user space program spidev_test to do the test

I enabled the SPI_SPIDEV in linux menuconfig (linux 5.1 from mainstream)

pastedImage_1.png

The next step is to bind the driver to the spi bus. But I do not know to to do this. The next screenshot show how to add a structure called spi_board_info and give the spidev to the .modalias.

pastedImage_5.png

I didn't find any file named mach-xxxx for ls1012a( I am using my hardware with ls1012a, that's why I need to test the spi), so i am stuck here, step 2. 

Should I bind them with device tree? Anyone who knows how to do it?

Thank you

1 Solution
3,031 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello Kai Wu,

Please refer to the following dts definition.

&dspi {

        bus-num = <0>;

        status = "okay";

 

        spidev@0 {

                #address-cells = <1>;

                #size-cells = <1>;

                compatible = "spidev";

                reg = <0>;

                spi-max-frequency = <10000000>;

        };

 

        spidev@1 {

                #address-cells = <1>;

                #size-cells = <1>;

                compatible = "spidev";

                reg = <1>;

                spi-max-frequency = <10000000>;

        };

}

Thanks,

Yiping

View solution in original post

6 Replies
3,032 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello Kai Wu,

Please refer to the following dts definition.

&dspi {

        bus-num = <0>;

        status = "okay";

 

        spidev@0 {

                #address-cells = <1>;

                #size-cells = <1>;

                compatible = "spidev";

                reg = <0>;

                spi-max-frequency = <10000000>;

        };

 

        spidev@1 {

                #address-cells = <1>;

                #size-cells = <1>;

                compatible = "spidev";

                reg = <1>;

                spi-max-frequency = <10000000>;

        };

}

Thanks,

Yiping

3,031 Views
changsu_ryu
Contributor I

Hi Yiping,

I have similar problem. I use dts as followed.

dspi@2100000 {
compatible = "fsl,ls1012a-dspi", "fsl,ls1021a-v1.0-dspi";
// compatible = "fsl,vf610-dspi";
#address-cells = <0x1>;
#size-cells = <0x0>;
reg = <0x0 0x2100000 0x0 0x10000>;
interrupts = <0x0 0x40 0x4>;
clock-names = "dspi";
clocks = <0x2 0x4 0x0>;
spi-num-chipselects = <0x3>;
big-endian;
bus-num = <0x01>;
status = "okay";

spidev@0 {
#address-cells = <0x01>;
#size-cells = <0x01>;
compatible = "spidev";
reg = <0x00>;
spi-max-frequency = <10000000>;
};

spidev@1 {
#address-cells = <0x01>;
#size-cells = <0x01>;
compatible = "spidev";
reg = <0x01>;
spi-max-frequency = <10000000>;
};

spidev@2 {
#address-cells = <0x01>;
#size-cells = <0x01>;
compatible = "spidev";
reg = <0x02>;
spi-max-frequency = <10000000>;
};

};

when I use compatible as "fsl,ls1012a-dspi", "fsl,ls1021a-v1.0-dspi" , I end up with kernel msg like this.

spidev spi1.2: setup mode 0, 8 bits/w, 10000000 Hz max --> 0
spidev spi1.2: spi mode 0
spidev spi1.2: setup mode 0, 8 bits/w, 10000000 Hz max --> 0
spidev spi1.2: 8 bits per word
spidev spi1.2: setup mode 0, 8 bits/w, 1000000 Hz max --> 0

fsl-dspi 2100000.dspi: wait transfer complete fail!

when I use compatible as compatible = "fsl,vf610-dspi", devices are note created as spidev1.x under /dev/.

fsl-dspi 2100000.spi: rx dma channel not available
fsl-dspi 2100000.spi: can't get dma channels

Can I get any help about this?

0 Kudos
3,031 Views
changsu_ryu
Contributor I

NVM about my question.

I've figured out and it was my mistake

0 Kudos
3,031 Views
ufedor
NXP Employee
NXP Employee

Please explain in more detail what was the mistake.

0 Kudos
3,031 Views
changsu_ryu
Contributor I

The problem was that I have used bootloader dspi code in kernel in order to read CPLD(external module).

so I believe there is a malfunction if I use tcfq_mode in user-mode and bootloader dspi code in kernel.

Maybe in HALT fields of register MCR(210_0000h)  could be a problem.

Anyway I got another problem that when I use spidev(tcfq_mode) there is a gap between clock even they are in one chipselect. It happens every single 8 clock after. So I want to use dma mode.

I still get kernel msg as followed:

fsl-dspi 2100000.spi: rx dma channel not available
fsl-dspi 2100000.spi: can't get dma channels

could you give me any advice to solve this problem?

0 Kudos
3,031 Views
kai_wu
Contributor III

Hi YIping,

Thanks for the device tree you provided. It works for me.

Also, I enable the fsl-dspi module in linux menucofig. 

pastedImage_1.png

Test results (send:121212121, receive 121212121):

image

0 Kudos