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.

GPIO0 IRQF_SHARED query

Hi,

I am working with a DM368 based custom board. we have touch and keypad interfaced to the DM368.

we have interfaced the interrupt pin of touch and keypad to DM368 GPIO0 pin only, due to the shortage of GPIO pins in our system design.

we have programmed the gpio irq as edge trigger falling edge.

we have used the IRQF_SHARED flag in the request_irq, please find the syntax below.

Keypad:

request_irq(priv->irq, keypad_irq_handler_func, IRQF_SHARED, "DM36x_CM_INPUT0", priv);

Touch:

request_irq(priv->irq, touch_irq_handler_func, IRQF_SHARED, "DM36x_CM_INPUT1", priv);

when user do a key press or touch the screen the gpio is pulled low triggering the irq.

but the control is going to both the irq handler functions ( keypad and touch) even though i pressed only for keypad and similar behaviour to touch press also.

I need to have the control going to only one irq handler  that is if i press a key the control needs to go to keypad_irq_handler_func

and similarly if i do a touch the control needs to go touch_irq_handler_func.

please suggest what changes i need to make in request_irq to get this desired behaviour.

Thank you, Sreedhar.

  • Hi Sreedhar,

    This is normal behavior. I am copy pasting one paragraph from "Linux Device Drivers, 3rd edition" book:

     

    Whenever two or more drivers are sharing an interrupt line and the hardware interrupts the processor on that line, the kernel invokes every handler registered for that

    interrupt, passing each its own

     

    dev_id. Therefore, a shared handler must be able to recognize its own interrupts and should quickly exit when its own device has not

    interrupted. Be sure to return

     

    IRQ_NONE whenever your handler is called and finds that the device is not interrupting.

    Regards, Sudhakar

  • Hi,

    We have one each separate irq handlers for keypad and touch.

    the dev_id is the different for keypad and touch.

    when i do a keypress it is going to the keypad handler and also to the touch handler as expected.

    the dev_id values when i print it is the corresponding values.

    suppose keypad dev_id = 0xC27E7420 and for touch dev_id = 0xC27E7620

    in keypad handler its value is 0xC27E7420 and in touch handler it is 0xC27E7620

    how can we differentiate the source of intterupt, because dev_id are the corresponding ones.

    please suggest how to resolve this problem.

    Thank you, Sreedhar.

     

  • Hi,

    You need to read the Interrupt status register to find out whether the interrupt is for the particular peripheral or not.

    Regards, Sudhakar

  • Hi Sudhakar,

    Thanks, i understood the concept.

    -Sreedhar.