cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
260 Views
Registered: ‎09-06-2019

Using a I2C GPIO expander to generate IRQ

Hi, 

In my device tree I have a i2c1 node where I instantiate a child node for a gpio exander as shown here:

	tca6408_u53: gpio@21 {
		compatible = "ti,tca6408";
                //interrupt-parent = <&gpio0>;
                //interrupts = <11 0>;
                //interrupt-controller;
                #interrupt-cells = <2>;
		reg = <0x21>;
		gpio-controller;
		#gpio-cells = <2>;
	};

My question is how do I actually make the link from this gpio expander to an actual interrupt? For example I would like the system to receive an interrupt when say GPIO0 asserts. How could this be done? I'm not sure in this case what exactly would be the interrupt parent. This chip (tca6408) has a interrupt output pin so in order to assign pin 0 as an interrupt would I have to route the TCA6408's interrupt back into the GIC as well as assign the tca6408_u53 node as an interrupt controller? 

For example say I route back the tca6408_u53 interrupt pin to GIC pin 1 and would like the processor to trigger on the rising edge of tca6408_u53 GPIO0. I want to say my device tree will look like the following:

// expander instantiation here
&i2c1{	
                tca6408_u53: gpio@21 {
		     compatible = "ti,tca6408";
                     interrupt-parent = <&gic>;
                     interrupts = <1 0>;
                     interrupt-controller;
                     #interrupt-cells = <2>;
		     reg = <0x21>;
		     gpio-controller;
		     #gpio-cells = <2>;
	};
};

// reference to gpio controller as interrupt
&some_node {
                     ...
                     interrupt-parent = <&tca6408_u53>;
                     interrupts = <1 0>;
                     ...
}

Another question I have is what is the best method to refer to an interrupt of this type from the user space? If a pin on the TCA asserts as an interrupt what is the best way to link this interrupt to a driver or application?


Thanks!

Tags (3)
0 Kudos