Linux Device Tree Help (GPIO controller/interrupts)

nigp4w rudy picture nigp4w rudy · May 6, 2014 · Viewed 15.3k times · Source

I've been learning about linux device trees and we've been trying to start porting some of our older code to use them. I'm having a little bit of trouble with the gpio controller node:

gpio1: gpio-controller@c00 {
    #gpio-cells = <2>;
    compatible = "cavium,octeon-3860-gpio";
    reg = <0xc00 0x100>;
    gpio-controller;
    /* Interrupts are specified by two parts:
     * 1) GPIO pin number (0..15)
     * 2) Triggering (1 - edge rising
     *                2 - edge falling
     *                4 - level active high
     *                8 - level active low)
     */
    interrupt-controller;
    interrupt-cells = <2>;
    interrupts = <0 24>, <1 25>, <2 26>, <3 27>;

};

I'm trying to map certain IRQs to GPIO pins, however, it looks like its only ever mapping the first one <0 24> IRQ 24 to gpio pin 0. I looked at the source code and it doesnt seem like it will ever interate of 'interrupts', though the device tree bindings text file seems to hint that it will (devicetree/bindings/gpio/cavium-octeon-gpio.txt). Does anyone know how i can map a handful of interupts to different gpio pins?

Answer

Joshua Clayton picture Joshua Clayton · Jan 5, 2015

gpio handling is still not 100% the same between platforms, so I'll give you the gist of it, and you may need to adapt to your platform (find a dts that uses the same or similar SoC). My platform is Freescale imx.6 Here this is the gist of it:

First: Leave gpio1 node alone. (It is probably set up correctly in the dtsi you got from your upstream vendor)

Second: If you want .e.g. gpio 1 15 to be an interrupt, active high in the device node you want to consume the gpio interrupt, add

interrupt-parent = <&gpio1>;
interrupts = <15 IRQ_TYPE_LEVEL_HIGH>;

for example: from arch/arm/boot/dts/imx6qdl-gw52xx.dtsi

touchscreen: egalax_ts@04 {
        compatible = "eeti,egalax_ts";
        reg = <0x04>;
        interrupt-parent = <&gpio7>;
        interrupts = <12 2>;
        wakeup-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
};