[device tree] interrupt mapping example
This is for Devicetree Specification Release 0.1
Interrupt Mapping Example p19
在講解前,先帶進一些 PCI 的基礎觀念
pci device 的 其中一種 type address 由下方組成


為什麼 硬體要連成這樣子呢? 因為要 loading balance
pci device 的 INTA 是較常使用到的,
INTB,INTC,INTD 是較少使用到,
假如每個 device 的 INTA 都發出中斷,這種接線方式會讓 每個中斷 都接到一根 IRQ。
Interrupt Mapping Example p19
有兩個 PCI slots (IDSEL 0x11, 0x12)
每個 slot 有 4 個 中斷 pin, INTA,INTB,INTC,INTD
並且連接到 Open PIC interrupt controller
IDSEL(Initialization Device Select)是指"it used as a chip select during configuration read and write transactions."
這部分會連接到PCI AD[31:11],是由硬體拉線所決定的。
soc {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
open-pic {
clock-frequency = <0>;
interrupt-controller; // interrupt controller node 需要填寫 interrupt-controller property
#address-cells = <0>;
#interrupt-cells = <2>;
};
pci {
#interrupt-cells = <1>;
#size-cells = <2>;
#address-cells = <3>;
interrupt-map-mask = <0xf800 0 0 7>;
interrupt-map = <
/* IDSEL 0x11 - PCI slot 1 */
0x8800 0 0 1 &open-pic 2 1 /* INTA */
0x8800 0 0 2 &open-pic 3 1 /* INTB */
0x8800 0 0 3 &open-pic 4 1 /* INTC */
0x8800 0 0 4 &open-pic 1 1 /* INTD */
/* IDSEL 0x12 - PCI slot 2 */
0x9000 0 0 1 &open-pic 3 1 /* INTA */
0x9000 0 0 2 &open-pic 4 1 /* INTB */
0x9000 0 0 3 &open-pic 1 1 /* INTC */
0x9000 0 0 4 &open-pic 2 1 /* INTD */
>;
};
};
interrupt-map table 裡的每一列,包含5個部分,
1.child unit address
2.child interrupt specifier
3.interrupt parent
4.parent unit address
5.parent interrupt specifier
child unit address 和 child interrupt specifier 會對應到 特定的 parent unit address 及 interrupt specifier 的 interrupt parent。
interrupt-map table 裡的第一列,
0x8800 0 0 1 &open-pic 2 1
1。child unit address 是 0x8800 0 0
為什麼是由3個 32-bit cells 組成 child unit address?
因為 pci controller 裡的 address-cells property 是3,
所以 PCI bus 是使用 3 個 address cells 來表達 PCI bus。
為什麼是 0x8800?
因為 IDSEL 其中一個是 0x11,這連接到PCI AD[31:11],所以整個 pci address 編碼為 0x8800(編碼方式最上面有提到).
2。child interrupt specifier 是 1
pci controller 的 interrupt-cells 是1,
所以只用一個cell 表達 child interrupt specifier,
而 1 是表達 INTA,(不是從0)
這是指 child interrupt domain,不是 parent interrupt domain。
3。interrupt parent 是 &open-pic
這會填入interrupt parent 的 phandle 的值,來代表 要將 中斷傳給誰(parent)。
4。沒有parent unit address。
因為 parent interrupt domain (open-pic)的 address-cells property 是 0。
5。parent interrupt specifier 是 2 1
parent 的 interrupt-cells 是 2,
所以是使用 2 個 cells 表達 parent interrupt secpfier
2代表 中斷要連到 parent 的 IRQ2。
1代表 level/sense encoding,還不知道這是什麼。
interrupt-map-mask
interrupt-map-mask = <0xf800 0 0 7>
在搜尋 interrupt map table之前,child unit address 及 child interrupt specifier 會先經過
interrupt-map-mask 做 & bit 運算後,得到一個結果,再到 interrupt map talbe 裡取出對應 parent unit address 及 parent interrupt specifier。
Ex:
一個 pci device IDSEL 0x12 (slot 2),function 0x3,發出 INTB 中斷,然後要去 interrupt map talbe 找出 parent open-pic 的 interrupt source number,也就是要找出對應的 parent 中斷 IRQ
pci device 的 address (IDSEL 0x12 (slot 2),function 0x3) 編碼為 0x9300(編碼方式最上面有提到),
因為 pci controller 的 address-cells 為3,所以最後編碼為 0x9300 0 0,
pci device 的 INTB 中斷,編碼為 2,
child unit address及child interrupt specifier整個是 < 0x9300 0 0 2 >。
而<0x9300 0 0 2> 要與 interrupt-map-mask <0xf800 0 0 7> 做 & bit 運算,
得到結果為 <0x9000 0 0 2>,
<0x9000 0 0 2>再往 interrupt map table搜尋 找出,
parent unit address 為空,為什麼為空,因為 parent (open-pic) 的 #address-cells = <0>
parent interrupt specifier 為 <4 1>,對應到 parent (open-pic) 的 IRQ4,1尚未知道其意義,
這樣就完成了 child interrupt domain 到 parent interrupt domain 的轉換
那為什麼要做 interrupt-map-mask 運算呢?
依稀記得網上有篇文章提到,做interrupt-map-mask 運算是要找出那一個 device 發出那一個中斷,所以只保留 bus 及 device bits及 INTx,其它bits 歸零。
reference
http://www.devicetree.org/specifications/
PCI Local Bus Specification Revision 2.2
PCI Read/Write
[device tree] interrupt mapping example的更多相关文章
- [device tree] interrupt
Specifying interrupt information for devices ============================================ 1) Interru ...
- Device Tree Usage( DTS文件语法)
http://elinux.org/Device_Tree_Usage Device Tree Usage Top Device Tree page This page walks throu ...
- Device Tree Usage(理解DTS文件语法)
Basic Data Format The device tree is a simple tree structure of nodes and properties. Properties are ...
- Device Tree Usage 【转】
转自:http://blog.chinaunix.net/uid-20522771-id-3457184.html 原文链接:http://devicetree.org/Device_Tree_Usa ...
- 學習 DT device tree 以 ST 的開發板 STM32F429i-disc1 為例
目標 因為對 device tree 不是很熟悉, 所以就將 device tree, 設為學習目標. 啟動 注意, 這篇隨筆的解說都放在最下面,會標 Explanation_XX,只要搜尋 Expl ...
- Device Tree(二):基本概念
转自:http://www.wowotech.net/linux_kenrel/dt_basic_concept.html 一.前言 一些背景知识(例如:为何要引入Device Tree,这个机制是用 ...
- Linux and the Device Tree
来之\kernel\Documentation\devicetree\usage-model.txt Linux and the Device Tree ----------------------- ...
- Device Tree(三):代码分析【转】
转自:http://www.wowotech.net/linux_kenrel/dt-code-analysis.html Device Tree(三):代码分析 作者:linuxer 发布于:201 ...
- ARM Linux 3.x的设备树(Device Tree)
http://blog.csdn.net/21cnbao/article/details/8457546 宋宝华 Barry Song <21cnbao@gmail.com> 1. ...
随机推荐
- BZOJ 1834 网络扩容(最大流+费用流)
对于第一问,直接求最大流. 对于第二问,建源点s和汇点t,s连1容量为INF,费用为0的边,n连t容量为最大流+k,费用为0的边.这样就把最大流限制为最多增加k了. 限制需要求扩充的最小费用,原图的边 ...
- Python 断言和异常
Python 断言和异常 Python断言 断言是一种理智检查,当程序的测试完成,可以将其打开或关闭.断言的最简单方法就是把它比作raise-if语句(或更加准确,raise-if-not声明).一个 ...
- Codeforces Gym 101142 G Gangsters in Central City (lca+dfs序+树状数组+set)
题意: 树的根节点为水源,编号为 1 .给定编号为 2, 3, 4, …, n 的点的父节点.已知只有叶子节点都是房子. 有 q 个操作,每个操作可以是下列两者之一: + v ,表示编号为 v 的房子 ...
- python 深浅copy的例子
1. copy.copy 浅拷贝 只拷贝父对象,不会拷贝对象的内部的子对象.2. copy.deepcopy 深拷贝 拷贝对象及其子对象一个很好的例子:import copya = [1, 2, 3, ...
- POJ2352:Stars——题解
http://poj.org/problem?id=2352 Astronomers晚上仰望星空,看到了很多星星.回到办公桌,Astronomers将这些星星画到二维坐标系,每个星星的坐标都是整数.例 ...
- BZOJ3534:[SDOI2014]重建——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=3534 https://www.luogu.org/problemnew/show/P3317 T国 ...
- BZOJ2597 [Wc2007]剪刀石头布 【费用流】
题目链接 BZOJ2597 题解 orz思维差 既然是一张竞赛图,我们选出任意三个点都可能成环 总方案数为 \[{n \choose 3}\] 如果三个点不成环,会发现它们的度数是确定的,入度分别为\ ...
- BZOJ [Ctsc2002] Award 颁奖典礼 解题报告
[Ctsc2002] Award 颁奖典礼 Description IOI2002的颁奖典礼将在YONG-IN Hall隆重举行.人们在经历了充满梦幻的世界杯之后变得更加富于情趣.为了使颁奖典礼更具魅 ...
- 【简单算法】37.Shuffle an Array
题目: 打乱一个没有重复元素的数组. 示例: // 以数字集合 1, 2 和 3 初始化数组. ,,}; Solution solution = new Solution(nums); // 打乱数组 ...
- 【状压DP】【P3959】【NOIP2017D2T2】宝藏
Description 参与考古挖掘的小明得到了一份藏宝图,藏宝图上标出了 $n$ 个深埋在地下的宝藏屋, 也给出了这 $n$ 个宝藏屋之间可供开发的$ m$ 条道路和它们的长度. 小明决心亲自前往挖 ...