S3C6410 中的 cascaded irqdomain 之 gpio

news/2025/3/14 21:39:51/

文章目录

  • VIC 中断 与 gpio 中断 的硬件拓扑图描述
  • linux cascaded irq domain
    • irq domain 初始化时
    • 获取 IRQ number(软件中断号) 时
    • 中断发生时
    • 如何调试
    • linux irq domain 实例
  • VIC domain 与 gpio domain 的硬件拓扑语言描述
    • VIC 与 INT_EINTx 的关系
    • INT_EINTx 与 GPIO的关系
      • INT_EINT0
      • INT_EINT1
      • INT_EINT2
      • INT_EINT3
      • INT_EINT4
        • INT_EINT4 与 External interrupt Group1-9 的关系
        • External interrupt Group1
        • External interrupt Group2
        • External interrupt Group3
        • External interrupt Group4
        • External interrupt Group5
        • External interrupt Group6
        • External interrupt Group7
        • External interrupt Group8
        • External interrupt Group9

VIC 中断 与 gpio 中断 的硬件拓扑图描述

以下是 s3c6410a 的 irq 拓扑 描述,着重凸显了 gpio irq
以下 每个颜色 的gpio 共享一个vic 的中断线,5 个 中断线
-----------
注意 : 在linux 里面,将每个 gpx 注册为了一个domain!!!

在这里插入图片描述

linux cascaded irq domain

  • irq domain & 级联(cascaded)irq domain

irq domain 初始化时

s3c64xx_eint_eint0_init// 0. 处理 parents interrupt console 相关的 中断处理函数for (i = 0; i < NUM_EINT0_IRQ; ++i) { // 设置 parent 相关的irqirq = irq_of_parse_and_map(eint0_np, i);irq_set_chained_handler_and_data(irq, s3c64xx_eint0_handlers[i], data);}// 1. 创建 irq domainfor (i = 0; i < d->nr_banks; ++i, ++bank) bank->irq_domain = irq_domain_add_linear(bank->of_node, nr_eints, &s3c64xx_eint0_irqd_ops, ddata);// irq_domain_add_simple 的 第三个参数 first_irq如果为0 ,效果等同于 irq_domain_add_linear// first_irq: first number of irq block assigned to the domain,// pass zero to assign irqs on-the-fly. If first_irq is non-zero, then// pre-map all of the irqs in the domain to virqs starting at first_irq.// 如果第三个参数 不等于0 ,则 在该函数中 做 irq_create_mapping

获取 IRQ number(软件中断号) 时


使用domain 映射号码irq_create_mapping/irq_create_mapping_affinity// 2. 获取 软件中断号  并 创建 descsvirq = irq_find_mapping(domain, hwirq);virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node), affinity);// 3. 绑定 domain 中的软件中断号 和 硬件中断号// 用domain 的 map函数 设置 高层 handlerirq_domain_associate(domain, virq, hwirq)irq_set_chip_and_handler(virq, &s3c64xx_eint0_irq_chip, handle_level_irq);

中断发生时

  • 非级联的中断发生流程
一旦发生硬件中断,经过CPU architecture相关的中断代码之后,会调用irq handler,该函数的一般过程如下:(1)首先找到root interrupt controller对应的irq domain。(2)根据HW 寄存器信息和irq domain信息获取HW interrupt ID(3)调用irq_find_mapping找到HW interrupt ID对应的irq number(4)调用handle_IRQ(对于ARM平台)来处理该irq number
  • 级联中断发生流程

按照当前 gpio 级联到 vic
假设 vic0 是 A, GPN0-3的domain 是 B
假设 GPN0 发生了中断A.1首先找到root interrupt controller(在这里是vic)对应的irq domain  // 关注 irq_set_chip_data irq_get_chip_data 
A.2根据VIC HW 寄存器信息和irq domain信息获取HW interrupt ID  // VIC0的 0
A.3调用irq_find_mapping找到HW interrupt ID(在这里是0)对应的irq number
A.4调用irq domain B 注册 的 handler( irq_set_chained_handler 设定的gpio_handle_irq_cascaded)B.1gpio_handle_irq_cascaded找到gpio对应的irq domain // 和 A.1 中的irq domain完全不同// 关注 irq_set_chip_data irq_get_chip_data 
B.2根据GPIO HW 寄存器信息和irq domain信息获取HW interrupt ID // 和 A.2 中的HW interrupt ID完全不同
B.3调用irq_find_mapping找到HW interrupt ID对应的irq number // 和 A.3 中的 irq number 完全不同
B.4调用 驱动 注册 的 handler( request_irq 设定的) // 这个驱动对应的设备用到了 GPN0

如何调试

CONFIG_DYNAMIC_DEBUG=y
CONFIG_DEBUG_FS=y
CONFIG_GENERIC_IRQ_DEBUGFS=y
----------------
kernel/irq/Makefile
@@ -1,5 +1,6 @@# SPDX-License-Identifier: GPL-2.0+ccflags-y += -DDEBUG -DVERBOSE_DEBUG
# pwd
/sys/kernel/debug/irq
# ls
domains  irqs
# ls -l 
total 0
drwxr-xr-x    2 root     root             0 Jan  1 00:00 domains
drwxr-xr-x    2 root     root             0 Jan  1 00:00 irqs以下的文件都可以读./domains:
:soc:interrupt-controller@71200000  :soc:pinctrl@7f008000:gph
:soc:interrupt-controller@71300000  :soc:pinctrl@7f008000:gpl
:soc:pinctrl@7f008000:gpa           :soc:pinctrl@7f008000:gpm
:soc:pinctrl@7f008000:gpb           :soc:pinctrl@7f008000:gpn
:soc:pinctrl@7f008000:gpc           :soc:pinctrl@7f008000:gpo
:soc:pinctrl@7f008000:gpd           :soc:pinctrl@7f008000:gpp
:soc:pinctrl@7f008000:gpf           :soc:pinctrl@7f008000:gpq
:soc:pinctrl@7f008000:gpg           default./irqs:
0   10  12  14  16  18  2   21  23  25  27  29  30  32  4   6   8
1   11  13  15  17  19  20  22  24  26  28  3   31  33  5   7   9

linux irq domain 实例

irq: Added domain :soc:interrupt-controller@71200000
irq: Added domain :soc:interrupt-controller@71300000
irq: Added domain :soc:pinctrl@7f008000:gpa
irq: Added domain :soc:pinctrl@7f008000:gpb
irq: Added domain :soc:pinctrl@7f008000:gpc
irq: Added domain :soc:pinctrl@7f008000:gpd
irq: Added domain :soc:pinctrl@7f008000:gpf
irq: Added domain :soc:pinctrl@7f008000:gpg
irq: Added domain :soc:pinctrl@7f008000:gph
irq: Added domain :soc:pinctrl@7f008000:gpo
irq: Added domain :soc:pinctrl@7f008000:gpp
irq: Added domain :soc:pinctrl@7f008000:gpq
irq: Added domain :soc:pinctrl@7f008000:gpl
irq: Added domain :soc:pinctrl@7f008000:gpm
irq: Added domain :soc:pinctrl@7f008000:gpn
irq: Added domain :soc:pinctrl@7f008000:gpn
irq: -> using domain @c0889d80
SUD File: kernel/irq/irqdomain.c, Line: 00557: irq_domain_associate,domain:c0889d80,virq:33,hwirq:7
SUD File: kernel/irq/irqdomain.c, Line: 00559: irq_domain_associate,c024afa8 // s3c64xx_eint0_irq_map domain->ops->map
SUD File: kernel/irq/irqdomain.c, Line: 00499: irq_domain_set_mapping,7,16
irq: irq 7 on domain gpn mapped to virtual irq 33

VIC domain 与 gpio domain 的硬件拓扑语言描述

VIC 与 INT_EINTx 的关系

Int. No.SourcesDescriptionGroup
53INT_EINT4External interrupt Group 1 ~ Group 9VIC1
33INT_EINT3External interrupt Group 0 20 ~ 27VIC1
32INT_EINT2External interrupt Group 0 12 ~ 19VIC1
1INT_EINT1External interrupt Group 0 4 ~ 11VIC0
0INT_EINT0External interrupt Group 0 0 ~ 3VIC0

INT_EINTx 与 GPIO的关系

INT_EINT0

External interrupt Group 0  0 - 15  <===> GPN0-GPN15GPN0-3			: 0GPN4-11			: 1GPN12-15 & GPL8-GPL11 : 32
External interrupt Group 0  16 - 22 <===> GPL8-GPL14GPL12-GPL14 & GPM0-GPM4 : 33
External interrupt Group 0  23 - 27 <===> GPM0-GPM4

INT_EINT1

External interrupt Group 0  0 - 15  <===> GPN0-GPN15
External interrupt Group 0  16 - 22 <===> GPL8-GPL14
External interrupt Group 0  23 - 27 <===> GPM0-GPM4

INT_EINT2

External interrupt Group 0  0 - 15  <===> GPN0-GPN15
External interrupt Group 0  16 - 22 <===> GPL8-GPL14
External interrupt Group 0  23 - 27 <===> GPM0-GPM4

INT_EINT3

External interrupt Group 0  0 - 15  <===> GPN0-GPN15
External interrupt Group 0  16 - 22 <===> GPL8-GPL14
External interrupt Group 0  23 - 27 <===> GPM0-GPM4

INT_EINT4

INT_EINT4 与 External interrupt Group1-9 的关系

在这里插入图片描述

External interrupt Group1

EINT1 0 - 7   <===> GPA 0 - 7
EINT1 8 - 14  <===> GPB 0 - 6

External interrupt Group2

EINT2 0 - 7   <===> GPC 0 - 7

External interrupt Group3

EINT3 0 - 4   <===> GPD 0 - 4

External interrupt Group4

EINT4 0 - 13   <===> GPF 0 - 13

External interrupt Group5

EINT5 0 - 6   <===> GPG 0 - 6

External interrupt Group6

EINT6 0 - 9   <===> GPH 0 - 9

External interrupt Group7

EINT7 0 - 15   <===> GPO 0 - 7

External interrupt Group8

EINT8 0 - 14   <===> GPP 0 - 7

External interrupt Group9

EINT9 0 - 8   <===> GPQ 0 - 8

http://www.ppmy.cn/news/58000.html

相关文章

回炉重造十一------ansible批量安装服务

1.playbook的核心组件 Hosts 执行的远程主机列表Tasks 任务集,由多个task的元素组成的列表实现,每个task是一个字典,一个完整的代码块功能需最 少元素需包括 name 和 task,一个name只能包括一个taskVariables 内置变量或自定义变量在playbook中调用Templates 模板&#xff0c;…

springboot第15集:MyBatis分页

我们在测试SQL的时候&#xff0c;要是能够在控制台输出 SQL 的话&#xff0c;是不是就能够有更快的排错效率&#xff1f; 是的&#xff0c;输出 SQL 可以帮助我们更好地理解代码的执行流程和结果。在控制台输出 SQL 可以让我们看到实际执行的 SQL 语句&#xff0c;这样就能够更…

Scalable Vector Graphics (SVG)中的svg、clipPath、mask元素

Scalable Vector Graphics (SVG)是一种用于描述二维向量图形的XML基础标记语言。使用SVG可以实现丰富的图形效果&#xff0c;而不需要像使用位图那样考虑分辨率和像素密度的问题&#xff0c;可以在不同设备上展示出相同的高质量图像。 在SVG中&#xff0c;除了基本形状如circl…

【人工智能】— 不确定性、先验概率/后验概率、概率密度、贝叶斯法则、朴素贝叶斯 、最大似然估计

【人工智能】— 不确定性 不确定性不确定性与理性决策基本概率符号先验概率(无条件概率)/后验概率(条件概率)随机变量概率密度联合概率分布公理完全联合分布概率演算独立性 贝叶斯法则例1例2 使用贝叶斯规则&#xff1a;合并证据朴素贝叶斯最大似然估计小结 不确定性 不确定性与…

码出高效:Java开发手册笔记(线程池及其源码)

码出高效&#xff1a;Java开发手册笔记&#xff08;线程池及其源码&#xff09; 码出高效&#xff1a;Java开发手册笔记&#xff08;线程池及其源码&#xff09; 码出高效&#xff1a;Java开发手册笔记&#xff08;线程池及其源码&#xff09;前言一、线程池的作用线程的生命周…

Sentinel源码分析学习

文章目录 前言Sentinel源码分析1.Sentinel的基本概念1.1.ProcessorSlotChain1.2.Node1.3.Entry1.3.1.自定义资源1.3.2.基于注解标记资源 1.4.Context1.4.1.什么是Context1.4.2.Context的初始化1.4.2.1.自动装配1.4.2.2.AbstractSentinelInterceptor1.4.2.3.ContextUtil 2.Proce…

【网络进阶】服务器模型Reactor与Proactor

文章目录 1. Reactor模型2. Proactor模型3. 同步IO模拟Proactor模型 在高并发编程和网络连接的消息处理中&#xff0c;通常可分为两个阶段&#xff1a;等待消息就绪和消息处理。当使用默认的阻塞套接字时&#xff08;例如每个线程专门处理一个连接&#xff09;&#xff0c;这两…

clion--cmake内置常量---打算一锅端了

# cmakelists.txt文件讲解&#xff0c;以下语意不是都在同一个cmakelists.txt message("${CMAKE_SOURCE_DIR} 是工程终极父级目录") message("${CMAKE_BINARY_DIR} 是CMAKE_SOURCE_DIR下的一个cmake_build_<buildtype>目录") message("${PROJEC…