Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers

GHRD interrupts

Altera_Forum
Honored Contributor II
3,664 Views

I would like to use the standard GHRD design to handle interrupt. It looks like the pushbutton interrupts are enabled in the Qsys design. 

 

I have no idea how to register a callback in Linux code on one of these interrupt lines. 

 

Can anyone help with some example Linux code that works with the GHRD? 

 

Thanks.
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
1,985 Views

I think you'd better write a linux driver for the button!

0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

I have the Arrow SoCkit, and I have been struggling with this for a while. I'm digging into the device tree for the arrow board posted on rocketboards, and I found an entry for the gpio's. 

 

agpio0: gpio@0xc0000000 { 

compatible = "altr,pio-1.0"; 

/* Register base 0xff200000 is for a light-weight bridge */ 

reg = <0xff200000 0x10>; 

width = <32>; 

/* There are 64 interrupts from the FPGA start at 72, so 45 has to be wrong */ 

interrupts = <0 45 4>; 

interrupt-controller; 

# interrupt-cells = <1>; 

gpio-controller; 

# gpio-cells = <2>; 

level_trigger = <0>; 

 

I verified this is what the Linux kernel sees by looking in the folder at /proc/device-tree/soc/gpio@0xc0000000 

 

I'm worried about the comment : /* There are 64 interrupts from the FPGA start at 72, so 45 has to be wrong */ 

 

I wonder why that has to be wrong? 

 

 

 

This looks different from the Altera boards device tree entry, which is:  

 

button_pio: gpio@0x100c0 { 

compatible = "ALTR,pio-13.0.1", "ALTR,pio-1.0", "altr,pio-1.0"; 

reg = < 0x000100C0 0x00000010 >; 

interrupt-parent = < &hps_0_arm_gic_0 >; 

interrupts = < 0 41 1 >; 

width = < 2 >; /* width type NUMBER */ 

resetvalue = < 0 >; /* resetValue type NUMBER */ 

level_trigger = < 0 >; /* embeddedsw.dts.params.level_trigger type NUMBER */ 

# gpio-cells = < 2 >; 

gpio-controller; 

}; //end gpio@0x100c0 (button_pio) 

 

This entry has quite few differences from the arrow version. 

 

I have tried following the example here: C:\altera\13.0sp1\embedded\examples\software\Altera-SoCFPGA-Push-Button-Linux-GNU.tar.gz  

I was able to build the gpio-interrupt driver in the example. I used the yocto project kernel headers for the altera board to build against. (Not sure if this was the right way to do this.) 

 

For the arrow board, when I insert the altera-gpio.ko kernel module, ( with 'modprobe gpio_altera'), I find gpiochip224 in /sys/class/gpio. 

 

The next step I did was insert the gpio-interrupt kernel module I built from the example with the command 'modprobe gpio_interrupt gpio_number=224' 

 

So I look at /proc/interrupts and I see this: 

 

CPU0 CPU1 

525: 123056 121886 GIC twd 

648: 1 0 GIC eth0 

656: 1 0 GIC dwc_otg, dwc_otg_pcd, d 

667: 2280 0 GIC dw-mci 

679: 0 0 GIC ff705000.spi 

682: 0 0 GIC dw_spi0 

684: 0 0 GIC dw_spi1 

686: 0 0 GIC ffc04000.i2c 

687: 0 0 GIC ffc05000.i2c 

690: 6879 0 GIC serial 

697: 9 0 GIC timer2 

752: 0 0 altera-gpio (null) 

IPI0: 0 0 CPU wakeup interrupts 

IPI1: 0 0 Timer broadcast interrupts 

IPI2: 1127 1196 Rescheduling interrupts 

IPI3: 0 0 Function call interrupts 

IPI4: 1 2 Single function call interrupts 

IPI5: 0 0 CPU stop interrupts 

Err: 0 

 

There is an entry for the altera-gpio interrupt, but it does respond when I push the button (No updating /proc/interrupts, and no message in 'dmesg') 

The '(null)' after the interrupt is concerning. 

 

Any help is appreciated. 

 

Thanks.
0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

Hi ecullert  

I have writen a hps gpio interrupt driver with kernel-3.8. I build the driver within the kernel and it works. 

I get the kernel source from http://www.rocketboards.org/foswiki/view/projects/sockitlinarolinuxdesktop 

In the dts I just add myself code  

gpio1: gpio@0xff709000 {  

compatible = "key"; 

reg = < 0xff709000 0x00001000 >;  

interrupts = <0 165 4>; 

};  

The interrupt number in dts is 32 less than the number in GIC 

The I write my own driver (initial the driver and register the interrupt in kernel) 

This driver just uste the gpio interrupt but not fpga interrupt  

I hope the information be helpful for you!
0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

TO_BE_DONE

0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

Hi, 

 

Can someone please give some help on how to actually use the interrupt. I have a FIFO setup connected the light weight avalon master. The interrupt from the FIFO is connected to the HPS. 

 

But how do I set up the device tree. 

 

I read up somewhere to generate the device tree file from the sopcinfo file. I tried doing this but I got the following response. 

 

"Master and slave interfaces for the Transparent bridge in fifo_0 of type altera_avalon_fifo have different types." 

 

Any thoughts? 

 

Jack
0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

@ecullert 

 

Thank you for your very detailled help. 

I have done a "make" with linux-altera-3.7.  

Everything works fine in my virtual machine but not on my Evaluation Board. 

 

The Problem:  

 

I get an error for "insmod gpio_interruot.ko" because I should use kernel version 3.8.0. 

Is there an altera-linux-3.8? 

 

I have not found anything on Google. 

 

Best regards, 

Michael
0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

As far as I can tell, the altera yocto source package is still on 3.7. You could build the 3.7 Linux and do your testing unless there is a reason you need 3.8. 

 

The following webpages should get you through the entire process. 

 

http://www.rocketboards.org/foswiki/documentation/gsrdgettingstartedyocto 

 

http://www.rocketboards.org/foswiki/documentation/gsrdsdcard
0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

Thanks a lot! :-)

0 Kudos
Reply