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 Not working with am3352.

Other Parts Discussed in Thread: AM3352

I have configured the SPI0 pins for our coustom board.

below is the pin muxing for spi in .dts file

                  0x150 0x30  /* spi0_sclk, INPUT_PULLUP | MODE0 */
                  0x154 0x30  /* spi0_d0, INPUT_PULLUP | MODE0 */
                  0x158 0x10  /* spi0_d1, OUTPUT_PULLUP | MODE0 */
                  0x15c 0x10  /* spi0_cs0, OUTPUT_PULLUP | MODE0 */

I also able to see the "spidev1.0 " in /dev folder.
But when ever I am trying to test "spidev_test" application as suggested in the below url, I am not able to transmit the data.
I followed the url as mentioned elinux.org/BeagleBone_Black_Enable_SPIDEV

When I probed the Tx and CLK of SPI in my custom board by running the test application, I am not getting any pulse triggers.
To verify any H/W problem, I disabled the SPI and then exported those pins as GPIO. After that when I tried to toggle the pins I could able to see the change in voltage level in Oscilloscope.

can any one help me in resolving the issue to make the SPI work.

Regards
Sudipta.


  • Please post the entire SPI section from the .dts
  • Hi Biser

    The SPI section of my .dts file looks as follow

    mcspi0_pins_default: pinmux_mcspi0_pins {
                 pinctrl-single,pins = <
                              0x150 (PIN_INPUT_PULLUP | MUX_MODE0)
                              0x154 (PIN_INPUT_PULLUP | MUX_MODE0)
                              0x158 (PIN_OUTPUT_PULLUP | MUX_MODE0)
                              0x15C (PIN_OUTPUT_PULLUP | MUX_MODE0)
                >;
    };

    mcspi0_pins_sleep: pinmux_mcspi0_pins {
               pinctrl-single,pins = <
                              0x150 (PIN_INPUT_PULLUP | MUX_MODE7)
                              0x154 (PIN_INPUT_PULLUP | MUX_MODE7)
                              0x158 (PIN_OUTPUT_PULLUP | MUX_MODE7)
                              0x15C (PIN_OUTPUT_PULLUP | MUX_MODE7)
              >;
    };

    &spi0 {
          pinctrl-names = "default", "sleep";
          pinctrl-0 = <&mcspi0_pins_default>;
          pinctrl-1 = <&mcspi0_pins_sleep>;
          status = "okay";
                spidev0:spi@0 {
                            compatible = "spidev";
                            spi-max-frequency = <48000000>;
                            reg = <0>;
                            status = "okay";
                            };
          };

  • Hi,

    You should use:

      spidev@0

    instead of

      spidev0:spidev@0

    Also you should have:

     compatible = "linux, spidev"; 


    Configured this way, you should see spidev0.0 in /dev, can you confirm? 

    Best Regards, 
    Yordan

  • Hi,

    I tested this on BBB (with am3352 on it).

    Here is how i configured my spidev:

             spi0_pins: spi0_pins {

                   pinctrl-single,pins = <

                         0x150 (PIN_INPUT_PULLUP | MUX_MODE0)

                         0x154 (PIN_INPUT_PULLUP | MUX_MODE0)

                         0x158 (PIN_OUTPUT_PULLUP | MUX_MODE0)

                         0x15C (PIN_OUTPUT_PULLUP | MUX_MODE0)

                   >;

           };

    &spi0 {

        pinctrl-names = "default";

        pinctrl-0 = <&spi0_pins>;

        status = "okay";

               spidev@0 {

                           compatible = "linux,spidev";

                           spi-max-frequency = <48000000>;

                           reg = <0>;

                           status = "okay";

               };

    };

    Also in drivers/spi/spidev.c, I had to add:

      static const struct of_device_id spidev_dt_ids[] = {

          { .compatible = "rohm,dh2228fv" },

          { .compatible = "linux,spidev"},

            {},

    }

    Another option is tu use compatible = "rohm,dh2228fv", instead of compatible = "linux,spidev" in your spidev dts node. 

    As a result, I got /dev/spi1.0. 

    Spi pins are outputted on P9_17 -> spi0_cs0 (0x15C), P9_18 -> spi0_d1 (0x158) & P9_22 -> spi0_sclk (0x150). 

    When I execute: 
       echo "DEADBEEF" > /dev/spi1.0 

    I can see activity on the spi pins listed above, see scope screen: 

    Hope this helps. 

    Best Regards, 
    Yordan

  • Hi Yordan,

    Thanks for your help. It worked.

    Regards

    Sudipta.