如何在没有设备树的嵌入式Linux中设置PL/PS中断?

问题描述 投票:0回答:1

我正在尝试在嵌入式 Linux 上记录从 PS 到 PL 的中断。为此,我使用驱动程序和 request_irq 函数。但我无法记录我的中断。我在vivado上的中断号是IRQ_F2P号61。

查看 GIC 文档,我想也许我应该输入 29(SPI 中断的数字),我还尝试了 61 + 32 和 61 - 32(在一些晦涩的论坛答案中找到的公式)。但无济于事,我的请求 irq 返回错误 -22。我想在不修改设备树的情况下执行此操作,这可能吗?如果是这样,有人对如何做到这一点有任何想法吗?

提前致谢:)。

linux kernel interrupt petalinux
1个回答
0
投票

我终于找到解决办法了。如果我们想要在没有设备树的情况下注册 irq,我们必须将中断映射到 irq 域。为此,我们必须找到该数字。这段代码完成了所有操作,之后您可以轻松使用“register_irq”。这是代码:

#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 是我的 irq 61 - 32(GIC 数据表)。

感谢:request_irq 失败,因为没有 irq 描述符

© www.soinside.com 2019 - 2024. All rights reserved.