How to enable multiple CS on spidev in IMX6ULL

I am modifying the default devicetree using an overlay. I want to enable three CS on spidev.

devicetree:

&pinctrl_ecspi1_cs{
	fsl,pins = <
		MX6UL_PAD_LCD_DATA21__GPIO3_IO26	0x000a0
		MX6UL_PAD_LCD_DATA05__GPIO3_IO10	0x000a0
		MX6UL_PAD_LCD_DATA06__GPIO3_IO11	0x000a0
	>;
};

&ecspi1 {
	status = "okay";
	fsl,spi-num-chipselects = <3>;
	cs-gpios = 
		<&gpio3 26 GPIO_ACTIVE_HIGH>,
		<&gpio3 10 GPIO_ACTIVE_HIGH>,
		<&gpio3 11 GPIO_ACTIVE_HIGH>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_ecspi1_cs>;

		spidev0: spidev@0 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <23000000>;
		status = "okay";
	};
};

GPIO status:

root@colibri-imx6ull:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
 gpio-2   (                    |VCC_USB[1-4]        ) out lo    

gpiochip1: GPIOs 32-63, parent: platform/20a0000.gpio, 20a0000.gpio:

gpiochip2: GPIOs 64-95, parent: platform/20a4000.gpio, 20a4000.gpio:
 gpio-74  (                    |spi_imx             ) in  lo    
 gpio-75  (                    |spi_imx             ) in  lo    
 gpio-90  (                    |spi_imx             ) out hi    

gpiochip3: GPIOs 96-127, parent: platform/20a8000.gpio, 20a8000.gpio:

gpiochip4: GPIOs 128-159, parent: platform/20ac000.gpio, 20ac000.gpio:
 gpio-128 (                    |cd                  ) in  lo IRQ
 gpio-129 (                    |Wake-Up             ) in  lo IRQ
 gpio-130 (                    |id                  ) in  lo IRQ

IOMUX status:

root@colibri-imx6ull:~# cat /sys/kernel/debug/pinctrl/pinctrl-maps | grep -A 6 spi
device 2008000.ecspi
state default
type MUX_GROUP (2)
controlling device 20e0000.iomuxc
group ecspi1grp
function imx6ull-colibri

device 2008000.ecspi
state default
type CONFIGS_PIN (3)
controlling device 20e0000.iomuxc
pin MX6UL_PAD_LCD_DATA20
config 000000a0

device 2008000.ecspi
state default
type CONFIGS_PIN (3)
controlling device 20e0000.iomuxc
pin MX6UL_PAD_LCD_DATA22
config 000000a0

device 2008000.ecspi
state default
type CONFIGS_PIN (3)
controlling device 20e0000.iomuxc
pin MX6UL_PAD_LCD_DATA23
config 000100a0

device 2008000.ecspi
state default
type MUX_GROUP (2)
controlling device 20e0000.iomuxc
group ecspi1_cs_grp
function imx6ull-colibri

device 2008000.ecspi
state default
type CONFIGS_PIN (3)
controlling device 20e0000.iomuxc
pin MX6UL_PAD_LCD_DATA21
config 000000a0

device 2008000.ecspi
state default
type CONFIGS_PIN (3)
controlling device 20e0000.iomuxc
pin MX6UL_PAD_LCD_DATA05
config 000000a0

device 2008000.ecspi
state default
type CONFIGS_PIN (3)
controlling device 20e0000.iomuxc
pin MX6UL_PAD_LCD_DATA06
config 000000a0

spi devices:

root@colibri-imx6ull:~# ls /dev/ | grep spi
spidev0.0

What should I do to configure the other two chip-selects and get spidev0.1 & spidev0.2?

Greetings @toragex,

The following community posts shows roughly the changes you’ll need to do in order to have multiple chip selects under the same spidev: Several chip select on SPI - Technical Support - Toradex Community

In short you’ll need to create multiple spidev nodes under the ecspi node you want to use, one for each CS you plan to add.

Some points to note.

  • Make sure the pins you are using as additional CS are not being used by other interfaces, in which case you’ll need to resolve this conflict.
  • Don’t forget to disable the SPI CAN controller that is enabled by default as described here.

Best Regards,
Jeremias

For anyone else interested, here is my device tree for three SPI CS:

&ecspi1 {
	status = "okay";
	fsl,spi-num-chipselects = <3>;
	cs-gpios = 
		<&gpio3 26 GPIO_ACTIVE_HIGH>,
		<&gpio3 10 GPIO_ACTIVE_HIGH>,
		<&gpio3 11 GPIO_ACTIVE_HIGH>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_ecspi1_cs>;

		spidev0: spidev@0 {
		compatible = "toradex,evalspi";
		reg = <0>;
		spi-max-frequency = <23000000>;
		status = "okay";
	};
		spidev1: spidev@1 {
		compatible = "toradex,evalspi";
		reg = <1>;
		spi-max-frequency = <23000000>;
		status = "okay";
	};
		spidev2: spidev@2 {
		compatible = "toradex,evalspi";
		reg = <2>;
		spi-max-frequency = <23000000>;
		status = "okay";
	};
};

Hi @toragex

Perfect that it works.
Thanks for your valuable feedback.

Best regards,
Jaski