linuxkernelinterruptpetalinux

How set a PL/PS Interrupt in embedded Linux without device-tree?


I'm trying to record an interruption from my PS to my PL on my embedded linux. To do this I'm using a driver and the request_irq function. But I can't manage to record my interrupt. The number of my interrupt on vivado is IRQ_F2P number 61.

Looking at the GIC documentation I thought maybe I should put 29 (number for an SPI interrupt), I also tried 61 + 32 and 61 - 32 (formula found on some obscure forum answers). But to no avail, my request irq returns error -22. I'd like to do this without modifying the device-tree, is this possible? And if so, does anyone have any ideas on how to do this?

Thanks in advance :).


Solution

  • I finnaly find a solution. If we want register irq without device-tree we have to map our interrupt with irq domain. For do this we have to find the number. This code do everything, after that you can easily use "register_irq". This is the code :

    #include <linux/irqdomain.h> //For irq_domain struct
    #include <linux/of.h> //For device tree struct types
    #include <linux/irq.h> //Needed by other interrupt-related code
     
    struct device_node *dn;
    struct irq_domain *dom;
    struct irq_fwspec dummy_fwspec = {
        .param_count = 3,
        .param = {0, 29, 4}
    };
    int virq;
     
    //Find the Linux irq number
    dn = of_find_node_by_name(NULL, "interrupt-controller");
    if (!dn) {
        printk(KERN_ERR "Could not find device node for \"interrupt-controller\"\n");
        goto /*error_handler*/;
    }
    dom = irq_find_host(dn);
    if (!dom) {
        printk(KERN_ERR "Could not find irq domain\n");
        goto /*error_handler*/;
    }
     
    dummy_fwspec.fwnode = dom->fwnode;
    virq = irq_create_fwspec_mapping(&dummy_fwspec);
    

    29 is my irq 61 - 32 (GIC datasheet).

    Thank's to : request_irq fails because there is no irq descriptor