How to enable SPI Chipselects in Linux

I’m trying to communicate between HPS(master) and FPGA(slave) using the SPI-Bus. In Qsys I can see 4 chip select signals but in the Linux environment I can only see one (spidevX.0). A closer look in my .dts-file tells 4 chipselects to the Kernel(4.1), so where are the other three?

Regards,

Aeromaritime

Hi,
Do you have added a device in your *.dts for each of your SPI devices?
I’m not sure, but when you add a sub-device in the entry of the SPI interface, you can add a “reg” property which define the CS signal…
By implementing a spi module, the “struct spi_device” include the information of the used CS.

Yes you’re right, thank you for pointing me into the right direction, I’ll add my configuration for 4 chipselects as an example for the ones searching too.

	hps_0_spim0: spi@0xfff00000 {
		compatible = "snps,dw-spi-mmio-15.1", "snps,dw-spi-mmio", "snps,dw-apb-ssi";
		reg = <0xfff00000 0x00000100>;
		interrupt-parent = <&hps_0_arm_gic_0>;
		interrupts = <0 154 4>;
		clocks = <&spi_m_clk>;
		#address-cells = <1>;	/* embeddedsw.dts.params.#address-cells type NUMBER */
		#size-cells = <0>;	/* embeddedsw.dts.params.#size-cells type NUMBER */
		bus-num = <0>;	/* embeddedsw.dts.params.bus-num type NUMBER */
		num-chipselect = <4>;	/* embeddedsw.dts.params.num-chipselect type NUMBER */
		status = "okay";	/* embeddedsw.dts.params.status type STRING */

		spidev01: spidev@01 {
			compatible = "spidev";	/* appended from boardinfo */
			reg = <0>;	/* appended from boardinfo */
			spi-max-frequency = <100000000>;	/* appended from boardinfo */
			enable-dma = <1>;	/* appended from boardinfo */
		}; //end spidev@01 (spidev01)
		spidev02: spidev@02 {
			compatible = "spidev";	/* appended from boardinfo */
			reg = <1>;	/* appended from boardinfo */
			spi-max-frequency = <100000000>;	/* appended from boardinfo */
			enable-dma = <1>;	/* appended from boardinfo */
		}; //end spidev@02 (spidev02)
		spidev03: spidev@03 {
			compatible = "spidev";	/* appended from boardinfo */
			reg = <2>;	/* appended from boardinfo */
			spi-max-frequency = <100000000>;	/* appended from boardinfo */
			enable-dma = <1>;	/* appended from boardinfo */
		}; //end spidev@03 (spidev03)
		spidev04: spidev@04 {
			compatible = "spidev";	/* appended from boardinfo */
			reg = <3>;	/* appended from boardinfo */
			spi-max-frequency = <100000000>;	/* appended from boardinfo */
			enable-dma = <1>;	/* appended from boardinfo */
		}; //end spidev@04 (spidev04)
	}; //end spi@0xfff00000 (hps_0_spim0)
1 Like