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 McSPI problem

Other Parts Discussed in Thread: AM4372

Hi,

I am going to connect my FPGA from the SPI4 of AM437x, to enable the SPI4 I have made the following changes in the device tree.

spi4_pins: pinmux_spi4_pins {
                pinctrl-single,pins = <
                        0x250 (PIN_OUTPUT  | MUX_MODE0) /* spi4_sclk.spi4_sclk */
                        0x254 (PIN_INPUT      | MUX_MODE0) /* spi4_d0.spi4_d0 */
                        0x258 (PIN_OUTPUT  | MUX_MODE0) /* spi4_d1.spi4_d1 */
                        0x25C (PIN_OUTPUT | MUX_MODE0) /* spi4_cs0.spi4_cs0 */

and

&spi4 {
    pinctrl-0 = <&spi4_pins>;
    status = "okay";
    pinctrl-names = "default";
    spidev@4 {
        compatible = "rohm,dh2228fv";
        /*compatible = "linux, spidev";*/
        spi-max-frequency = <24000000>;
        reg = <0>;
    };
};

also, I enabled the McSPI driver for OMAP in the kernel configuration,

and enabled    User mode SPI device driver support

after this I compiled the kernel and device tree and updated the sd card image and now I can see the spidev2.0 in the /dev. 

Now I shorted the pin 65 and pin 63 which is data in and data out of the SPI4 to test the driver.

Now I am sendend the data to the driver but still not able to get any data back.

Please suggest what is the problem here.

Thank you.

Regards,

Zafar

  • Hi,

    You must change: 0x250 (PIN_OUTPUT | MUX_MODE0) /* spi4_sclk.spi4_sclk */
    To: 0x250 (PIN_INPUT | MUX_MODE0) /* spi4_sclk.spi4_sclk */

    See Note 1 below Table 26-4 in the AM437x TRM Rev. D for details.
  • Hi,

    I have changed the 0x250 (PIN_OUTPUT | MUX_MODE0) to 0x250 (PIN_INTPUT | MUX_MODE0) now but still it is not working, I connected the pin 65 to 63( D1 to D0 ) and sending the data and receiving the same, but I am not able to get it. Is the mode is correct.


    Thanks

    Regards
    Zafar
  • You seem to be missing the pinmux entry in your &spi4 node. See this wiki: processors.wiki.ti.com/.../Linux_Core_SPI_User's_Guide
  • Hi,

    Thanks for your suggestion, Now I am able to use the SPI driver, I am using SPI4 since SPI4 support cs0 and cs1, I wanted to make use of cs1 also so that I can communicate with the other device also, using the same bus.

    Please suggest what changes need to be done in the following device tree

    spi4_pins: pinmux_spi4_pins {
    pinctrl-single,pins = <
    0x250 (PIN_OUTPUT | MUX_MODE0) /* spi4_sclk.spi4_sclk */
    0x254 (PIN_INPUT | MUX_MODE0) /* spi4_d0.spi4_d0 */
    0x258 (PIN_OUTPUT | MUX_MODE0) /* spi4_d1.spi4_d1 */
    0x25C (PIN_OUTPUT | MUX_MODE0) /* spi4_cs0.spi4_cs0 */

    and

    &spi4 {
    pinctrl-0 = <&spi4_pins>;
    status = "okay";
    pinctrl-names = "default";
    spidev@4 {
    compatible = "rohm,dh2228fv";
    spi-max-frequency = <24000000>;
    reg = <0>;
    };
    };
  • As long as you do not enable the input for SP_SCLK, the receive channel of the McSPI will not work, check Note 1 below Table 26-4 in the AM437x TRM Rev. E for details.
  • Hi,

    I made following changes:

    spi4_pins: pinmux_spi4_pins {
    pinctrl-single,pins = <
    0x250 (PIN_INPUT | MUX_MODE0) /* spi4_sclk.spi4_sclk */
    0x254 (PIN_INPUT | MUX_MODE0) /* spi4_d0.spi4_d0 */
    0x258 (PIN_OUTPUT | MUX_MODE0) /* spi4_d1.spi4_d1 */
    0x25C (PIN_OUTPUT | MUX_MODE0) /* spi4_cs0.spi4_cs0 */

    and

    &spi4 {
    pinctrl-0 = <&spi4_pins>;
    status = "okay";
    pinctrl-names = "default";
    spidev@4 {
    compatible = "rohm,dh2228fv";
    spi-max-frequency = <24000000>;
    reg = <0>;
    };
    };

    Now I wanted to connect two devices from the SPI4 ( two different section in FPGA ) hence except the chip select all line D0, D1 and SCLK will remain same, So please suggest what changes I need to add in the device tree so that I can make use of the cs1 ( of SPI4 ) as well. presently only CS0 is used.

    Thank you

    Regards,

    Zafar

  • Hi Zafar,

    Zafar Iqbal said:
    please suggest what changes I need to add in the device tree so that I can make use of the cs1 ( of SPI4 ) as well. presently only CS0 is used.

     

    Try adding  ti,spi-num-cs = <number_of_chip_selects>; in spi4: spi@48345000  in am4372.dtsi 

    Then in your dts try modifying the &spi4 like: 
      &spi4 {

         pinctrl-names = "default";
         pinctrl-0 = <&spi4_pins>;
         status = "okay";
         spidev@4 {
               compatible = "rohm,dh2228fv";
               spi-max-frequency = <24000000>;
               reg = <0>;                                            ==>CS0
         };

        spidev1@4 {

               compatible = "rohm,dh2228fv";
               spi-max-frequency = <24000000>;
               reg = <1>;                                             ==> CS1
         };     

    };

    Hope this helps. 

    Best Regards, 
    Yordan

  • Hi Yordan,

    Thanks a lot.

    This is working for me now.
    Just one last question will this driver by default will be in duplex mode or I need to add duplex =<1> in the device tree to make it in the duplex mode.

    Thank you.

    Regards,
    Zafar
  • Hi Zafar,

    I am not sure that the spi.c supports full duplex mode. Have a look at the driver: drivers/spi/spi.c, you will see that it only mentions SPI_MASTER_HALF_DUPLEX.

    Best Regards,
    Yordan
  • Hi Yordan,

    Thanks a lot for your support. I worked yesterday for sometime. I verified the same what you suggested, but those are condition, I looked into the spidev.c file also and found that it supports full duplex also. Now I am able to communicate in the full duplex mode also.

    Thanks a lot to help me to make my device up and running.

    regards,
    Zafar