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.

AM57X: Not able to probe SPI driver

Hello,

I am using SDKv2.0 for AM57xx EVM. I have modified device tree file am57xx-evm.dts as below.
 

mcspi4_pins: mcspi4_pins {
                pinctrl-single,pins = <
                        0x350 (PIN_OUTPUT | MUX_MODE2) /*mcasp5_axr1.spi4_cs0*/
                        0x34C (PIN_OUTPUT | MUX_MODE2) /*mcasp5_axr0.spi4_d0*/
                        0x348 (PIN_INPUT | MUX_MODE2) /*mcasp5_fsx.spi4_d1*/
                        0x344 (PIN_OUTPUT | MUX_MODE2) /*mcasp5_aclkx.spi4_clk*/
                >;
        };

&mcspi4 {
        pinctrl-names = "default";
        pinctrl-0 = <&mcspi4_pins>;
        status = "okay";
        spidev@0 {
                  compatible = "linux, spidev";
                  spi-max-frequency = <48000000>;
                  reg = <0x0>;
                  status = "okay";
        };
};

But after a kernel boot I can not see the spidev in /dev/ . I also want to add custom device driver i.e. mcp23s08. When I have modified device tree for MCP23S08, as below, it gives error during kernel boot that.

&mcspi4 {
        pinctrl-names = "default";
        pinctrl-0 = <&mcspi4_pins>;
        status = "okay";
        gpiom1: mcp23s17@3 {
                compitible = "microchip,mcp23s17";
                spi-max-frequency = <1000000>;
                reg = <0>;
                #address-cells = <1>;
                #size-cells = <0>;
        };
};

Below is the error:

[    1.610137] spi_master spi32766: cannot find modalias for /ocp/spi@480ba000/mcp23s17@3
[    1.618095] spi_master spi32766: Failed to create SPI device for /ocp/spi@480ba000/mcp23s17@3

So could you please help me resolve this two issues?

  • Hi,

    I will ask the software team to check your dts settings. One thing that you should change is:

    0x344 (PIN_OUTPUT | MUX_MODE2) /*mcasp5_aclkx.spi4_clk*/

    to

    0x344 (PIN_INPUT | MUX_MODE2) /*mcasp5_aclkx.spi4_clk*/

    For explanation see Note below Table 24-288 in the AM572X TRM Rev. D.
  • Hi,

    Rakesh Modi said:
    But after a kernel boot I can not see the spidev in /dev/

     

    Make sure that you enable CONFIG_SPI_SPIDEV in your .config, or through menuconfig. I checked my sources (of ti-processor-sdk-linux-am57xx-evm-02.00.00.00) and this is NOT enabled by default. 

    After you recompile your kernel see if you have 

    sys/class/spi_master/spiX 

    sys/class/spidev/ 

    and 

    dev/spidevX 

    Rakesh Modi said:
    I also want to add custom device driver i.e. mcp23s08. When I have modified device tree for MCP23S08, as below, it gives error during kernel boot that.

    Below is the error:

    [    1.610137] spi_master spi32766: cannot find modalias for /ocp/spi@480ba000/mcp23s17@3
    [    1.618095] spi_master spi32766: Failed to create SPI device for /ocp/spi@480ba000/mcp23s17@3

    In your custom driver, can you try adding:

    #ifdef CONFIG_OF
    static const struct of_device_id mcp23s17_dt_ids[] = {
             { .compatible = "microchip,mcp23s17" },
             {},
    };
    MODULE_DEVICE_TABLE(of, mcp23s17_dt_ids);
    #endif 

    I suggest you take a reference from the spi-omap2-mcspi.c driver.

    Hope this helps. 

    Best Regards, 
    Yordan

  • Thanks for your reply Yordan. I have enabled CONFIG_SPI_SPIDEV and I can see sys/class/spidev/ & sys/class/spidev/. But I can not see /dev/spidevX. I have also changed the pinmux for spi clock as you suggested. So what could be the problem for this behaviour?

    For mcp23s17 I am able to solve the issue. It was error in dts file.

  • Hi Yordan, 

    Could you let me know what you had wrong in the .dts file for using the MCP23S17? How did the device appear in your /dev or /sys directory once you got it working?

    I am trying to get the MCP23S18 working with the am335x. I can see some device files but I don't think they can be used for control of the device:

    root@am335x-evm:/sys/class/spi_master/spi1/spi1.1/of_node# ls
    #gpio-cells gpio-controller reg spi-present-mask
    compatible name spi-max-frequency

    I was expecting it to register as some sort of gpio device (sys/class/gpio) but I can only find the processor gpio's here.

    Basically I am trying to work out if the device is registered with the kernel correctly and how I should communicate with it once it is

    I have the CONFIG_SPI_SPIDEV and CONFIG_GPIO_MCP23S08 enabled in .config

    A cut down version of my .dts file looks like:

    // from the .dtsi file

    &am33xx_pinmux {
    pinctrl-names = "default";

    spi0_pins: pinmux_spi0_pins {
    pinctrl-single,pins = <
    AM33XX_IOPAD(0x150, PIN_INPUT | MUX_MODE0 ) // (A18) spi0_sclk.spi0_sclk
    AM33XX_IOPAD(0x154, PIN_INPUT | MUX_MODE0 ) // (B18) spi0_d0.spi0_d0
    AM33XX_IOPAD(0x158, PIN_INPUT | MUX_MODE0 ) // (B17) spi0_d1.spi0_d1
    AM33XX_IOPAD(0x15c, PIN_OUTPUT | MUX_MODE0 ) // (A17) spi0_cs0.spi0_cs0
    AM33XX_IOPAD(0x160, PIN_OUTPUT | MUX_MODE0 ) // (B16) spi0_cs1.spi0_cs1
    >;
    };
    };


    &spi0 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spi0_pins>;
    };


    //from my .dts file

    &spi0 {

    mcp: mcp@1 {
    compatible = "mcp,mcp23s17";
    reg = <1>;
    gpio-controller;
    #gpio-cells = <2>;
    spi-present-mask = <0x01>;
    spi-max-frequency = <1000000>;
    };


    nvram: nvram {
    address-cells = <1>;
    #size-cells = <1>;
    compatible = "spansion,mr25h10"; //may need to change spansion.
    reg = <0>;
    spi-max-frequency = <40000000>;
    m25p,fast-read;
    };

    };