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!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor snoopy87
Visitor
7,378 Views
Registered: ‎06-18-2014

Zynq: Handle interrupt on Linux

Hi,

 

I'm using the microzed board and I have different source of interrupts (buttons and custom IP) connected to the IRQ_F2P port of my Zynq and I would like to associate a function for each source of interrupts in my C program on Linux.  How I can do that ?

 

Regards,

 

Snoopy

 

0 Kudos
7 Replies
Adventurer
Adventurer
7,358 Views
Registered: ‎10-28-2007

Re: Zynq: Handle interrupt on Linux

You will need to write your own driver, or use 'UIO', Userspace I/O subsystem.

 

http://www.hep.by/gnu/kernel/uio-howto/

 

You will need to add a device in your DTS with compatible set to "generic-uio" and set the interrupts value correctly.

 

 

0 Kudos
Visitor snoopy87
Visitor
7,328 Views
Registered: ‎06-18-2014

Re: Zynq: Handle interrupt on Linux

Hi,

 

It is not possible from linux to interact with the GIC block of the Zynq in order to detect interrupt ? Because in my design I have some interrupt from input of the FPGA and theses inputs are directly connected to GIC block and I have some interrupt from custom IP. With custom IP I can use UIO but for other interrupts how I can detect the interrupt ?

 

Regards,

 

Snoopy

0 Kudos
Scholar milosoftware
Scholar
7,322 Views
Registered: ‎10-26-2012

Re: Zynq: Handle interrupt on Linux

I think don't quite understand your question.

 

Of course you can get interrupts from the GIC in Linux. Delivering interrupts to the PS is the reason the GIC exists, so it would be rather strange if it weren't possible to do just that.

 

Maybe this answers your real question:

You cannot really handle interrupts in a user space program. Interrupts must be handled in kernel context, something only a driver can do. The "uio" driver provides a generic mechanism to translate an interrupt into a file handle operation, so that user space can react in a way that closely resembles the behaviour.

 

0 Kudos
Visitor snoopy87
Visitor
7,317 Views
Registered: ‎06-18-2014

Re: Zynq: Handle interrupt on Linux

My understanding of the UIO driver is that I wirte in the device tree the address of the IP block, the different interrupts generated by the IP that are connected to GIC and also some other things. After the UIO driver allows me to write to the IP and also translate my interrupts into a file. Is it true ? (I have already try to use the UIO driver. I'm able to communicate with the IP but not to handle interrupt).

 

Now when the interrupt doesn't come from an IP, I can't write in the device tree the address of the IP because it doen't exist. So I can't use the UIO driver for managing interrupt coming from an input port for instance. So in that case how I can manage my interrupt. I must write my own driver or there is an driver to configure the GIC in order to tranlsate the interrupts into a file. 

 

 

 

0 Kudos
Scholar milosoftware
Scholar
7,288 Views
Registered: ‎10-26-2012

Re: Zynq: Handle interrupt on Linux

Please explain what your IP does and what you intend to do with it. Maybe that will help us help you.

0 Kudos
Visitor snoopy87
Visitor
7,285 Views
Registered: ‎06-18-2014

Re: Zynq: Handle interrupt on Linux

My IP is used to spy the communication between a reader and a smartcard (ISO 7816). The IP is divided into two parts: the first part intercepts the data from the reader (slave part) and the second one sends the data to the smartcard (master part). All data pass through the ARM core in order to decode them. The IP generates different interrupts like "cold reset detected", "warm reset detected", "new data received", "data send ended", etc . it also owns 5 registers used to configure the speed of the communication and to check the status of the IP. All interrupts are connected to GIC and the IP communicates with the ARM through the AXI port. 

 

 

0 Kudos
Scholar milosoftware
Scholar
7,223 Views
Registered: ‎10-26-2012

Re: Zynq: Handle interrupt on Linux

Looks like the kind of device that really needs a driver.

 

Note that instead of using 5 interrupts, you could also use one interrupt and a mask register that contains a bitset for the events that have fired. You can make that register zero itself and clear the interrupt status after a read, which avoids race conditions.

 

I suggest learning to walk before running - start with a simple driver that only does a part of what you want.

 

This is the "bible" for driver development. It isn't rocket science...

http://lwn.net/Kernel/LDD3/

0 Kudos