This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x: Assigning interrupt to a GPIO via DTS

Hello All,


I am having trouble figuring out how to assign IRQ2 to GPIO3_17 in my DTS file as a shared low level interrupt. Our hardware is basically a BeagleBoneBlack with an external DUART attached that will be using GPIO3_17 as its interrupt signal to the processor. Could anyone point me in the right direction or share any sample code that I can use as a reference? We are using kernel version 3.12.

Thanks in advance for any help - Anthony

  • For reference, this is what I have added so far. I added this right after the uart definitions in the am33xx.dtsi. The duart is at address ox01000000 (CS1).

            uart6: serial@01000000 {
                device_type = "serial";
                compatible = "ns16550";
                ti,hwmods = "uart7";
                clock-frequency = <7372800>;
                reg = <0x01000000 0x8>;
                interrupt-parent = <&gpio3>;
                interrupts = <17 1>;
                status = "disabled";
            };

    I did not touch the gpio3 node, but here it is below in case something needs to be changed:

            gpio3: gpio@481ae000 {
                compatible = "ti,omap4-gpio";
                ti,hwmods = "gpio4";
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-controller;
                #interrupt-cells = <2>;
                reg = <0x481ae000 0x1000>;
                interrupts = <62>;
            };

  • For configuring the interrupt as active low level-sensitive, you need to set the second cell of the "interrupts" member to 0x8. For more information about this, read <kernel_dir>/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt.

    Another useful reading: http://www.devicetree.org/Device_Tree_Usage#How_Interrupts_Work


    Best regards,
    Miroslav

  • Thanks Miroslav. I have read the documents you mentioned. Still a few things that Im a bit unclear on. For uart0, the linux console, I also see the following in am335x-bone-common:

        uart0_pins: pinmux_uart0_pins {
            pinctrl-single,pins = <
                0x170 (PIN_INPUT_PULLUP | MUX_MODE0)    /* uart0_rxd.uart0_rxd */
                0x174 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)    /* uart0_txd.uart0_txd */
            >;
        };


    and:

    &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_pins>;

        status = "okay";
    };


    It appears that these sections are needed since uart0 uses tx/rx pins straight off the processor. For an external uart, can I omit these sections completely? Seems that I can definitely omit "uart0_pins: pinmux_uart0_pins" node. But should I keep the "&uart0" node since it contains the line:

    status = "okay"

    In my uart6 node in the original post the status is set to status = "disabled", so Im wondering if I need this status = "okay" somewhere in the dts to enable the port.

    Also, is there any easy way to know how my new serial port will look in the /dev directory once linux boots? Just want to know what to look for to see if my serial port is there. My kernel boots with the linux console at /dev/ttyO0. There is also /dev/ttyS0-S3. Not sure where these are coming from.

    Thanks for your help - Anthony

  • As far as I can see in the documentation, the "status" property is used to check if a device is ready for use. Check here: http://lxr.free-electrons.com/source/drivers/of/base.c?v=3.12#L395

    /**
     *  __of_device_is_available - check if a device is available for use
     *
     *  @device: Node to check for availability, with locks already held
     *
     *  Returns 1 if the status property is absent or set to "okay" or "ok",
     *  0 otherwise
     */
    static int __of_device_is_available(const struct device_node *device)
    {
        const char *status;
        int statlen;

        status = __of_get_property(device, "status", &statlen);
        if (status == NULL)
            return 1;

        if (statlen > 0) {
            if (!strcmp(status, "okay") || !strcmp(status, "ok"))
                return 1;
        }

        return 0;
    }

    My knowledge on your second question is limited, sorry.

    Best regards,
    Miroslav