S3C6410 中的 cascaded irqdomain 之 gpio
文章目录
- 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!!!
pinctrl0: pinctrl@7f008000 { compatible = "samsung,s3c64xx-pinctrl"; reg = <0x7f008000 0x1000>; interrupt-parent = <&vic1>; interrupts = <21>; pctrl_int_map: pinctrl-interrupt-map { interrupt-map = <0 &vic0 0>, <1 &vic0 1>, <2 &vic1 0>, <3 &vic1 1>; #address-cells = <0>; #size-cells = <0>; #interrupt-cells = <1>; }; wakeup-interrupt-controller { compatible = "samsung,s3c64xx-wakeup-eint"; interrupts = <0>, <1>, <2>, <3>; interrupt-parent = <&pctrl_int_map>; }; };
linux cascaded irq domain
- irq domain & 级联(cascaded)irq domain
这个配置没有使用 Hierarchy IRQ domain , 即 CONFIG_IRQ_DOMAIN_HIERARCHY=n, 但是使用了级联中断
是怎么实现的呢? 在 gpio irq domain 初始化过程中 直接 做了 父domain(vic) 中的 hwirq&irq 的申请.并做好了对应的多合一的中断处理函数(三星专用的)如果实现了 CONFIG_IRQ_DOMAIN_HIERARCHY=y则会在 使用gpio(gpn3)中断的模块驱动中, request_irq , 如果是第一个,则 会 做了 父domain(vic0) 中的 hwirq(1)&irq 的申请并 设置 多合一(vic0 hwirq0)的中断处理函数(这应该是通用函数gpio_handle_irq_cascaded)然后申请自己的中断处理函数(gpn3)使用 irq_set_chained_handler_and_data(d->irq, s3c64xx_eint_gpio_irq, data); 和 父domain(vic) 建立了联系这个函数做了以下事情1.由vic 21 对应的 irq 申请了desc2.申请了中断处理函数 s3c64xx_eint_gpio_irq3.设置了中断处理函数 能够获取的数据 data当中断发生时,调用s3c64xx_eint_gpio_irq,这个函数做以下事情0.知道是gpio domain 中哪个硬件中断号1.获取data中的domain3.利用 irq_linear_revmap 和 domain 和 硬件中断号 获取 软件中断号4.调用软件中断号对应的中断处理函数,即该GPIO的中断处理函数
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. | Sources | Description | Group |
---|---|---|---|
53 | INT_EINT4 | External interrupt Group 1 ~ Group 9 | VIC1 |
33 | INT_EINT3 | External interrupt Group 0 20 ~ 27 | VIC1 |
32 | INT_EINT2 | External interrupt Group 0 12 ~ 19 | VIC1 |
1 | INT_EINT1 | External interrupt Group 0 4 ~ 11 | VIC0 |
0 | INT_EINT0 | External interrupt Group 0 0 ~ 3 | VIC0 |
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
S3C6410 中的 cascaded irqdomain 之 gpio相关推荐
- [nRF51822] 5、 霸屏了——详解nRF51 SDK中的GPIOTE(从GPIO电平变化到产生中断事件的流程详解)...
:由于在大多数情况下GPIO的状态变化都会触发应用程序执行一些动作.为了方便nRF51官方把该流程封装成了GPIOTE,全称:The GPIO Tasks and Events (GPIOTE) . ...
- Openwrt中MT7628/MT7688的全部GPIO复用配置及常用接口DTS配置总结
Openwrt的不同版本中关于MT7628,MT7688的GPIO配置,存在或多或少的一些小问题 下面将以MT7628AN为基础,介绍其全部的GPIO功能复用配置,以及需要注意的地方 MT76x8一个 ...
- Openwrt中MT7628/MT7688的全部GPIO复用配置及常用接口
Openwrt的不同版本中关于MT7628,MT7688的GPIO配置,存在或多或少的一些小问题 下面将以MT7628AN为基础,介绍其全部的GPIO功能复用配置,以及需要注意的地方 MT76x8一个 ...
- 视频图文教学 - 用最快的速度把 DotNet Core Blazor 程序安装到 树莓派中 并且用网页控制 GPIO 闪灯
前言 dotnet core 在3.0时代已经发展得很好. 尤其是在跨平台方面更已经是达到了很实用的阶段. 作为 dotnet 程序员, 应该对 Linux 有充分的了解, 也可以在业余时间玩玩硬件, ...
- zynq学习03 zynq中三种实现GPIO的方式
http://m.blog.csdn.net/article/details?id=52123465 http://blog.chinaaet.com/songhuangong/p/43084 本文介 ...
- 友善之臂中的mini2440 GPIO相关函数操作
在mini2440的驱动中,如果要对GPIO进行相关功能的配置和数据的写入获取,需要直接对相应的寄存器进行操作,其中使用的函数有: mini2440中端口号的形成可以使用下边的宏: S3C2410_G ...
- S3C6410 SPI中PCLK_GATE和SCLK_GATE的理解
在使用S3C6410 SPI进行通信时,首先要设置SPI的控制寄存器,但是经过查看大量代码后,发现在设置SPI的一系列的寄存器时要先设置S3C6410中PCLK_GATE和SCLK_GATE寄存器与S ...
- 学会Zynq(5)GPIO中EMIO的使用方法
之前的Hello World和MIO使用都算是纯PS部分,也就是把Zynq单纯地当作ARM使用.很多人都是因为FPGA+ARM架构才使用的Zynq,有两个关键问题容易引起初学者的兴趣:(1).如何用P ...
- s3c6410中断处理
一.中断的场景模拟 ---------------------------------------------------------------------------- 中断(Interrupt) ...
最新文章
- 使用Python,Matplotlib显示RGB图像
- gazebo入门_【ROS-Gazebo】仿真插件编写教程(1)——概述
- Facebook如何向十亿人推荐东西
- brain teasers
- 信息学奥赛一本通(C++)在线评测系统——基础(一)C++语言——1103:陶陶摘苹果
- 批量生成100万张小程序码?了解一下。
- Visual C++位图操作
- 勾股定理的形象拆分法,原来数学可以这么好玩!
- pivot 与 unpivot 函数是SQL05新提供的2个函数
- Custom Sharepoint Lookup Field
- Java垃圾回收精粹 — Part4
- 已经被废弃的 tcp_tw_recycle
- 繁简体(GB=Big5)字符串互转的JAVA方式实现
- ENVI监督分类图像分割
- 【技术答疑】Swarm BZZ常见技术问题解答
- MPB:山大倪金凤组-​​白蚁肠道微生物样品收集与制备
- java进阶知识思维导图
- win10配置计算机时强制关机,老鸟讲解Win10设置远程系统强制关机的详尽处理要领...
- 数据库架构设计——数据库选型
- python之直方图统计作图
热门文章
- 82540em 无盘服务器,千兆网卡
- Maven无法从nexus私服下载依赖?
- m35c android 4.4,索尼M35c电信版评测:Android 4.1系统和娱乐体验
- Email和电子邮箱一样吗?
- python撩妹小技巧 —— 30行代码实现520小彩蛋
- [附源码]计算机毕业设计JAVA汽车票售票系统lunwen
- wh6服务器怎么修改,文华财经怎样设置云服务器
- 学习笔记-----Material design
- 用python3的pyspider爬取国家统计局的行政区域(只到乡镇级,更新到2017年)
- 推荐一些免费的网盘给你