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 woes - spidev devices not being created

Part Number: AM4378

Tool/software: Linux

Hi Everybody!

Our AM4378 has two (2) switches attached to it on spi2.  Switch[1] is connected to chip select 1 (AE17).  Switch[2] is connected to chip select 2 (AB19).

An except from my pin mux...

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 */
        0x1b0 ( PIN_OUTPUT | MUX_MODE4 ) /* (AE17) cam0_hd.spi2_cs1 */
        0x1c4 ( PIN_OUTPUT | MUX_MODE4 ) /* (AB19) cam0_data8.spi2_cs2 */
    >;
};

An excerpt from the dts outside the pin mux, setting up spi2...

&spi2 {
    pinctrl-names = "default";
    pinctrl-0 = <&spi2_internal_pins_default>;
    status = "okay";

    cs-gpios = <0>, <0>, <0>, <0>;
    //num-cs = 4;

    spidev@1 {
        compatible = "linux, spidev";
        spi-max-frequency = <25000000>;
        reg = <0x1>;
        status = "okay";
    };
    spidev@2 {
        compatible = "linux, spidev";
        spi-max-frequency = <25000000>;
        reg = <0x2>;
        status = "okay";
    };
};

In the config I have...

#
# SPI Protocol Masters
#
CONFIG_SPI_SPIDEV=y

In /sys...

root@am437x-evm:/sys# find . -name spi\*
./class/spidev
./class/spi_master
./firmware/devicetree/base/aliases/spi0
./firmware/devicetree/base/ocp@44000000/spinlock@480ca000
./firmware/devicetree/base/ocp@44000000/spi@481a0000
./firmware/devicetree/base/ocp@44000000/spi@48030000
./firmware/devicetree/base/ocp@44000000/spi@48345000
./firmware/devicetree/base/ocp@44000000/spi@481a2000
./firmware/devicetree/base/ocp@44000000/spi@481a2000/spidev@1
./firmware/devicetree/base/ocp@44000000/spi@481a2000/spidev@1/spi-max-frequency
./firmware/devicetree/base/ocp@44000000/spi@481a2000/spidev@2
./firmware/devicetree/base/ocp@44000000/spi@481a2000/spidev@2/spi-max-frequency
./firmware/devicetree/base/ocp@44000000/l4_wkup@44c00000/scm@210000/pinmux@800/spi2_internal_pins_default
./firmware/devicetree/base/ocp@44000000/spi@481a4000
./bus/spi
./bus/spi/drivers/spidev
./module/spidev

...but I get no spidev devices created in /dev.

I tried making them manually...

mknod /dev/spidev2.1 c 153 1

... and a node was created, but I couldn't open it in my program.

Any thoughts on trouble shooting why my devices are not appearing in /dev?

Thanks!

Nathan

  • Hi Nathan,

    Is udev daemon running in your system ?

    Thanks and Regards,

    Dwarakesh R.

    PathPartner Technology

  • In reply to Dwarakesh R:

    I think so...

    root@am437x-evm:~# ps -ef | grep udev
    root 114 1 2 11:32 ? 00:00:01 /lib/systemd/systemd-udevd

    Is there a better way to check?

    Nathan

  • After a bit more head banging I enabled...

        CONFIG_SPI_OMAP24XX=y

    ...which I had previously thought replaced spidev = y.  I guess they are two different thingus's.

    I then got errors about chip selects exceeding max cs.

    So I added...
        ti,spi-num-cs = <4>;
    ... to &spi2

    And now I get this in dmesg...
    [ 1.209866] spi spi1.1: not using DMA for McSPI (-19)
    [ 1.215334] spidev spi1.1: buggy DT: spidev listed directly in DT
    [ 1.226143] WARNING: CPU: 0 PID: 1 at drivers/spi/spidev.c:757 spidev_probe+0x1ac/0x1cc
    [ 1.295503] [<c012d418>] (warn_slowpath_null) from [<c0586338>] (spidev_probe+0x1ac/0x1cc)
    [ 1.303831] [<c058618c>] (spidev_probe) from [<c0582b48>] (spi_drv_probe+0x84/0xb4)
    [ 1.318276] [<c0582ac4>] (spi_drv_probe) from [<c051c978>] (driver_probe_device+0x20c/0x2b8)
    [ 1.413367] [<c0519820>] (device_add) from [<c0583cc0>] (spi_add_device+0xa4/0x13c)
    [ 1.431472] [<c0583c1c>] (spi_add_device) from [<c0584188>] (of_register_spi_device+0x220/0x318)
    [ 1.445996] [<c0583f68>] (of_register_spi_device) from [<c05846e4>] (spi_register_master+0x28c/0x488)
    [ 1.461994] [<c0584458>] (spi_register_master) from [<c0584920>] (devm_spi_register_master+0x40/0x78)
    [ 1.481681] [<c05848e0>] (devm_spi_register_master) from [<c0588f68>] (omap2_mcspi_probe+0x2e0/0x36c)
    [ 1.496645] [<c0588c88>] (omap2_mcspi_probe) from [<c051e478>] (platform_drv_probe+0x58/0xb8)
    [ 1.607569] [<c051e38c>] (__platform_driver_register) from [<c0b2988c>] (omap2_mcspi_driver_init+0x1c/0x20)
    [ 1.620952] [<c0b29870>] (omap2_mcspi_driver_init) from [<c010178c>] (do_one_initcall+0x4c/0x178)
    [ 1.683875] spi spi1.2: not using DMA for McSPI (-19)
    [ 1.689173] spidev spi1.2: buggy DT: spidev listed directly in DT
    [ 1.699970] WARNING: CPU: 0 PID: 1 at drivers/spi/spidev.c:757 spidev_probe+0x1ac/0x1cc
    [ 1.770524] [<c012d418>] (warn_slowpath_null) from [<c0586338>] (spidev_probe+0x1ac/0x1cc)
    [ 1.778846] [<c058618c>] (spidev_probe) from [<c0582b48>] (spi_drv_probe+0x84/0xb4)
    [ 1.793295] [<c0582ac4>] (spi_drv_probe) from [<c051c978>] (driver_probe_device+0x20c/0x2b8)
    [ 1.888372] [<c0519820>] (device_add) from [<c0583cc0>] (spi_add_device+0xa4/0x13c)
    [ 1.906486] [<c0583c1c>] (spi_add_device) from [<c0584188>] (of_register_spi_device+0x220/0x318)
    [ 1.921003] [<c0583f68>] (of_register_spi_device) from [<c05846e4>] (spi_register_master+0x28c/0x488)
    [ 1.937009] [<c0584458>] (spi_register_master) from [<c0584920>] (devm_spi_register_master+0x40/0x78)
    [ 1.956692] [<c05848e0>] (devm_spi_register_master) from [<c0588f68>] (omap2_mcspi_probe+0x2e0/0x36c)
    [ 1.971644] [<c0588c88>] (omap2_mcspi_probe) from [<c051e478>] (platform_drv_probe+0x58/0xb8)
    [ 2.082576] [<c051e38c>] (__platform_driver_register) from [<c0b2988c>] (omap2_mcspi_driver_init+0x1c/0x20)
    [ 2.095956] [<c0b29870>] (omap2_mcspi_driver_init) from [<c010178c>] (do_one_initcall+0x4c/0x178)

     

    And now I have devices!  Yeah!  /dev/spidev1.1 and /dev/spidev1.2

     

    So to summarize, you need both a "SPI Master Controller Drivers" (in my case OMAP24XX) and a "SPI Protocol Masters" (SPIDEV) enabled in defconfig, and you need to tell it there are enough chip selects out there, and then you get devices in /dev.

     

    Now on to see if I can actually talk to the devices out there...

  • In reply to Nathan Wright:

    Hi,

    Good to know, you have made progress. You can use
    compatible = "rohm,dh2228fv"; to avoid the warning dum that comes above.

    Thanks and Regards,

    Dwarakesh R.

    PathPartner Technology

  • In reply to Dwarakesh R:

    Thanks Dwarakesh, I did do that. I'm still having issues with it though. Check out my post here...

    e2e.ti.com/.../2331287

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.