UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 62363

Zynq-7000 Example Design - Interrupt Handler in Linux Driver

Description

This page describes how to create and register an interrupt handler in a device driver.

Solution

You can create your interrupt handler function as a static function pointer in irqreturn_t defined in linux/interrupt.h. 

Here is an example.

static irqreturn_t xilaxitimer_isr(int irq,void*dev_id);

 

To register the interrupt handler, you can use request_irq() defined in linux/interrupt.h. 

In this example, the AXI Timer in PL is connected to IRQ91 through IRQF2P[15].

 

request_irq(91, xilaxitimer_isr, 0, "xilaxitimer", NULL)

 

To unregister the given handler, you can use free_irq().

 

free_irq(91, NULL);

 

Here is an example of interrupt related parameters in the device tree.

 

axi_timer_0: timer@41c00000 {
                  
                                      interrupt-parent = <&ps7_scugic_0>;
                                      interrupts = <0 59 4>;
                  
} ;

 

The attached source code is the AXI Timer driver for interrupt handling.

After you compile the driver, locate the .ko file to a specific directory.

After Linux boots, run this command:

insmod xilaxitimer.ko

 

Then, you will see the following message in the serial console.

zynq> insmod xilaxitimer.ko

xilaxitimer_

init: Initialize Module "xilaxitimer"

xilaxitimer_

init: Registered IRQ 91

xilaxitimer

_init: Set timer count 0xF8000000

zynq> xilaxitimer_isr: Interrupt Occured ! Timer Count = 0xF80001EC

xilaxitime

r_isr: Interrupt Occured ! Timer Count = 0xF8000154

xilaxitim

er_isr: Interrupt Occured ! Timer Count = 0xF800013E

xilaxiti

mer_isr: Interrupt Occured ! Timer Count = 0xF8000143

 

xilaxit

imer_isr: Interrupt Occured ! Timer Count = 0xF8000124

xilaxi

timer_isr: Interrupt Occured ! Timer Count = 0xF8000152

xilax

itimer_isr: Interrupt Occured ! Timer Count = 0xF800015E

xilaxitimer_isr: 100 interrupts have been occurred. Disabling timer

Attachments

Associated Attachments

Name File Size File Type
xilaxitimer.c 4 KB C
AR# 62363
Date Created 10/05/2014
Last Updated 01/22/2016
Status Active
Type General Article
Devices
  • Zynq-7000
Tools
  • Vivado Design Suite - 2014.4
  • Vivado Design Suite - 2014.3
IP
  • Processing System 7