How to use GPIO Expander IO as SPI Interrupts?

Hi ,

We want to use multi SPI devices(up to 8 or 6), so we need 8 gpio as cs signal and 8 gpios as interrupt signal. But the spi register failed with “could not get #gpio-cells for /interrupt-controller@3881000”?

kernel dmesg logs:

[    1.661962] OF: /spi@3210000: could not get #gpio-cells for /interrupt-controller@3881000
[    1.662181] spi-tegra114 3210000.spi: can not register to master err -22
[    1.662559] spi-tegra114: probe of 3210000.spi failed with error -22

Can you give some help about interrupts settings through GPIO Expander?

HW: SPI1(3210000), two GPIO Expander TCA6408
SW: DTS configuration


	i2c@31e0000 {
		tca6408_20: tca6408@20 {
			compatible = "ti,tca6408";
			gpio-controller;
			#gpio-cells = <2>;
			reg = <0x20>;
			vcc-supply = <&p2822_vdd_1v8_cvb>;
			cs_outlow {
				/*
				 * GPIO-0 : CS1
				 * GPIO-1 : CS2
				 * GPIO-2 : CS3
				 * GPIO-3 : CS4
				 * GPIO-4 : CS5
				 * GPIO-5 : CS6
				 * GPIO-6 : CS7
				 * GPIO-7 : CS8
				 */
				gpio-hog;
				gpios = <0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0>;
				output-low;
				label = "cs1",
					"cs2",
					"cs3",
					"cs4",
					"cs5",
					"cs6",
					"cs7",
					"cs8";
			};
			cs_outhigh {
				status = "disabled";
			};
			cs_input {
				status = "disabled";
			};
		};
		
		tca6408_21: tca6408@21 {
			compatible = "ti,tca6408";
			reg = <0x21>;
			gpio-controller;
			#gpio-cells = <2>;
			interrupt-controller;
			#interrupt-cells = <2>;
			vcc-supply = <&p2822_vdd_1v8_cvb>;
			int_outlow {
				status = "disabled";
			};
			int_outhigh {
				status = "disabled";
			};
			? How to configure interrupts ?
		};
	};
		
	spi@3210000 {
		status = "okay";
		compatible = "nvidia,tegra186-spi";
		cs-gpios = <&tca6408_20 0 >,
		           <&tca6408_20 1 >,
		           <&tca6408_20 2 >,
		           <&tca6408_20 3 >,
		           <&tca6408_20 4 >,
		           <&tca6408_20 5 >,
		           <&tca6408_20 6 >,
		           <&tca6408_20 7 >;
				   
		spidev0: spidev@0 {
			compatible = "microchip,mcp28xd";
			status = "okay";
			reg = <0x0>;
			interrupt-parent = <&tca6408_21>;
			interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
			spi-max-frequency = <20000000>;
			controller-data {
				nvidia,cs-setup-clk-count = <0xF>;
				nvidia,cs-hold-clk-count = <0xF>;
				nvidia,tx-clk-tap-delay = <0x7>;
				nvidia,rx-clk-tap-delay = <0x0>;
			};
		};
		spidev1: spidev@1 {
			compatible = "microchip,mcp28xd";
			status = "okay";
			reg = <0x1>;
			interrupt-parent = <&tca6408_21>;
			interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
			spi-max-frequency = <20000000>;
			controller-data {
				nvidia,cs-setup-clk-count = <0xF>;
				nvidia,cs-hold-clk-count = <0xF>;
				nvidia,tx-clk-tap-delay = <0x7>;
				nvidia,rx-clk-tap-delay = <0x0>;
			};
		};
	};

Hi NV_Team,

Can anyone help me to check about this issue?

Thanks

Check the INT pin connect to Tegra which GPIO and add the interrupt-parent = <&tegra_main_gpio>; and interrupts = <> in the tca6408_2x scope.

Hi ShaneCCC,

I don’t need add interrupt to tca6408, and now the 8 io of tca6408 expand success.
I want to use the expand 8 IOs as interrupt for other devices, such as we use the expanded io as an interrupt for SPI devices, and how to configure the interrupt for SPI, just like

interrupt-parent = <&tegra_main_gpio>;
/*HDR PIN22, TEGRA spi3_miso_py1 */
interrupts = <TEGRA194_MAIN_GPIO(M, 1) IRQ_TYPE_LEVEL_LOW>;

Thanks .

I think the tca6408 have INT pin that connect to Tegra for interrupt then you can configure the GPIO of the expander to issue interrupt to the system.

Hi ShaneCCC,

Okay, we will try to test it. Thanks so much.