Project

General

Profile

Virtual SPI device setup and access using spidev

Added by Gianni Casonato about 3 years ago

Hi,
I'm trying to simulate with SW a SPI device (I don't have the HW) defining a dummy device to be accessed from user space using spidev (or a modified version).
I've tried several options for defining the SPI device in the dev-tree (dts file), but no way up to now, i.e. the system boots but when I load spidev module nothing happens in the /dev, no /dev/spidevX.Y appear...

Note that I've enabled SPI controller in the kernel and rebuild and reinstalled it in the SD.

Any suggestion??

Thanks in advance,
Gianni


Replies (6)

RE: Virtual SPI device setup and access using spidev - Added by Jonathan Cormier about 3 years ago

Gianni Casonato wrote:

Hi,
I'm trying to simulate with SW a SPI device (I don't have the HW) defining a dummy device to be accessed from user space using spidev (or a modified version).

Okay so you've created a custom driver based on spidev to simulate a device. Neat.

I've tried several options for defining the SPI device in the dev-tree (dts file), but no way up to now, i.e. the system boots but when I load spidev module nothing happens in the /dev, no /dev/spidevX.Y appear...

Could you include the section of the dts you modified?

Note that I've enabled SPI controller in the kernel and rebuild and reinstalled it in the SD.

What version of the kernel are you using? What filesystem? Is it running udev?

Any suggestion??

When the module is loaded you might be able to print out the alias that the driver is registering as in an attempt to see what name you need to put in the dts. Not exactly sure if this works.

root@mityomapl138:/sys# find /sys/ -name modalias
/sys/devices/platform/edma/modalias
/sys/devices/platform/watchdog/modalias
/sys/devices/platform/serial8250.0/modalias
/sys/devices/platform/i2c_davinci.1/modalias
/sys/devices/platform/i2c_davinci.1/i2c-1/1-0048/modalias
/sys/devices/platform/i2c_davinci.1/i2c-1/1-0050/modalias
/sys/devices/platform/davinci_nand.1/modalias
/sys/devices/platform/spi_davinci.1/modalias
/sys/devices/platform/spi_davinci.1/spi_master/spi1/spi1.0/modalias
/sys/devices/platform/spi_davinci.1/spi_master/spi1/spi1.1/modalias
/sys/devices/platform/omap_rtc/modalias
/sys/devices/platform/cpuidle-davinci.0/modalias
/sys/devices/platform/pm-davinci/modalias
/sys/devices/platform/ahci/modalias
/sys/devices/platform/pruss_uio/modalias
/sys/devices/platform/davinci_mmc.0/modalias
/sys/devices/platform/ohci.0/modalias
/sys/devices/platform/i2c_davinci.2/modalias
/sys/devices/platform/alarmtimer/modalias
/sys/devices/platform/serial8250/modalias
/sys/devices/platform/cpufreq-davinci/modalias
/sys/devices/platform/davinci_mdio.0/modalias
/sys/devices/platform/davinci_emac.1/modalias
/sys/devices/fpga_ctrl/8/spi_master/spi3/spi3.0/modalias
/sys/devices/fpga_ctrl/8/spi_master/spi3/spi3.2/modalias

root@mityomapl138:/sys# find /sys/ -name modalias  -exec cat {} +
platform:edma
platform:watchdog
platform:serial8250
platform:i2c_davinci
i2c:tps65023
i2c:24c02
platform:davinci_nand
platform:spi_davinci
m25p80
mcp2515
platform:omap_rtc
platform:cpuidle-davinci
platform:pm-davinci
platform:ahci
platform:pruss_uio
platform:davinci_mmc
platform:ohci
platform:i2c_davinci
platform:alarmtimer
platform:serial8250
platform:cpufreq-davinci
platform:davinci_mdio
platform:davinci_emac
spidev
spidev

In the past when struggling to get a driver to install, i've had to add print statements in the kernel where it does the comparisons to see if it loads a certain driver. I don't recall where that was though..

RE: Virtual SPI device setup and access using spidev - Added by Gianni Casonato about 3 years ago

Trying to make the SPI working I've tested several options, found in Internet and in this Forum too, both adding the SPI devices in the soc node, like here below (I've used the "compatible" set to rohm,dh2228fv for connecting to spidev but no way)

            spi@0x0060 {
                compatible = "altr,spi-15.1", "altr,spi-1.0";
                #address-cells = <0x1>;
                #size-cells = <0x0>;
                reg = <0x60 0x20>;
                interrupts = <0x0 0x33 0x4>;
                num-chipselect = <0x1>;
                status = "okay";

                spidev@0x0 {
                    compatible = "spidev", "rohm,dh2228fv";
                    #address-cells = <0x1>;
                    #size-cells = <0x0>;
                    reg = <0x0>;
                    spi-max-frequency = <0x5f5e100>;
                    enable-dma = <0x1>;
                };
            };

            spi@0x0040 {
                compatible = "altr,spi-15.1", "altr,spi-1.0";
                #address-cells = <0x1>;
                #size-cells = <0x0>;
                reg = <0x40 0x20>;
                interrupts = <0x0 0x28 0x4>;
                num-chipselect = <0x2>;
                status = "okay";
            };

or as a standalone node at the bottom of the dts, like for example

&spi0 {
    status = "okay";

    spidev@0 {
        /* spidev causes a WARN_ON() so spoof with DAC compat */
        compatible = "rohm,dh2228fv";
        reg = <0>;    /* chip select */
        spi-max-frequency = <1000000>;
        enable-dma = <1>;
    };
    spidev@1 {
        /* spidev causes a WARN_ON() so spoof with DAC compat */
        compatible = "rohm,dh2228fv";
        reg = <1>;    /* chip select */
        spi-max-frequency = <1000000>;
        enable-dma = <1>;
    };
};

Both of them has failed.

I'm using a MitySOM-5CSX Altera SOCFPGA Cyclone V board with kernel version 3.16.0-g9cf65cd-dirty.
The filesystem is ext3 and udev deamon is running.

RE: Virtual SPI device setup and access using spidev - Added by Jonathan Cormier about 3 years ago

Gianni Casonato wrote:

Trying to make the SPI working I've tested several options, found in Internet and in this Forum too, both adding the SPI devices in the soc node, like here below (I've used the "compatible" set to rohm,dh2228fv for connecting to spidev but no way)
[...]

or as a standalone node at the bottom of the dts, like for example
[...]

Both of them has failed.

I'm using a MitySOM-5CSX Altera SOCFPGA Cyclone V board with kernel version 3.16.0-g9cf65cd-dirty.
The filesystem is ext3 and udev deamon is running.

Ahh this explains my confusion as this is the MityDSP-L138 forums which has no dts supported kernel.

There is fairly recent post asking about spi and spidev on the socfpga forumns. https://support.criticallink.com/redmine/boards/45/topics/5239?r=5289#message-5289

RE: Virtual SPI device setup and access using spidev - Added by Daniel Vincelette about 3 years ago

Hello Gianni,

Sorry about the confusing before. Would you mind posting your entire altered DTS?

Thank you!

Dan

RE: Virtual SPI device setup and access using spidev - Added by Gianni Casonato about 3 years ago

Sorry for the wrong Forum...
I've moved the discussion in the correct one now - MitySOM-5CSX Altera Cyclone V - using same message name.
I've posted there the dts I've been using.

Gianni

    (1-6/6)
    Add picture from clipboard (Maximum size: 500 MB)