补充IRQ Domain介绍
在linux kernel中,我们使用下面两个ID来标识一个来自外设的中断:

1、IRQ number。CPU需要为每一个外设中断编号,我们称之IRQ Number。这个IRQ number是一个虚拟的interrupt ID,和硬件无关,仅仅是被CPU用来标识一个外设中断。

2、HW interrupt ID。对于interrupt controller而言,它收集了多个外设的interrupt request line并向上传递,因此,interrupt controller需要对外设中断进行编码。Interrupt controller用HW interrupt ID来标识外设的中断。在interrupt controller级联的情况下,仅仅用HW interrupt ID已经不能唯一标识一个外设中断,还需要知道该HW interrupt ID所属的interrupt controller(HW interrupt ID在不同的Interrupt controller上是会重复编码的)。

这样,CPU和interrupt controller在标识中断上就有了一些不同的概念,但是,对于驱动工程师而言,我们和CPU视角是一样的,我们只希望得到一个IRQ number,而不关系具体是那个interrupt controller上的那个HW interrupt ID。这样一个好处是在中断相关的硬件发生变化的时候,驱动软件不需要修改。因此,linux kernel中的中断子系统需要提供一个将HW interrupt ID映射到IRQ number上来的机制…

(本段转载自:http://www.wowotech.net/linux_kenrel/irq-domain.html)

1、创建一个irq domain,注意是tree型的

(linux/drivers/irqchip/irq-gic-v3.c)static int __init gic_init_bases(void __iomem *dist_base,struct redist_region *rdist_regs,u32 nr_redist_regions,u64 redist_stride,struct fwnode_handle *handle)
......gic_data.domain = irq_domain_create_tree(handle, &gic_irq_domain_ops, &gic_data);
......
}

2、为domain分配中断号

(linux/drivers/irqchip/irq-gic-v3.c)static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,unsigned int nr_irqs, void *arg)
{int i, ret;irq_hw_number_t hwirq;unsigned int type = IRQ_TYPE_NONE;struct irq_fwspec *fwspec = arg;ret = gic_irq_domain_translate(domain, fwspec, &hwirq, &type);if (ret)return ret;for (i = 0; i < nr_irqs; i++) {ret = gic_irq_domain_map(domain, virq + i, hwirq + i);if (ret)return ret;}return 0;
}

3、对irq进行map

(linux/drivers/irqchip/irq-gic-v3.c)static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq,irq_hw_number_t hw)
{struct irq_chip *chip = &gic_chip;struct irq_data *irqd = irq_desc_get_irq_data(irq_to_desc(irq));if (static_branch_likely(&supports_deactivate_key))chip = &gic_eoimode1_chip;switch (__get_intid_range(hw)) {case SGI_RANGE:case PPI_RANGE:case EPPI_RANGE:irq_set_percpu_devid(irq);irq_domain_set_info(d, irq, hw, chip, d->host_data,handle_percpu_devid_irq, NULL, NULL);break;case SPI_RANGE:case ESPI_RANGE:irq_domain_set_info(d, irq, hw, chip, d->host_data,handle_fasteoi_irq, NULL, NULL);irq_set_probe(irq);irqd_set_single_target(irqd);break;case LPI_RANGE:if (!gic_dist_supports_lpis())return -EPERM;irq_domain_set_info(d, irq, hw, chip, d->host_data,handle_fasteoi_irq, NULL, NULL);break;default:return -EPERM;}/* Prevents SW retriggers which mess up the ACK/EOI ordering */irqd_set_handle_enforce_irqctx(irqd);return 0;
}

5、使用示例:

xxxx_yyyy_engine {compatible = "xxxx,yyyy_engine";interrupts = <0 52 0x4>,<0 57 0x4>;  // 两个硬件中断号
};yyyy_irq1 = irq_of_parse_and_map(np, 0);  //map成linux kernel中的中断号
yyyy_irq2 = irq_of_parse_and_map(np, 1);  //map成linux kernel中的中断号ret = request_irq(yyyy_irq1, handler1,IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "name1", NULL) //注册中断
ret = request_irq(yyyy_irq2, handler2,IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "name2", NULL) //注册中断

参考irqdomain

irq domain介绍和代码导读相关推荐

  1. Linux kernel的中断子系统之(二):IRQ Domain介绍

    一.概述 在linux kernel中,我们使用下面两个ID来标识一个来自外设的中断: 1.IRQ number.CPU需要为每一个外设中断编号,我们称之IRQ Number.这个IRQ number ...

  2. 设备树学习(十五、番外篇-中断子系统之IRQ Domain介绍)

    之前的文章分析过没使用设备树时,中断是如何初始化的 https://blog.csdn.net/qq_16777851/article/details/82556519 用一句话总结就是,启动过程,通 ...

  3. Android gatekeeper的原理介绍和代码导读

    快速链接: .

  4. Caffe代码导读(5):对数据集进行Testing

    转载自: Caffe代码导读(5):对数据集进行Testing - 卜居 - 博客频道 - CSDN.NET http://blog.csdn.net/kkk584520/article/detail ...

  5. 深度学习推荐系统之wide deep介绍和代码实现

    阅读前思考 在你的应用场景中,哪些特征适合放在Wide侧,哪些特征适合放在Deep侧,为什么呢? 为什么Wide部分要用L1 FTRL训练? 为什么Deep部分不特别考虑稀疏性的问题? 系列导读 深度 ...

  6. linux IRQ Management(四)- IRQ Domain

    了解IRQ Domain(中断控制器) 1.如何理解中断号?   每个IRQ同时有"irq"和"hwirq"两个编号. "hwirq"是硬件 ...

  7. 【Linux】网络编程三:TCP通信和UDP通信介绍及代码编写

    参考连接:https://www.nowcoder.com/study/live/504/2/16. [Linux]网络编程一:网络结构模式.MAC/IP/端口.网络模型.协议及网络通信过程简单介绍 ...

  8. python简单代码画曲线图教程-Python绘制折线图和散点图的详细方法介绍(代码示例)...

    本篇文章给大家带来的内容是关于Python绘制折线图和散点图的详细方法介绍(代码示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 1.绘制折线图和散点图要用到matplotlib ...

  9. python画折线图代码-Python绘制折线图和散点图的详细方法介绍(代码示例)

    本篇文章给大家带来的内容是关于Python绘制折线图和散点图的详细方法介绍(代码示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 1.绘制折线图和散点图要用到matplotlib ...

最新文章

  1. mask-conditional contrast-GAN
  2. 网络营销外包专员浅析响应式网站建设应注意哪些网络营销外包细节
  3. 零基础python从入门到精通 pdf-PYTHON从入门到精通 PDF 下载
  4. 在a标签中写ajax,ajax请求后的数据渲染到页面中,a链接失效
  5. nvm-windows 安装后,node 命令报错
  6. nodejs 嵌套消除和高并发
  7. mysql case默认_MySQL -- 配置文件my.cnf 的详细说明
  8. 三、索引优化(5)索引设计指南
  9. gcc中设置特定代码块的优化级别
  10. Virtual Breadboard 4.46 arduino模拟仿真虚拟 破解下载
  11. Android 百度地图定位
  12. 文件后缀bat是什么?(批处理文件)
  13. 未成年人勿进 谨以献给1980~1990出生的人(三)
  14. 2021年二级c语言采用的版本是,2021年二级c语言笔试必背-20210416065706.doc-原创力文档...
  15. 从小程序快速扫码进微信群聊
  16. CAD教程:CAD软件中如何进行CAD图层管理?
  17. 经验主义:破解困局的救命稻草
  18. 2021浙江高考成绩查询登不进,2021年浙江高考成绩查询官网查分网址:https://www.zjzs.net/...
  19. 微信小程序Mac端设置服务器代理
  20. 基于matlab的简单的寻找波峰波谷处理方法

热门文章

  1. 无处不在的智能设备与边缘计算时代即将来临
  2. python 哪些比赛项目_70个超火python小项目列表,拿走·不谢
  3. php针对中文的字符串函数,php截取中文字符串函数实例_php技巧
  4. BigData之Hive beeline:beeline的简介、使用方法之详细攻略
  5. 成功解决Module Not Found Error : No module named mglearn
  6. Keras之MLPR:利用MLPR算法(3to1【窗口法】+【Input(3)→(12+8)(relu)→O(mse)】)实现根据历史航空旅客数量数据集(时间序列数据)预测下月乘客数量问题
  7. Hadoop-2.7.4 八节点分布式集群安装
  8. JAVA_OA管理系统(三)番外篇:Myeclipse导入Spring源码包
  9. Web应用开发技术(3)-html
  10. (原创)7-1 银行业务队列简单模拟 (30 分)