How to implement "#interrupt-cells = <2>" for a gpiochip?

From: Daniel Santos
Date: Mon Oct 29 2018 - 22:47:51 EST


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:Â

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-cells = <2>;

#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
property. This is a empty, boolean property. An additional
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?