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.

REQUEST_IRQ fails when tried to register an IRQ for GPIO[OMAP L138]

 Dear All , Can anyone please help me to understand why request_irq is failing

I am using OMAP L138 [ARM with LINUX ]

REQUEST_IRQ always fails with EINVAL..

Please note that i am trying to configure an GPIO in LINUX as an INTERRUPT pin . 
To do this the very first step is failing .PLease find the below code :-

return_value = request_irq(48,gpio_intr_handler,NULL,DRIVER_DEV_FILE,NULL);

where :-
1. static irqreturn_t gpio_intr_handler(int irq,void *dev_id)
{
printk("\n\nI am in ISR of GPIO .STATEMENT 1...\n");
return IRQ_HANDLED;
}

2. 48 is the interrupt pin for GPIO Bank 6. 


Can you please guide me where am i going wrong for this .... 
As it is just an plain IRQ register process ...

Also the return value is -22 

Can't i use normal LINUX mechanism for GPIO ... 

Please help me !!!!!!!!!!!!!!!



  • Same driver code is able to do  register IRQ for other INTERRUPT lines :-

    I have checked for :-

     1) 91 Upp

    2) 14EMIF 

    3) INTERRUPT NUMBER 2 ...

    4) INTERRUPT NUMBER 51

    For all the above i could see an entry in /proc/interrupts ....

    But it fails for any interrupt between [42 - 50 ] That is GPIO Interrupt's .....

    Can any one please guide me , if i need to follow some other mechanism to register INTERRUPT ISR for GPIO interrupt ......

    Thanks 

  • Ashish:

    Before requesting irq, we have to call,

    gpio_to_irq function with gpio pin as argument,

    you are doing that step?

    Regards,

    santosh vastrad

  • Hi Santosh , 

    No i was not using that function . I was directly registering the INTERRUPT using REQUEST_IRQ. 

    a) Is it compulsory that i should use this function i.e GPIO_TO_IRQ to resister GPIO interrupt ? 

         Is it like LINUX default mechanism of REQUEST_IRQ wont work for GPIO stuff .Hence for IRQ , we need to get the IRQ using 

        GPIO_TO_IRQ first and then use this as an parameter to REQUEST_IRQ.

    b) Also apart from GPIO configuration , do i need to configure ARM INTERRUPT CONTROLLER to use GPIO an as interrupt 

        Or is it like we just have to configure GPIO . No need to configue any other stuff. 

        

    c) I am not clear for point [b] , but what i understood is we have have to configure ARM interrupt controller apart from GPIO. 

         I am listing my understanding to how i was planning to register the GPIO interrupt :-

         a) I wanted to use GPIO6[2] as an interrupt pin. Hence from TRM i got that on ARM INTERRUPT controller 

              Interrupt number 48 is from GPIO Bank6. Hence i was registering ISR directly on this number. 

              [ Will try with GPIO_TO_IRQ and will update by today evening]. 

         b) Then i was planning to do following configuration for ARM INTERRUPT CONTROLLER  :-

              1. Enable GLOBAL INTERRUPT from GER register.

              2. ENABLE HOST Interrupt from HIER 

              3. MAP the GPIO Bank 6 interrupt to ARM CONTROLLER CHANNEL using CHAN12 [ As GPIO Bank 6 interrupt is 48]

              4. ENABLE SYSTEM Interrupt from ESR2 [ As i need for GPIO bank 6 , for which interrupt is 48]

              5. Then MONITOR  the INTERRUPT using SECR2 [ To check if interrupt has ocurred] 

                    If interrupt has occurred clear the BIT in SECR2 by writing a 1 to corresponding bit. 

              6. Also for testing purpose or we can say simulation , i was planning to write 1 to corresponding bit of SECR2

                  So that , even without HARDWARE INTERRUPT SIGNAL , i can check the functionality.

      

    c) So can you please let me know if my understanding is correct or i am missing any details. 

    d) Also befpre this we have to configure GPIO parameters for DIRECTION and TYPE of INTERRUPT sensing 

         like rising or falling edge ....

    Please help me to figure out the correct mechanism to use GPIO as an interrupt .

    I am working on this stuff for the first time , hence not very sure if my understanding is correct ....

    Thanks

    Ashish

      

  • First,

    Which gpio pin , we want to use, make mux configuration as mode4 ,

    secondly,

    Before interrupt request doing, we have to call

    gpio_to_irq function,

    While calling interrupt request, we have to give rising/falling edge,

    so if gpio toggles, we will get interrupt .

    Follow above steps, is enough!

    Regards,

    santosh vastrad

  • Dear Santosh , 

    It worked without much pain . Thanks for the GUIDANCE. 

    Thank you,

    Ashish 

  • Hi,
    Can you shared the solution?
    I don't understand why gpio don't work as interrupts.

    Thanks,
    Ran