linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to implement "#interrupt-cells = <2>" for a gpiochip?
@ 2018-10-30  2:46 Daniel Santos
  0 siblings, 0 replies; only message in thread
From: Daniel Santos @ 2018-10-30  2:46 UTC (permalink / raw)
  To: LKML, linux-devicetree; +Cc: John Crispin

Hello,

I'm trying to use a GPIO as an interrupt on an mt7620 (using OpenWRT
drivers) and I can't seem to figure out how to glue my two-celled
interrupt description (including the trigger) to the device tree code. 
This is the gpio driver I'm using: 
https://github.com/openwrt/openwrt/blob/master/target/linux/ramips/patches-4.14/0027-GPIO-MIPS-ralink-add-gpio-driver-for-ralink-SoC.patch

And this is the gpio chip in the device tree:

		gpio0: gpio@600 {
			compatible = "ralink,mt7620a-gpio", "ralink,rt2880-gpio";
			reg = <0x600 0x34>;

			resets = <&rstctrl 13>;
			reset-names = "pio";

			interrupt-parent = <&intc>;
			interrupts = <6>;

			interrupt-controller;
			#interrupt-cells = <2>;

			gpio-controller;
			#gpio-cells = <2>;

			ralink,gpio-base = <0>;
			ralink,num-gpios = <24>;
			ralink,register-map = [ 00 04 08 0c
						20 24 28 2c
						30 34 ];
		};


I've added the "interrupt-controller;" and "#interrupt-cells" myself. 
This is my i2c device:

&i2c {
	status = "okay";

	imu: lsm6ds3@6b {
		compatible = "st,lsm6ds3";
		reg = <0x6b>;
		interrupt-parent = <&gpio0>;
		interrupts = <14 IRQ_TYPE_EDGE_FALLING>;
	};
};


The problem is that when the driver probes and asks what the trigger for
the irq is, it returns zero instead of 2 (IRQ_TYPE_EDGE_FALLING).  I
presume this is because the two-celled interrupts aren't implemented by
the gpio driver? 
Documentation/devicetree/bindings/interrupt-controller/interrupts.txt says:

A device is marked as an interrupt controller with the
"interrupt-controller"
property. This is a empty, boolean property. An additional
"#interrupt-cells"
property defines the number of cells needed to specify a single interrupt.

It is the responsibility of the interrupt controller's binding to define the
length and format of the interrupt specifier. The following two variants are
commonly used:
...

However, I'm having great trouble finding documentation on how to write
these bindings. Can anybody give me a pointer please?

Thanks,
Daniel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-10-30  2:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-30  2:46 How to implement "#interrupt-cells = <2>" for a gpiochip? Daniel Santos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).