How to know correct IRQ number for calling request_irq() while writing myown Linux driver?


  1. I am using Altera Cyclone V SoC Dev Kit
  2. I add UART_0 (UART IP) in QSYS, connect UART_0.irq into HPS.f2h_irq0[3]
    add UART_1 (UART IP) in QSYS, connect UART_1.irq into HPS.f2h_irq0[4]
  3. Link UART_0.Tx to UART_1.Rx & UART_0.Rx to UART_1.Tx (cross-link) for test only.


  1. I have wrote a bare-metal program to test UART_0 & UART_1, UART’s interrupt works well.

[Problem & Request]

  1. I want to write a Linux Driver of UART_0.
  2. I don’t know the IRQ number that map to UART_0 that connect to HPS.f2h_irq0[3].
    Please give me some help.

Thanks in advance.

1 Like

-First: For the altera UART driver you can take a look in kernel drivers/tty/serial/altera_uart.c. Or you can also take a look at /drivers/tty/serial/8250/8250_dw.c. Thats the uart driver usually used for the uarts @ HPS!
-The interrupts will look like this:
UART_0.irq > hps.f2h_irq0[3] > Altera docu interrupt 75 (FPGA_IRQ3) > linux interrupt 43 (75-32)
UART_1.irq > hps.f2h_irq0[4] > Altera docu interrupt 76 (FPGA_IRQ4) > linux interrupt 44 (76-32)

I think there is already a UART driver (unless this is custom UART)

In general, you want to add your device to the device tree (dts). Then from your driver you can look up the irq information from the device tree.

In my .dts (from the GSRD) the uart entry looks like this:

hps_0_uart0: serial@0xffc02000 {
                        compatible = "snps,dw-apb-uart-15.0", "snps,dw-apb-uart";
                        reg = <0xffc02000 0x00000100>;
                        interrupt-parent = <&hps_0_arm_gic_0>;
                        interrupts = <0 162 4>;
                        clocks = <&l4_sp_clk>;
                        reg-io-width = <4>;     /* embeddedsw.dts.params.reg-io-width type NUMBER */
                        reg-shift = <2>;        /* embeddedsw.dts.params.reg-shift type NUMBER */
                        status = "okay";        /* embeddedsw.dts.params.status type STRING */
                }; //end serial@0xffc02000 (hps_0_uart0)

Then in your driver probe function:

static int my_driver_probe(struct platform_device* pdev)
    int irq_num;
    int res;
    irq_num = irq_of_parse_and_map(pdev->dev.of_node, 0); /* get IRQ # from device tree */
    res = request_irq(irq_num, my_isr, 0, DEVNAME, l1dev);

of course you will need to set up a platform driver for this method (there are other ways to do this as well without setting up a platform driver)

static const struct of_device_id my_driver_id[] = {
        { .compatible = "snps,dw-apb-uart" }, /* this name should match one of entries in the compatible field */
        { }

static struct platform_driver my_driver = {
    .driver =
    {   .name = DEVNAME,
        .owner = THIS_MODULE,
        .of_match_table = of_match_ptr(my_driver_id),
    .probe = itcl1_rx_driver_probe,
    .remove = itcl1_rx_driver_remove,
MODULE_DEVICE_TABLE(mydrv, mydriver);

int __init my_driver_init(void)
   /* ... other driver init setup ... */
   result = platform_driver_register(&my_driver); /* register platform driver */

Hope that points you in the right direction

Thanks for every answers.

I am writing my own UART driver of Linux.

The UART is not a peripheral of HPS, it’s another FPGA IP that exist in QSYS library. (not in HPS configuration sheet).

So I have connect UART’s IRQ into HPS.f2h_irq_0[3], but when UART.irq happend (Rising edge), the ISR in Linux Driver didn’t happen.

Where can find the example that connect your own FPGA IP’s interrupt to HPS.f2h_irq0, and writing the Linux Driver for your own IP ?



I dont think youll find just what you need! But here is one of the best things i’ve found in internet!
You can learn how to create a qsys component from your (vhdl or verilog) sources. To connect it to the HPS. Also how to write a driver and how to use interrupts!!
Just check it! all-in-one!

Hi, I don’t know how to use the interrupt on the board. If your problem is solved, can u give me some advice? Thanks a lot.

Do you finish your work on writing your UART driver of Linux?
I have a board based on Cyclone V SoC, the board has a UART module on the FPGA side, I have to write a drive for the UART, but I am a beginner in Linux, it’s too hard for me to write a drive.
So, Can you share your UART driver with me? Thanks a lot!
my email address is!