Interrupt handler is not working in MPC 8323 RDB

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interrupt handler is not working in MPC 8323 RDB

848 Views
gangadharrao
Contributor II

I am adding below mentioned module into linux kernel.But CPU gets hanged when External interrupt is enabled.please suggest changes in the module


#include <linux/kernel.h> 
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h> 
#include <linux/irq.h> 
#include <asm/io.h>
unsigned char modname[] = "UART";


irqreturn_t irq_handler(int irq, void *dev_id, struct pt_regs *regs)
{

      printf("irq_handler");
      return IRQ_HANDLED;
}


static int __init uart_init(void) /* Constructor */
{
return request_irq(6,irq_handler,IRQF_SHARED, modname, &modname);
}

void cleanup_module()
{

free_irq(6, NULL);
}


MODULE_LICENSE("GPL");

0 Kudos
1 Reply

651 Views
Pavel
NXP Employee
NXP Employee

Look at recommendations below for the MPC823x_RDB LTIB Linux BSP.

Linux makes no difference between external and internal interrupts. All interrupts in the system are handled by the same Linux API. If this API didn't work, no driver in the system would be able to operate, not just your customer's module.

 

The customer is attempting to request an IRQ by the resource number which is generally incorrect. The resource number is an index to irq_desc table.

This index is generally _not_equal to the hardware IRQ line number. See Documentation/IRQ.txt for explanation.

To request an IRQ line in a proper way, the customer should:

 

  1. Declare the IRQ properly in the DTS. Refer to /Documentation/powerpc/booting-without-of.txt for details. The value of the "interrupt"

property is calculated by the following

   formula:

  

   [DTS_interrupt_number] = ([EIVPR/IIVPR_addr] - [Interrupt_Source_Configuration_Registers_Base]) / 0x20

 

                where [EIVPR/IIVPR_addr] is the address of the interrupt configuration registers

                of the IRQ being declared, [Interrupt_Source_Configuration_Registers_Base]

                is 0x50000 for P1010

  

  1. Request the interrupt property from the Open Firmware in the driver.

 

  1. Map the interrupt to the resource ID. This can be done by of_irq_to_resource() or by irq_of_parse_and_map().

  

  1. Request the interrupt by the resource number.

 

All steps above are performed by _any_ device driver in the system. Just look how it is done in e.g. drivers/net/gianfar.c or  drivers/spi/fsl_espi.c

and do the same in your code.

 

Look at also attached file. It is common method for interrupt handling under Linux.

Check your code using this document.


Have a great day,
Pavel Chubakov

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

0 Kudos