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.

SPI Communication on AM437x Starter Kit

Hi,

I am new to Linux and AM437x.

I have a AM437x Starter Kit (with Linux SDK) and I would like to know how to use SPI on this device/board.

Thanks.

  • How to enable and use SPI2 on AM437x Starter Kit?

    Thanks.

  • Hi,

    Can you please explain what is your intention? The Starter Kit is more or less a closed system with no general purpose expansion connectors. Schematics can be found here: www.ti.com/.../tmdxsk437x Documents From what I see the only possibility would be to use SPI2 on page 18.
  • Hi Biser,

    To make my question simple, my intention is to use SPI2 through J10 connector.

    • I would like to know how to enable and use this SPI2.
    • Is this enabled by default or should I make any modifications in the am437x-sk-evm.dts (under ../arch/arm/boot/dts/) file and any other files to make it work.

    Please let me know if you need further clarification.

    Thanks.

  • I will ask the software team. You should be careful when using this connector, as it's primary purpose is for JTAG. You should make sure that none of the processor JTAG signals are connected.
  • Hi SureKa,

    You can find general description about SPI initialization under Linux in the Overview of Linux kernel SPI support document at:
    www.kernel.org/.../spi-summary
    Also you can find description of all SPI related structures and functions at:
    www.kernel.org/.../spi.html
    The specific register values can be found in the AM437x Sitara Processors Technical Reference Manual at:
    www.ti.com/.../spruhl7d.pdf

    If the SPI2 pin mux is not configured in your .dts file you should add configuration about it.

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin,

    Thanks for the information.

    As the SPI2 was not configured in the .dts file, I added the following lines of code in it:

    &am43xx_pinmux {

    /******************************/
    spi2_pins: spi2_pins {
        pinctrl-single,pins = <
             0x260 (PIN_OUTPUT_PULLUP | MUX_MODE0)
             0x264 (PIN_INPUT_PULLUP | MUX_MODE0)
             0x268 (PIN_INPUT_PULLUP | MUX_MODE0)
             0x26c (PIN_OUTPUT_PULLUP | MUX_MODE0)
             >;
    };
    /******************************/

                 };

    &spi2 {
                     status = "okay";
                     pinctrl-names = "default";
                     pinctrl-0 = <&spi2_pins>;
                     spidev@0 {
                     spi-max-frequency = <24000000>;
                     reg = <0>;
                     compatible = "linux,spidev";
               };

    I then compiled the .dts file and a new .dtb file is generated.

    But I don't see the SPI drivers in the $evm/dev.

    Please let me know if my approach is correct and which other files should I edit to enable SPI2. And, how to know if the SPI2 is enabled other than looking at the $evm/dev/ ?

    Thanks,

     

  • Hello TI,

    Can someone please help me with my problem?

    Thanks.

  • Hi,

    I still not able to make the SPI2 on this board working. Please help me in this regard.

    Following are the changes I made in the .dts file:

    spi2_pins: spi2_pins {
    	pinctrl-single,pins = <
    	0x260 (PIN_OUTPUT_PULLUP | MUX_MODE0) /* spi_sclk */
    	0x264 (PIN_OUTPUT_PULLUP | MUX_MODE0) /* spi_MOSI */
    	0x268 (PIN_INPUT_PULLUP | MUX_MODE0)  /* spi_MISO */
    	0x26c (PIN_OUTPUT_PULLUP | MUX_MODE0) /* spi_cs */
    	>; 
    };
    
    &spi2 {
    	#address-cells = <1>;
    	#size-cells = <0>;
    	status = "okay";
    	pinctrl-names = "default";
    	pinctrl-0 = <&spi2_pins>;
    	spidev@0 {
    		#address-cells = <1>;
    		#size-cells = <0>;
    		compatible = "spidev";
    		reg = <0>;
    		spi-max-frequency = <16000000>;
    		spi-cpha;
    	};
    };
    

    I can see spidev1.0 in the root@am437x-evm:/dev# .

    I used the spidev_test.c program to test the SPI2 interface. 

    Pins 3 and 5 of the J10 are shorted to make a loop back connection. 

    But I haven't received the expected data, but all 00s. 

    Could anyone please help me how to enable SPI2 and work with it on this particular board? 

    Thanks.