How to set device tree lpspi0 to use a cs decoder with 3 spi device connected

Hello, we have the SPI0 connected to three ADC devices with a chipselect decoder that controls 3 output with 2 inputs cs (we use the two native cs pins). This is our schematic:

1664-spi.png

So we need to use the three spi devices with the logic of the decoder.
I tried with the device tree param: is-decoded-cs= <1>; and num-cs= <3>;
as described in many web examples but it doesn’t work:

this is our device tree configuration:

&lpspi0 {
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_lpspi0>;
	status = "okay";
	is-decoded-cs = <1>;
	fsl,spi-num-chipselects = <3>; 
	num-cs = <3>;
	
	/*cs-gpios = <&gpio3 5 0>, <&gpio3 6 0>;*/
	/*cs-gpios = <0>, <1>;*/
	
	mcp3x0x@0 {
		reg = <0>;
		compatible = "microchip,mcp3208";
		spi-max-frequency = <1000000>;
	};

	mcp3x0x@1 {
		reg = <1>;
		compatible = "microchip,mcp3208";
		spi-max-frequency = <1000000>;
	};

	mcp3x0x@2 {
		reg = <2>;
		compatible = "microchip,mcp3208";
		spi-max-frequency = <1000000>;
	};
};

We also tryed with cs-gpios = <&gpio3 5 0>, <&gpio3 6 0>; but it give error with the num of chip select.

here is our pinctrl:

/* Apalis SPI1 */
		pinctrl_lpspi0: lpspi0grp {
			fsl,pins = <
				SC_P_SPI0_SCK_DMA_SPI0_SCK		0x0600004c
				SC_P_SPI0_SDO_DMA_SPI0_SDO		0x0600004c
				SC_P_SPI0_SDI_DMA_SPI0_SDI		0x0600004c
				SC_P_SPI0_CS0_DMA_SPI0_CS0		0x0600004c
				SC_P_SPI0_CS1_DMA_SPI0_CS1		0x0600004c
			>;
		};

many thanks. Elia

Hi @MarcoGestri

So we need to use the three spi devices with the logic of the decoder. I tried with the device tree param: is-decoded-cs= ; and num-cs= ; as described in many web examples but it doesn’t work:

Which web examples are you talking about?

There are two solutions for your problem. To address the correct Spi Adc Chipselect

  1. Either you switch the input cs pins manually in your code
  2. or you write a decoder kernel driver which can be configured using devicetree.

Best regards, Jaski