博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
设备树 记录
阅读量:3558 次
发布时间:2019-05-20

本文共 5713 字,大约阅读时间需要 19 分钟。

记录些设备树相关的规范。

1. 节点, 属性, 值

2. compatible,  匹配/兼容的驱动名称, OpenFirm框架会去寻找相应的驱动

3. 寄存器

amba_apu: amba_apu@0 {                                                                                       	compatible = "simple-bus";                                                                               	#address-cells = <2>;                                                                                   	#size-cells = <1>;                                                                                       	ranges = <0 0 0 0 0xffffffff>;                                                                          																												gic: interrupt-controller@f9010000 {                                                                    		compatible = "arm,gic-400", "arm,cortex-a15-gic";                                                   		#interrupt-cells = <3>;                                                                             		reg = <0x0 0xf9010000 0x10000>,                                                                     				<0x0 0xf9020000 0x20000>,                                                                     				<0x0 0xf9040000 0x20000>,                                                                     				<0x0 0xf9060000 0x20000>;                                                                     		interrupt-controller;                                                                               		interrupt-parent = <&gic>;                                                                          		interrupts = <1 9 0xf04>;                                                                           	};                                                                                                      };

address-cells: 地址单元,  = 2, 代表reg属性中2个32位数代表一个地址

size-cells: 长度单元, =1, 代表reg属性中1个32位数代表一个长度

4. 中断

还以上述为例,

interrupt-controller,  空键值的属性。代表该节点是一个中断控制器。 是的, gic是一个中断控制器。(包括gpio等, 都可抽象为中断控制器)

interrupt-parent: 由于中断数目众多, 现在多采用树状结构,  即最终到arm core的 irq num 是由各个/各层中断控制器汇总而来。

interrupts:  具体的中断信息, 其中数值代表的含义 跟 其中的interrupt-cells 属性有关。 上述例子中 interrupt-cells = 3,  代表中断由三个数据域组成。 <1(中断域), 9(中断号), 0xf04(触发条件)>

参考/Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt

The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI                                                                                 interrupts.                                                                                                                                                                                                                                                                                             The 2nd cell contains the interrupt number for the interrupt type.                                                                                  SPI interrupts are in the range [0-987].  PPI interrupts are in the                                                                                 range [0-15].                                                                                                                                                                                                                                                                                           The 3rd cell is the flags, encoded as follows:                                                                                                    ›   bits[3:0] trigger type and level flags.                                                                                                         ›   ›   1 = low-to-high edge triggered                                                                                                              ›   ›   2 = high-to-low edge triggered (invalid for SPIs)                                                                                           ›   ›   4 = active high level-sensitive                                                                                                             ›   ›   8 = active low level-sensitive (invalid for SPIs).                                                                                          ›   bits[15:8] PPI interrupt cpu mask.  Each bit corresponds to each of                                                                             ›   the 8 possible cpus attached to the GIC.  A bit set to '1' indicated                                                                            ›   the interrupt is wired to that CPU.  Only valid for PPI interrupts.                                                                             ›   Also note that the configurability of PPI interrupts is IMPLEMENTATION                                                                          ›   DEFINED and as such not guaranteed to be present (most SoC available                                                                            ›   in 2014 seem to ignore the setting of this flag and use the hardware                                                                            ›   default value).

故上述 <1 9 0xf04> 含义为:

1号中断域

9号中断号

PPI中断, 绑定cpu0,1,2,3,  高电平有效


此处记录下ARM架构中断相关。

arm cpu核心有7种异常模式(armv8 多了2种,  hypervisor和monitor模式)

跟中断相关的是其中两种,  irq和fiq, 对应两根pin。

 

故外部必然有中断控制器进行拓展并管理。

从中断控制器角度 看 外部来的中断, 常用的可分为3种,

- SGI, Software-Generated Interrupt, 软件中断(不等同于swi), 软件可以通过中断控制器的GICD_SGIR寄存器来触发一个中断事件,  即会触发irq中断。 此类中断可用于多核的核间通信。例如 cpu0 写GICD_SGIR寄存器 触发cpu1 irq。SGI统一编号0~15。

- PPI, Private Peripheral Interrupt, 私有的外设中断, 该PPI只能分配给特定的处理器。统一编号16-31。每个cpu的local timmer即arch timmer产生的中断就是通过PPI发给cpu的。

- SPI, Shared Peripheral Interrupt, 共享的外设中断, 即各个cpu核心都可以收到该中断。 统一编号32~1019。 常见的global timmer, uart, gpio, usb等等外设控制器都通过该中断通知cpu核心。

其他还有虚拟中断和Maintenace interrupt, 暂不讨论。


贴张常见的图

 

你可能感兴趣的文章
小甲鱼Python第三讲(小插曲之变量和字符串)
查看>>
小甲鱼Python第十一讲(一个打了激素的数组2)
查看>>
小甲鱼Python第十三讲(戴上了枷锁的列表)
查看>>
小甲鱼Python第十四讲(各种奇葩的内置方法)
查看>>
小甲鱼Python第十五讲(格式化)
查看>>
小甲鱼Python第十七讲(Python的乐高积木)
查看>>
小甲鱼Python第十九讲(函数,我的地盘听我的)
查看>>
小甲鱼python第二十讲(内嵌函数和闭包)
查看>>
小甲鱼Python第二十一讲(lambda表达式)
查看>>
小甲鱼Python第二十三讲、第二十四讲(递归-这帮小兔崽子、汉诺塔)
查看>>
小甲鱼Python第二十七讲(集合)
查看>>
可调谐半导体激光器的窄线宽测试及压缩
查看>>
matlab中 %d,%f,%c,%s
查看>>
常见的光纤接头汇总
查看>>
半导体激光器—问题整理(二)
查看>>
科研日记7.31
查看>>
zemax仿真二向色镜
查看>>
stm32单片机编程时extern的用法
查看>>
UART4和5的问题
查看>>
Spring框架中在并发访问时的线程安全性
查看>>