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.

ISR for nmi is not working

Hi friends,

      I am working on starter Kit with SDKv7. I wrote one handler.c file I am able to build it but while inserting it

      as a module I am getting problem.

////////////////////////////////  code part ///////////////////////////////////////////////////////////////////

result = request_irq(External_nmi, (irq_handler_t) extn_irq_handler, IRQF_DISABLED, "EXTn_irq_handler", NULL);
    if(result)
    {
        printk(KERN_INFO "Failed to get requested interrupt");
        return 0;
    }

////////////////////////////////////////////////////////////////////////////////////////////////////////

 request_irq( ) function is not returning '0'.

so getting Failed to get requested interrupt. When this situation arises??


I am using NMI interrupt pin(irq num = 7) also given on Kit as a SW6.
Want to toggle LED D2 which is on GPIO1_5 inside handler, but not able to give exact base address of this PIN.

I find base address of GPIO1 is 0x4804_C000 to 0x4804_CFFF. but don't know how to drive exact address for
Particular pin.


Please suggest me the solutions

 

Thanks in advance,

Vishal.

  • Hi,

      I am attaching one sample handler.c  file by following this I am writing my Handler.c File.

      Please check it and suggest me the solution.

    #include <linux/kernel.h>
    #include <linux/module.h>               // for Module init & exit functions
    #include <linux/interrupt.h>           /*!We want an interrupt */
    #include <mach/gpio.h>
    
    
    #include <linux/fs.h>
    #include <linux/slab.h>
    #include <linux/init.h>
    #include <linux/list.h>
    #include <linux/smp_lock.h>
    #include <asm/uaccess.h>
    #include <linux/sched.h>
    #include <linux/workqueue.h>
    #include <linux/delay.h>
    #include <asm/io.h>
    #include <linux/vmalloc.h>
    #include <linux/mm.h>
    
    
    /*!******************************Defines section ******************************/
    
    
      #define External_nmi  7
    
    
      unsigned long irq_cnt = 0;
      unsigned char irq_flag = 0;
      unsigned long int cnt_intr;
    
    
    irqreturn_t extn_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
    
    
    /*!***********************End of Prototype section*****************************/
    
    
    
    
    irqreturn_t extn_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
    {
    
       // Want to toggle LED.
       //for this need information of LED PIN base address
        
        return IRQ_HANDLED;
    }
    
    int init_module()
    {
            int result      = 0;
            int short_int   = 0;
    
    
            printk(KERN_INFO "External Interuppt initialized\n");
      /*******************************************************************************************************************************/
             int request_irq(unsigned int irq, irqreturn_t(*handler)(int, void*, struct pt_regs*), unsigned long flag, const char *dev_name,
                          void *dev_id);
    
              0 is return if request_irq() success, or negative error code if fails.
    
                  unsigned int irq:                      Interrupt num to be requested
                  irqreturn_t(*handler)(int, void*, struct pt_regs*): Pointer to the handler function to be installed
                  unsigned long flag: SA_INTERRUP,SA_SHIRQ,SA_SAMPLE_RANDOM.                   
                  const char *dev_name: string pass to request_irq()func used in /proc/interrupts to show owner of interrupt
                  void *dev_id : pointer used to share interrupt line, if interrupt is not shared dev_id can be set to NULL.
    
    
       /*******************************************************************************************************************************/
            
              result = request_irq(External_nmi, (irqreturn_t) extn_irq_handler,IRQF_DISABLED,"EXTn_irq_handler", NULL);
    
     
    
           if(result)
             {
                printk(KERN_INFO "Failed to get requested interrupt");
             }
            
           else
    
             outb(); // enable interrupt reporting 
             
       return ret;
    }
    
    /*
     * Cleanup
     */
    void cleanup_module()
    {
      free_irq(extn_irq_handler, NULL);
            
    }
    
    MODULE_LICENSE("GPL");

  • Have you checked if this interrupt isn't already taken by another handler?

  • Hi Biser,

       I don't know where to find it in code but, on schematic of Starter Kit I find out that on NMI (AM335x_EXTINT) pin

       input is coming from two sources, SW5 and AR8031_AL1A IC (ETH1_INTn signal). But in code on which files 

       I will get information about it.

      Regards,

      Vishal

  • Hi,

      Please guide me further. Waiting for response.

     Regards,

     Vishal.

  • Have you been answered someone? I have same problem and I've got that NMI irq is busy of irq. module. We need some API for catch or get irq for handling in our software.