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.

  • Resolved

Linux/AM4378: Spidev does not output on pins

Intellectual 610 points

Replies: 25

Views: 8803

Part Number: AM4378

Tool/software: Linux

Hi Everybody!

I recently got my spidev devices registered in /dev (see here for details). 

My devices don't seem to work unfortunately.  I have only scoped out spidev1.1 so far.  I can open the device.  When I configre it I do get messages complaining about not using DMA (see below).  And then I get a TXS timed out message.

I am using a program really similar to this one.  I just added a ton of printing and slowed things down so that I could tell which actions were causing the system log messages.

Here is the output.

root@am437x-evm:/ace/bin# ./helloSpi -C 301
helloSpi ...
    ...Options selected
        device = /dev/spidev1.1
        speed = 24000000
        delay = 0
        bits = 8
        mode = 0x04
    ...Creating device
    ...Setting SPI option
    ...Opening file handle
    ...Committing options     <-- 3 ioctl calls in here
[62332.673461] spidev spi1.1: not using DMA for McSPI (-19)
[62332.678907] spidev spi1.1: not using DMA for McSPI (-19)
[62332.689027] spidev spi1.1: not using DMA for McSPI (-19)
    ...Setting up data transfer
        TX = 0x03 0x01 0x00 0x00 0x00 0x00 0x00 0x00
        RX = 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
    ...Performing ioctl data transfer   <-- 1 ioctl call in here
[62340.712144] spidev spi1.1: TXS timed out
    ...Receive buffer
        RX = 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Good bye!

I had our electrical team scope the clk, miso, mosi, and cs pin for spidex1.1 and there is no activity.

I also see the cs pin held low the entire time.  I think it should only go low when the spi master wants to send data to or retrieve data from that particular device.

Here is my pin mux...

spi2_internal_pins_default: spi2_internal_pins_default {
    pinctrl-single,pins = <
        0x260 ( PIN_OUTPUT | INPUT_EN | MUX_MODE0 ) /* (N20) spi2_sclk.spi2_sclk */
        0x264 ( PIN_OUTPUT | MUX_MODE0 )            /* (P22) spi2_d0.spi2_d0 */
        0x268 ( PIN_INPUT_PULLUP | MUX_MODE0 )      /* (P20) spi2_d1.spi2_d1 */
        0x1b0 ( PIN_OUTPUT | MUX_MODE4 )            /* (AE17) cam0_hd.spi2_cs1 */
        0x1c4 ( PIN_OUTPUT | MUX_MODE4 )            /* (AB19) cam0_data8.spi2_cs2 */
    >;

}

&spi2 {
    compatible = "ti,omap2-mcspi";
    pinctrl-names = "default";
    pinctrl-0 = <&spi2_internal_pins_default>;
    status = "okay";

        ti,spi-num-cs = <4>;
        ti,pindir-d0-out-d1-in = <1>;

ksz8895@1 {
    compatible = "rohm,dh2228fv";
    spi-max-frequency = <100000>;
    reg = <0x1>;
    status = "okay";
    #address-cells = <1>;
    #size-cells = <0>;
};
ksz8895@2 {
    compatible = "rohm,dh2228fv";
    spi-max-frequency = <100000>;
    reg = <0x2>;
    status = "okay";
    #address-cells = <1>;
    #size-cells = <0>;
};

};

Here are (what I think are pertinent) defconfig settings. In fact here's everything SPI related.  I highlighted the ones I think actually matter

root@am437x-evm:/ace/bin# cat /proc/config.gz|gunzip|grep SPI|grep \# -v|grep SPIN -v
CONFIG_REGMAP_SPI=y
CONFIG_MTD_SPI_NOR=y
CONFIG_SPI_CADENCE_QUADSPI=y
CONFIG_WLCORE_SPI=m
CONFIG_INPUT_ADXL34X_SPI=m
CONFIG_SPI=y
CONFIG_SPI_MASTER=y
CONFIG_SPI_BITBANG=m
CONFIG_SPI_GPIO=m
CONFIG_SPI_OMAP24XX=y
CONFIG_SPI_TI_QSPI=y
CONFIG_SPI_SPIDEV=y
CONFIG_SND_SOC_I2C_AND_SPI=y
CONFIG_RTC_I2C_AND_SPI=y

I've seen various posts about differing pinmux settings.  I've seen Biser say the clk needs to be an input (I tried, no change), I've seen another post that said they had success with clk as output with input_en flag.  So I'm not sure what is the "right" answer. 

All thoughts/suggestions/troubleshooting tips are welcome.

Thanks in advance!

Nathan

  • In reply to Yordan Kovachev:

    Hi Yordan,

    I added the related items to the u-boot dts and nothing changed. I get mosi and clk on startup briefly, then never again.

    Nathan
  • In reply to Nathan Wright:

    Are there any registers I could inspect with the XDS2xx debugger? I'd like to confirm that the traces I'm connected to really are connected to the pinpads I think they are connectd to. If I can confirm they are, then we can be sure it is a pinmuxing/linux/issue.

    Any help would be greatly appreciated.
    Nathan
  • In reply to Nathan Wright:

    Hi,

    You can dump the corresponding SPI pinmux settings:
    CTRL_CONF_CAM0_HD 9B0 ===> muxmode4 => spi2_cs1
    CTRL_CONF_CAM0_VD 9B4 ===> I think this should be CTRL_CONF_CAM0_PCLK 9C0 (offset in dts 1C0) MUX_MODE4 => spi2_cs0 Curretnly CTRL_CONF_CAM0_HD (offsett in dts 1B0) is set to MUX_MODE4 => spi2_d0, so you're missing cs0.
    CTRL_CONF_SPI2_SCLK A60 ===> clk
    CTRL_CONF_SPI2_D0 A64 ===> d0
    CTRL_CONF_SPI2_D1 A68 ===> d1

    Best Regards,
    Yordan

     


     Please make sure you read the forum guidelines first.

  • In reply to Yordan Kovachev:

    Hi Yordan,

    I did not realize you could not skip a chip select line.  I have a pin available that goes no where.  I configured it like this...

    spi2_internal_pins_default: spi2_internal_pins_default {
        pinctrl-single,pins = <
            0x260 ( PIN_INPUT | MUX_MODE0 ) /* (N20) spi2_sclk.spi2_sclk */
            0x264 ( PIN_OUTPUT | MUX_MODE0 ) /* (P22) spi2_d0.spi2_d0 */
            0x268 ( PIN_INPUT | MUX_MODE0 ) /* (P20) spi2_d1.spi2_d1 */
            0x1c0 ( PIN_OUTPUT | MUX_MODE4 ) /* (AC20) cam0_pclk.spi2_cs0 */   <- New CS0 pin to nowhere
            0x1b0 ( PIN_OUTPUT | MUX_MODE4 ) /* (AE17) cam0_hd.spi2_cs1 */
            0x1c4 ( PIN_OUTPUT | MUX_MODE4 ) /* (AB19) cam0_data8.spi2_cs2 */
        >;
    };

    &spi2 {
        compatible = "ti,omap2-mcspi";
        pinctrl-names = "default";
        pinctrl-0 = <&spi2_internal_pins_default>;
        status = "okay";

        ti,spi-num-cs = <3>;
        ti,pindir-d0-out-d1-in = <1>;

        ksz8895@1 {
            compatible = "rohm,dh2228fv";
            spi-max-frequency = <100000>;
            reg = <0x1>;
            status = "okay";
            #address-cells = <1>;
            #size-cells = <0>;
            spi-cs-high;
        };
        ksz8895@2 {
            compatible = "rohm,dh2228fv";
            spi-max-frequency = <100000>;
            reg = <0x2>;
            status = "okay";
            #address-cells = <1>;
            #size-cells = <0>;
            spi-cs-high;
        };
    };

    Rebuilt the dtb and there was no change in the behavior.  No MOSI and no CLK output.

  • In reply to Nathan Wright:

    Ok. With the settings you have, do you see /dev/spidevX.Y nodes in your filesystem?

    Best Regards,
    Yordan

     


     Please make sure you read the forum guidelines first.

  • In reply to Yordan Kovachev:

    Yes,

    root@am437x-evm:~# ls /dev/spi*
    /dev/spidev1.1 /dev/spidev1.2

    Nathan

  • In reply to Nathan Wright:

    To confirm I didn't have a board problem. I re-muxed the spi2 pins to be gpio. Then I confirmed I could toggle each pin with sysfs. I do not think there is a problem with the layout of my board.

    Should I try to run spi2 with no chip selects?
  • In reply to Yordan Kovachev:

    Hi Yordan,

    Do you have any other thoughts on why SPI doesn't work?

    Thanks,
    Nathan

  • In reply to Nathan Wright:

    Nathan,

    As I said previously, I have no other explanation except that the ethernet phys ksz8895 are somehow not compatible and don't want to communicate with the spidev driver.

    If you just change your dts as spidev@1 and spidev@2 isntead of  ksz8895@1 and  ksz8895@2,  your board should be working fine, and this should verify that your spi configurations are correct.

    Best Regards,
    Yordan

     


     Please make sure you read the forum guidelines first.

  • In reply to Yordan Kovachev:

    Thanks Yordan,

    I thought that text was an arbitrary label. I have changed the dts to spidev instead of ksz8895. Here is the entry...

    spi2_internal_pins_default: spi2_internal_pins_default {
    pinctrl-single,pins = <
    0x260 ( PIN_INPUT | MUX_MODE0 ) /* (N20) spi2_sclk.spi2_sclk */
    0x264 ( PIN_OUTPUT | MUX_MODE0 ) /* (P22) spi2_d0.spi2_d0 */
    0x268 ( PIN_INPUT | MUX_MODE0 ) /* (P20) spi2_d1.spi2_d1 */
    0x1c0 ( PIN_OUTPUT | MUX_MODE4 ) /* (AC20) cam0_pclk.spi2_cs0 */
    0x1b0 ( PIN_OUTPUT | MUX_MODE4 ) /* (AE17) cam0_hd.spi2_cs1 */
    0x1c4 ( PIN_OUTPUT | MUX_MODE4 ) /* (AB19) cam0_data8.spi2_cs2 */
    >;
    };

    &spi2 {
    compatible = "ti,omap2-mcspi";
    pinctrl-names = "default";
    pinctrl-0 = <&spi2_internal_pins_default>;
    status = "okay";

    ti,spi-num-cs = <3>;
    ti,pindir-d0-out-d1-in = <1>;

    spidev@1 {
    compatible = "rohm,dh2228fv";
    spi-max-frequency = <100000>;
    reg = <0x1>;
    status = "okay";
    #address-cells = <1>;
    #size-cells = <0>;
    spi-cs-high;
    };
    spidev@2 {
    compatible = "rohm,dh2228fv";
    spi-max-frequency = <100000>;
    reg = <0x2>;
    status = "okay";
    #address-cells = <1>;
    #size-cells = <0>;
    spi-cs-high;
    };
    };

    ... as you can see I have three contiguous chip selects in use as you recommended. I still get the same results.

    I get these when I try to configure the SPI...

    [ 9935.293689] spidev spi1.2: not using DMA for McSPI (-19)
    [ 9935.299140] spidev spi1.2: not using DMA for McSPI (-19)
    [ 9935.309422] spidev spi1.2: not using DMA for McSPI (-19)

    ... are these errors benign?

    I get this when I try to transfer data...

    [ 9943.333015] spidev spi1.2: TXS timed out 2

    I added the "2" to the driver since there are many "TXS timed out" messages in the driver. This one is inside omap2_mcspi_txrx_pio at line 729.

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.