Chinaunix首页 | 论坛 | 博客
  • 博客访问: 297567
  • 博文数量: 65
  • 博客积分: 185
  • 博客等级: 入伍新兵
  • 技术积分: 609
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-06 21:41
个人简介

好好学习,天天向上

文章分类

全部博文(65)

文章存档

2022年(3)

2021年(25)

2020年(1)

2019年(3)

2016年(2)

2015年(3)

2014年(14)

2013年(7)

2012年(7)

我的朋友

分类: 嵌入式

2021-03-26 10:38:09


  1. #include <linux/irqreturn.h>
  2. #include <linux/of_irq.h>
  3. #include <linux/interrupt.h>

  4. static int __init test_init(void)
  5. {
  6.         int err = 0, virq0;
  7.         struct device_node *node;

  8.         node = of_find_compatible_node(NULL,NULL, "test_int");
  9.         if (node) {
  10.                 virq0 = irq_of_parse_and_map(node, 0);
  11.                 if (virq0 <= 0) {
  12.                         pr_err("ftm: unable to get IRQ from DT, %d\n", virq0);
  13.                         return -EINVAL;
  14.                 }

  15.                 err = request_irq(virq0, test_handler, IRQF_TRIGGER_RISING, "test0", NULL);
  16.                 if (err) {
  17.                         pr_info(" ----warn: rtdm_irq_request failed, err=%d ---\n", err);
  18.                         return err;
  19.                 }
  20.         }

  21.         return 0;
  22. }

  23. static void __exit test_exit(void)
  24. {
  25.         free_irq(virq0, NULL);
  26. }


  27. ======dts节点
  28.         test: test@000000 {
  29.             compatible = "test_int";
  30.             interrupts = <GIC_SPI 179 IRQ_TYPE_LEVEL_HIGH>;
  31.         };


阅读(1168) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~