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.

Compiler/TDA2SG: gpio irq is not success

Part Number: TDA2SG

Tool/software: TI C/C++ Compiler

pin_desc[i]).pin =4;

gpio_direction_input((pin_desc[i]).pin);
(pin_desc[i]).irq = gpio_to_irq((pin_desc[i]).pin);
printk("(pin_desc[i]).irq:%d###### \r\n",(pin_desc[i]).irq);
//if ((pin_desc[i]).irq)
// disable_irq((pin_desc[i]).irq);
// IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING
iRet[i] = request_irq((pin_desc[i]).irq, gpio_notify_irq,IRQF_TRIGGER_RISING , "gpio_int", &pin_desc[i]);

Hi,my gpio is gpio1_4, irq is 50 ,but  I  find there is no irq in "cat /proc/interupt",  how  can i register the gpio interupt?

  • Hi Zhangc,

    Which is the SDK version & what is the purpose of registering this gpio interrupt?

    Best Regards,
    Keerthy

  • SDK3.07

    i want  to  get  the notify from the IO  Interrupt

  • Hi Zhangc,

    Can you add something like below in the .dts file:

    gpio_irq_test: gpio_irq_test {
            compatible = "ti,gpio-irq-test";
            interrupt-parent = <&gpio1>;
            interrupts = <4 IRQ_TYPE_EDGE_BOTH>;
    };

    Include the below header files wherever you are having your irq handler code:

    #include <linux/interrupt.h>
    #include <linux/of_irq.h>
    #include <linux/of_gpio.h>

    Below is a simple printing IRQ handler:

    static irqreturn_t test_gpio_irq(int irq, void *data)
    {

     static int scan_gpio;
     pr_info("%s: irq %d, val=%d\n", __func__, irq,
     gpio_get_value(scan_gpio));
     return IRQ_HANDLED;
    }

    This is the init code that you can try to insert wherever you are probing it one time:

    int gpio_test_irq_init(void)
    {
     struct device_node *np;
     int irq;
     int ret = 0;
     int pwr_gpio;

     np = of_find_node_by_name(NULL, "gpio_irq_test");

     if (np) {
     pr_info("Initializing gpio irq test\n");
     irq = irq_of_parse_and_map(np, 0);
     printk("irq number is %d\n", irq);
     ret = request_irq(irq, test_gpio_irq,  IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
     "key-gpio", NULL);


     if (ret)
     pr_err("request_irq returns %d\n", ret);
     }

     return ret;
    }

    Let me know if you can test out the irq test code.

    Best Regards,
    Keerthy