Unable to use spidev and a custom spi driver both at the same time

I have three spi devices. Two uses custom spi drivers , whereas the one uses the spidev drivers.
spi@3210000{ /* SPI1 in 40 pin conn /
status = “okay”;
nvidia,clock-always-on;
cs-gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(Z, 6) 0>, <&tegra_main_gpio TEGRA194_MAIN_GPIO(Z, 7) 0>;
num-cs = < 2 >;
prod-settings {
#prod-cells = <3>;
prod {
prod = <0x04 0x0000003f 0x0f>;
};
};
slb9670: slb9670@0
{
compatible = “infineon,slb9670”;
reg = <0>;/
CE0 */
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <5000000>;
status = “okay”;
controller-data {
nvidia,variable-length-transfer;
nvidia,enable-hw-based-cs;
};
};
spidev@1 {
compatible = “spidev”;
reg = <1>;
spi-max-frequency=<25000000>;
};
};

    spi@3230000 {
    status = "okay";
    spi-max-frequency = <12000000>;
            spifpga@0 {
            compatible = "lfpga-spi";
            reg = <0x0>;
            spi-max-frequency=<25000000>;
            };
    };

When I have spifpga driver and spidev driver included in defconfig file , I get only spidev device node working(/dev/spidev0.1).The spi_fpga init is called but the probe being not called

Whereas when I remove spidev driver, the /dev/spi_fpga2.0 device node is created and working.Any suggestions on making both work at same time ?

How are you setting up that DTB? By changing the source and rebuilding the DTB or by creating a DTB overlay and applying that over the existing DTB?

Look in /sys/firmware/devicetree/base/spi@3230000. If you see more than your spifpg@0 then I suspect you’re using an overlay. Overlays can’t delete nodes so if the spidev nodes are there, check their status. If they’re “okay” then you’ll have to set them to disabled in your overlay. If that doesn’t work, you have have to modify the sources to remove the spidev entries altogether.

Hi gtj,
I am doing it by compiling the dtb in my pc and flashing. Also I suspect the problem is to be with the Image and not the dtb. When I have all these entries in the dtb and only spifpga is enabled in the kernel defconfig, the fpga driver works. But when I enable configs for both the spidev and spi fpga driver in the defconfig and update the dtb , I get only spidev node being created and spi fpga driver probe is not being called, but the init is called.

Hmmm. Did you double check /sys/firmware just to be sure that there were no spidev nodes?
Are the spidev and spifpga drivers compiled as modules (they should be) and what’s the source of spifpga? I can’t find that module in the kernel source tree. What happens if you rmmod both drivers, then modprobe the spifpga driver, then the spidev driver? Actually how are you loading those drivers in the first place? From /etc/modules-load.d?

Hi gtj,
Actually the issue is solved. It was due to the spidev driver and my driver having the same major number and minor number.I have allocated a different major number and the issue got solved.

Thanks for your suggestions.

1 Like

Ah, that’ll do it! :)