Handling Interrupt from ONOFF Pin

Showing results for 
Search instead for 
Did you mean: 

Handling Interrupt from ONOFF Pin

Contributor II

What I am trying to achieve is: If ONOFF button is pressed shorter than 5 secs, I will handle interrupt and put the system in sleep mode. For now, I am trying to see a kernel message that says I triggered the interrupt successfully when the button is pressed. I am proceeding from another vendor's basic kernel module example for handling gpio interrupts. I have edited it a little bit:

#include <linux/module.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/gpio.h>

static int irq_number = -1;

irqreturn_t gpio_isr(int this_irq, void *dev_id)
    printk("Interrupt happened at gpio:%d\n", irq_number);
    return IRQ_HANDLED;

static void __exit gpio_interrupt_exit (void)

static int __init gpio_interrupt_init (void)
    int r;
    if (irq_number < 0) {
        printk("Please specify a valid gpio_number\n");
        return -1;
    r = request_irq(irq_number, gpio_isr, 0, 0, 0);
    if (r) {
        printk("failure requesting irq %i\n", irq_number);
        return r;
    return 0;


module_param(irq_number, int, 0);


From what I've read from the Reference Manual, ONOFF pin has IRQ 36, so I enter 36 as my irq_number parameter. After installing module, Linux hangs. I guess I am choosing wrong number that points to a busy pin, so that causes the hang.

Is it possible to handle ONOFF pin's interrupt? If so, how can I do it? Thanks in advance.

Labels (2)
0 Kudos
1 Reply

NXP TechSupport
NXP TechSupport

Hi denizdayan

one can look on patch on

ONOFF button doesn't interrupt 

Best regards
Note: If this post answers your question, please click the Correct Answer button. Thank you!

0 Kudos