Reputation: 41
My question is how to access an SPI slave device from a kernel driver, if that device is already accessed by "spidev" driver.
On the HW level, we've got one SPI Master on the SOC side (Marvell Cetus), one SPI slave (FPGA device) connected to that master on top of a 4-wire SPI bus. So only one SS line is used in the system.
On the SW level, we've got linux kernel 3.10.104, probing device drivers based on the Device Tree Source model.
In our DTS file we've defined one SPI master ("marvell,orion-spi") and one SPI slave ("spidev") on CS (ChipSelect) #0. Trying to add another SPI slave under the same SPI master on the same CS #0 fails - complaining only one slave can be registered to the master on the same CS.
(dmesg: "orion_spi f1010600.spi: chipselect 0 already in use")
spi0: spi@10600 {
status = "okay";
spifpga@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spidev";
reg = <0>;
spi-max-frequency = <25000000>;
};
lattice {
#address-cells = <1>;
#size-cells = <1>;
compatible = "msys_lattice_drv";
reg = <0>;
spi-max-frequency = <25000000>;
};
};
"spidev" is frequently used by our user space processes, we can't remove it. In addition there is a real need to add a new kernel driver for that slave FPGA in order to handle some issues including interrupts in the kernel space.
How can we add another kernel driver handling the same SPI slave device assuming this device is already handled by "spidev" ?
Thanks!
Upvotes: 3
Views: 6437
Reputation: 529
As the other answers allude to, it isn't allowed.
You say you can't remove the spidev device, but is there any reason your new driver can't provide the same functionality that the spidev generic driver does today and then replace the spidev entry in the device tree? It creates the sysFS entry, and allows for basic transfers using the command line, ioctl, and read/write functions. I assume you already have methods to transfer data, so you already have the bulk of what the spidev driver does.
The documentation for the spidev device can be found here.
Upvotes: 0
Reputation: 802
First using compatible = "spidev"
is strongly discouraged in using in device tree because it doesn't describe a real HW device.
spidev is just a generic kernel driver which exports low level API to the userspace
form /dev
interface.
You can't register two drivers for one HW device. Your alternative is to write your own SPI chip (client) driver according to Linux SPI driver model.
Upvotes: 1