This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM437x spidev issue - no MISO data

Other Parts Discussed in Thread: AM4372

Hi TI,

I have a problem with SPIdev and Mcspi driver for AM437x and TI Linux kernel 3.12.10. I have done this steps for enabling the spidev device:

  • Enable the McSPI driver for OMAP in kernel
  • Enable the User mode SPI device driver support in kernel
  • Added  configuration into the device tree
	spi0_pins: spi0_pins {
		pinctrl-single,pins = <
			0x150 (PIN_OUTPUT | MUX_MODE0) /* spi0_clk.spi0_clk */
			0x154 (PIN_OUTPUT | MUX_MODE0) /* spi0_d0.spi0_d0 */
			0x158 (PIN_INPUT | MUX_MODE0) /* spi0_d1.spi0_d1 */
			0x15C (PIN_OUTPUT | MUX_MODE0) /* spi0_cs0.spi0_cs0 */
		>;
	};

&spi0 {
	#address-cells = <1>;
    #size-cells = <0>;
    status = "okay";
	pinctrl-names = "default"; 
	pinctrl-0 = <&spi0_pins>;
	spidev@0 {
		#address-cells = <1>;
        #size-cells = <0>;
		compatible = "spidev"; 
		reg = <0>;
		spi-max-frequency = <16000000>;
		spi-cpha; 
	};
};

The kernel registers new spidev device as /dev/spidev1.0. The dmesg message is:

of_dma_request_slave_channel: dma-names property of node '/ocp/spi@48030000' missing or empty
spi spi1.0: not using DMA for McSPI

There is also same message when I open a SPI communication.

The problem is: I'm not able to receive any message. The outgoing messages (MOSI) are working fine, but I always receive (MISO) no answer.  I tried the communication with slave device, I even tried the spidev_test utility with MISO and MOSI pins connected. But I always receive zeros:

# ./spitest
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00


I found similar problems on this forum, but no solution:
https://e2e.ti.com/support/arm/sitara_arm/f/791/p/480760/1733656#pi316653=2
https://e2e.ti.com/support/arm/sitara_arm/f/791/p/521127/1897149#1897149

Thank you for any answer, that would help me to get the SPI communication working.

Best regards,
Jan Moravec

  • Change: 0x150 (PIN_OUTPUT | MUX_MODE0) /* spi0_clk.spi0_clk */
    To: 0x150 (PIN_INPUT | MUX_MODE0) /* spi0_clk.spi0_clk */
  • Sorry, this did not helped.
  • Nevertheless it's absolutely necessary. You may be missing something in the device tree. I will ask the software team to take a look.
  • Hi Jan,

    Could you try the following:
    1. in am4372.dtsi, in spi0 node change:
    compatible = "ti,am4372-mcspi","ti,omap4-mcspi";
    to
    compatible = "ti,omap2-mcspi";

    There is a difference in the register offset in pdata for omap2-mcspi & omap4-mcspi.

    2. in your dts node, change:
    spidev@0 {
    #address-cells = <1>;
    #size-cells = <0>;
    compatible = "spidev";
    to
    spidev@0 {
    #address-cells = <1>;
    #size-cells = <0>;
    compatible = "rohm,dh2228fv";
    You can see that there is NO .compatible = "spidev" in the spidev.c driver, there is .compatible = "rohm,dh2228fv" instead.

    Also make sure you have:
    CONFIG_SPI=y
    CONFIG_SPI_MASTER=y
    CONFIG_SPI_OMAP24XX=y
    CONFIG_SPI_SPIDEV=y
    set in your tisdk_am437x-evm_defconfig file.

    Best Regards,
    Yordan
  • Hi Yordan,

    Thanks for your information.
    I try your setting and can see the spidev1.0 in /dev.
    However, I use spidev_test to do loopback test, I got RX data is not the same as TX data.
    How can I fix this issue?
    Also, while I do the test, I got a message "spidev spi1.0: TXS timed out" is this message correct?

    Here is my setting:
    In am4372.dtsi:
    spi0: spi@48030000 {
    compatible = "ti,omap2-mcspi";
    reg = <0x48030000 0x400>;
    interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
    ti,hwmods = "spi0";
    #address-cells = <1>;
    #size-cells = <0>;
    status = "disabled";
    };

    In am437x-gp-evm.dts:
    spi0_pins: pinmux_spi0_pins {
    pinctrl-single,pins = <
    0x150 ( PIN_INPUT | MUX_MODE0 ) /* (P23) spi0_sclk.spi0_sclk */
    0x154 ( PIN_OUTPUT | MUX_MODE0 ) /* (T22) spi0_d0.spi0_d0 */
    0x158 ( PIN_INPUT | MUX_MODE0 ) /* (T21) spi0_d1.spi0_d1 */
    0x15c ( PIN_OUTPUT | MUX_MODE0 ) /* (T20) spi0_cs0.spi0_cs0 */
    >;
    };

    &spi0 {
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spi0_pins>;
    spidev@0 {
    #address-cells = <1>;
    #size-cells = <0>;
    compatible = "rohm,dh2228fv";
    reg = <0>;
    spi-max-frequency = <16000000>;
    };
    };

    In .config
    # Other I2C/SMBus bus drivers
    #
    # CONFIG_I2C_STUB is not set
    # CONFIG_I2C_SLAVE 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=y
    CONFIG_SPI_MASTER=y

    #
    # SPI Master Controller Drivers
    #
    # CONFIG_SPI_ALTERA is not set
    # CONFIG_SPI_BITBANG is not set
    # CONFIG_SPI_CADENCE is not set
    # CONFIG_SPI_GPIO is not set
    # CONFIG_SPI_FSL_SPI is not set
    # CONFIG_SPI_OC_TINY is not set
    CONFIG_SPI_OMAP24XX=y
    CONFIG_SPI_TI_QSPI=m

    And here is my dmesg:
    root@am437x-evm:~# dmesg | grep "spi"
    [ 1.109085] omap2_mcspi 48030000.spi: registered master spi1
    [ 1.109288] spi spi1.0: not using DMA for McSPI
    [ 1.113971] spi spi1.0: setup: speed 16000000, sample leading edge, clk normal
    [ 1.113987] spi spi1.0: setup mode 0, 8 bits/w, 16000000 Hz max --> 0
    [ 1.114339] omap2_mcspi 48030000.spi: registered child spi1.0

    Test result:
    root@am437x-evm:/opt/ltp/testcases/bin/ddt# ./spidev_test -D /dev/spidev1.0 -l
    [ 2111.978686] spidev spi1.0: not using DMA for McSPI
    [ 2111.983997] spidev spi1.0: not using DMA for McSPI
    [ 2111.988930] spidev spi1.0: not using DMA for McSPI
    spi mode: 32
    bits per word: 8
    max speed: 500000 Hz (500 KHz)
    number of words to be transfered: 100
    --------tx data-----------

    00 01 02 03 04 05
    06 07 08 09 0A 0B
    0C 0D 0E 0F 10 11
    12 13 14 15 16 17
    18 19 1A 1B 1C 1D
    1E 1F 20 21 22 23
    24 25 26 27 28 29
    2A 2B 2C 2D 2E 2F
    30 31 32 33 34 35
    36 37 38 39 3A 3B
    3C 3D 3E 3F 40 41
    42 43 44 45 46 47
    48 49 4A 4B 4C 4D
    4E 4F 50 51 52 53
    54 55 56 57 58 59
    5A 5B 5C 5D 5E 5F
    60 61 62 63
    [ 2113.001870] spidev spi1.0: TXS timed out
    ---------rx data----------

    00 D0 3B EE 09 DF
    E5 BE 00 00 00 00
    00 00 00 00 2F 76
    61 72 2F 6C 6F 67
    2F 6D 65 73 73 61
    67 65 73 00 43 4F
    75 6C 74 00 20 20
    20 20 20 31 39 36
    30 31 37 36 20 6B
    42 0A 4D 65 6D 41
    76 61 69 6C 61 62
    6C 65 3A 20 20 20
    20 32 30 33 33 38
    33 32 20 6B 42 0A
    42 75 66 66 65 72
    73 3A 20 20 20 20
    20 20 20 20

    Best Regards,
    Wayne Kuo

  • Hi Yordan,

    Also, I can't prob any signal on CLK, D1, D0 while I did the test.
    Do you have any suggestion?

    Best Regards,
    Wayne Kuo

  • Hi Champs:


    May you help to ansewr this question?


    We have reviewed the DTS/DTSI file, it should be correct by following your recommandation here.


    Please offer the answer for this issue query.





    Thanks.


    BR Rio
  • Hi Yordan, Biser and Rio,

    1. I tried to port this Device Tree setting on SDK 1.0.03, SPI loopback test is working fine.
        However, I still can not probe SPI_CLK, SPI_D0 & SPI_D1 waveform, AM437x SPI loopback test is internal or external? Why can't I probe the waveform?

    2. There may have some issue on SDK 2.0.1.7.
        Do TI have any solution or patch can solve this issue on SDK 2.0.1.7?

    BR
    Wayne Kuo

  • Hi,

    However, I still can not probe SPI_CLK, SPI_D0 & SPI_D1 waveform, AM437x SPI loopback test is internal or external? Why can't I probe the waveform?


    If your spidev test is working without error messages & you get /dev/spidev1.0 in your rootfs, then SPI1 should be properly initialized . Can you double check that you're probing the correct device pads & your scope settings?

    The loopback test should NOT be internal.

    Do TI have any solution or patch can solve this issue on SDK 2.0.1.7?


    There shouldn't be a difference between SDK2.0.1.7 & SDK1.0.03 for the SPI configuration. If you add the above described .dts node in SDK1.0.03 & change the defcofnig accordingly you should be able to get the SPI working.

    Best Regards,
    Yordan
  • Hi Yordan,

    Sorry, I follow the step that you said on SDK 1.0.0.3, still can probe any signal.
    I've provide my Device Tree setting for Taiwan TI FAE, we all can't find anything wrong about it.
    Can you provide a Device Tree setting that you can probe SPI signal on AM437x GP-EVM? Even SPI0 or SPI1 will be great.
    Thank you very much.

    Best Regards,
    Wayne Kuo

  • Hi TI Champs:

    #1. We have using the CTT tool to check the SPI clock.
    #2. By default, the 437 platform is not turning "on" the SPI clock, so, the devmem2 will have the bus error.
    #3. Moreover, we found the 437 platform is setting the SPI as "Slave"l, so, spidev_test will not working.

    So, can we have the correct patch or guide line to tell us how to make those 2 things to let the SPI working correct?

    A. How to turn on the SPI CLock in the code? by which path/file/function?
    B. How to set the target SPI as Master?

    We know the TI wiki shows somethiong, but, what we need is the Patch to guide us.
    Thanks.

    BR Rio
  • Hi Yordan,
    thank you for suggestions. I tried your Device Tree settings but it made things only worse.

    I can not get even MOSI channel working and the system got stuck with waiting for the answer. This is my output:

    # of_dma_request_slave_channel: dma-names property of node '/ocp/spi@48030000' y
    spidev spi1.0: not using DMA for McSPI
    of_dma_request_slave_channel: dma-names property of node '/ocp/spi@48030000' miy
    spidev spi1.0: not using DMA for McSPI
    of_dma_request_slave_channel: dma-names property of node '/ocp/spi@48030000' miy
    spidev spi1.0: not using DMA for McSPI
    spidev spi1.0: TXS timed out
    spidev spi1.0: TXS timed out
    spidev spi1.0: TXS timed out

    Can you please help me? Do you need more information about my problem?

    Thank you,
    Jan Moravec
  • Hi Jan,

    I've asked the McSPI experts for help. I've managed to enable spidev on AM335x & AM57xx EVM using the mentioned changes. At the moment I cannot get my hands on AM437x EVM to test, but it should be quite similar... Anyway, the design team should post their suggestions directly here.

    Best Regards,
    Yordan
  • Although the SPI_CLK is an output, the IO needs to be defined as an input because it is used by the SPI controller for retiming purposes (See the footnote in Table 26-4 in the TRM). In the device tree file, I don't think PIN_OUTPUT is correct. I think it should be PIN_INPUT or include INPUT_EN. Bottom line is that RXACTIVE bit in CTRL_CONF_SPI0_SCLK needs to be a 1

    Regards,
    James
  • Hi everyone,

    I used Yordan's suggestion to setup SPI0 on AM437x GP-EVM . But there is no luck.
    I can see spidev1.0 under /dev, but can't probe the clock and MOSI signal while doing loopback test.

    My customer has make a customer board for AM437x.
    Their SPI1 ~ SPI4 is working good.
    However, only SPI0 is not good and can probe any waveform, RX data of loopback test is not right as TX data.

    I got customer's feedback yesterday.
    They said after they edit the SPI0_CLK form PIN_OUTPUT to PIN_INPUT, they can probe the clock signal.
    However, the clock signal is weird, signal HIGH is 3.3V, but LOW is around 2.1V, not 0V.
    I'll ask customer to provide the scope waveform.

    Can SPI0 on AM437x use as general SPI? Or it just can use as SPI boot device?
    Any special configuation need to do while using SPI0?

    Best Regards,
    Wayne Kuo

  • Thank you James,

    I have repaired this problem already. It did not help. Now my device tree code looks like:

    	spi0_pins: spi0_pins {
    		pinctrl-single,pins = <
    			0x150 (PIN_INPUT | MUX_MODE0) /* spi0_clk.spi0_clk */
    			0x154 (PIN_OUTPUT | MUX_MODE0) /* spi0_d0.spi0_d0 */
    			0x158 (PIN_INPUT | MUX_MODE0) /* spi0_d1.spi0_d1 */
    			0x15C (PIN_OUTPUT | MUX_MODE0) /* spi0_cs0.spi0_cs0 */
    		>;
    	};
    &spi0 {
    	#address-cells = <1>;
        #size-cells = <0>;
        status = "okay";
    	pinctrl-names = "default"; 
    	pinctrl-0 = <&spi0_pins>;
    	spidev@0 {
    		#address-cells = <1>;
            #size-cells = <0>;
    		compatible = "rohm,dh2228fv"; 
    		reg = <0>;
    		spi-max-frequency = <16000000>;
    		spi-cpha; 
    	};
    };

    The problem is still the same. I can not receive any data.from slave.Can I be making any other mistake?

    Thank you,

    Jan Moravec

  • Jan, can you dump the register configuration after booting?  Specifically, the pin mux registers at address 0x44e10950-0x44e1095c, and the McSPI0 controller registers  0x48030000-0x480301A0.


    Regards,

    James

  • Hello,

    I still have the same Problem with the AM437x IDK board. I want to use the SPI0 to connect an external device to the board, but the SPI0 MISO only show zeros.

    I tried the Solutions in this and the following thread:

    e2e.ti.com/.../340805

    I can measure the waveform on SCK, MOSI, CS0 and they seems to be ok. Still receiving data is not working.

    DTS:

    &spi0  {

                   compatible = "ti,omap4-mcspi";

                   #address-cells = <1>;

                   #size-cells = <0>;

                   reg = <0x48030000 0x400>;

                   interrupts = <65>;

                   ti,spi-num-cs = <2>;

                   pinctrl-names = "default";

                   pinctrl-0 = <&spi0_pins>;

                   ti,hwmods = "spi0";

                   clocks = <&dpll_per_m2_div4_ck>;

                   clock-names = "fck";

                   clock-frequency = <1000000>;        

                   status = "okay";

                    spidev:spidev@0{

                               compatible = "rohm,dh2228fv";

                               reg               = <0>;

                               spi-max-frequency = <10000000>;

                       };

       };

    DTSI:

    spi0: spi@48030000 {

    compatible = "ti,omap2-mcspi";  

    reg = <0x48030000 0x400>;

    interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;

    ti,hwmods = "spi0";

    #address-cells = <1>;

    #size-cells = <0>;

    status = "disabled";

    };

    Those are configurations related on the am335..

    The Test output looks like this:

    root@am437x-evm:/#  ./opt/ltp/testcases/bin/ddt/spidev_test -D  /dev/spidev1.0<\r><\n>

    [  943.760309] spidev spi1.0: not using DMA for McSPI (-19)<\r><\n>

    [  943.766125] spidev spi1.0: not using DMA for McSPI (-19)<\r><\n>

    [  943.771742] spidev spi1.0: not using DMA for McSPI (-19)<\r><\n>

    spi mode: 0<\r><\n>

    bits per word: 8<\r><\n>

    max speed: 500000 Hz (500 KHz)<\r><\n>

    number of words to be transfered: 100<\r><\n>

    --------tx data-----------<\r><\n>

    <\r><\n>

    00 01 02 03 04 05 <\r><\n>

    06 07 08 09 0A 0B <\r><\n>

    0C 0D 0E 0F 10 11 <\r><\n>

    12 13 14 15 16 17 <\r><\n>

    18 19 1A 1B 1C 1D <\r><\n>

    1E 1F 20 21 22 23 <\r><\n>

    24 25 26 27 28 29 <\r><\n>

    2A 2B 2C 2D 2E 2F <\r><\n>

    30 31 32 33 34 35 <\r><\n>

    36 37 38 39 3A 3B <\r><\n>

    3C 3D 3E 3F 40 41 <\r><\n>

    42 43 44 45 46 47 <\r><\n>

    48 49 4A 4B 4C 4D <\r><\n>

    4E 4F 50 51 52 53 <\r><\n>

    54 55 56 57 58 59 <\r><\n>

    5A 5B 5C 5D 5E 5F <\r><\n>

    60 61 62 63 <\r><\n>

    ---------rx data----------<\r><\n>

    <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 00 00 <\r><\n>

    00 00 00 00 <\r><\n>

    root@am437x-evm:/#

    Is there a solution for this problem?

  • Hi,

    here is my solution for this issue. This is working DTS setting:

    	spi4_pins: spi4_pins {
    	pinctrl-single,pins = <
    		0x250 ( PIN_OUTPUT | MUX_MODE0 | INPUT_EN) /* (P25) spi4_sclk.spi4_sclk */
    		0x254 ( PIN_OUTPUT | MUX_MODE0 ) /* (R24) spi4_d0.spi4_d0 */
    		0x258 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (P24) spi4_d1.spi4_d1 */
    		//0x25c ( PIN_OUTPUT | MUX_MODE0 ) /* (N25) spi4_cs0.spi4_cs0 */ 
    		>;
    	};
    
    &spi4 {
        status = "okay";
        pinctrl-names = "default"; 
        pinctrl-0 = <&spi4_pins>;
        ti,pindir-d0-out-d1-in = <1>;
        spidev@4 {
    	#address-cells = <1>;
            #size-cells = <0>;
            compatible = "spidev";
    	reg = <0>;
    	spi-max-frequency = <1000000>;
        };
    };

    The key is to set the "ti,pindir-d0-out-d1-in = <1>;" values.

    Best regards,

    Jan Moravec

  • Hello,

    thank for your very quick answer. I tested it yesterday.

    I copied your configuration and changed SPI names. Miso is still not working.

    I was confused that the MISO pin is not doing any reaction to my changes, so I checked with a simple TI/RTOS project that the spi Pins are working, and they did.

    This is my current Setting:

        &spi0  {
                    compatible = "ti,omap4-mcspi";
                    //#address-cells = <1>;
                    //#size-cells = <0>;
                    reg = <0x48030000 0x400>;
                    interrupts = <65>;
                    ti,spi-num-cs = <2>;
                    pinctrl-names = "default";
                    pinctrl-0 = <&spi0_pins>;
                    ti,hwmods = "spi0";
      ti,pindir-d1-out-d0-in = <1>;
                    clocks = <&dpll_per_m2_div4_ck>;
                    clock-names = "fck";
                    clock-frequency = <1000000>;        
                    status = "okay";
                    spidev@0{
       //compatible = "rohm,dh2228fv";
                     #address-cells = <1>;
                     #size-cells = <0>;
       compatible = "spidev";
       reg               = <0>;
       spi-max-frequency = <10000000>;
      };
        };

    and Pinmuxing:

            spi0_pins: pinmux_spi0_pins {
                pinctrl-single,pins = <
                    0x150 (PIN_OUTPUT_PULLUP | MUX_MODE0 | INPUT_EN)    /* spi0_sclk.spi0_sclk      (also tested with "PIN_INPUT_PULLUP", no difference)
                    0x154 (PIN_INPUT | MUX_MODE0)      /* spi0_d0.spi0_d0 */
                    0x158 (PIN_OUTPUT_PULLUP | MUX_MODE0)      /* spi0_d1.spi0_d1 */
                    0x15C (PIN_OUTPUT_PULLUP | MUX_MODE0)      /* spi0_cs0.spi0_cs0 */
                >;
            };

    Output SCK, CS, MOSI is still working.

    I tried to switch D0=MISO and D1=MOSI, with SPI0 it is not possible?

    Do I miss anything in the configuration for SPI0?  Unfortunately is the SPI0 the only one I can use.

    Kind regards

    Florian Kaiser