Linux设备驱动之devicetree(2)

virtual-reg

Value type: <stringlist> Description: 表示映射到reg第一个物理地址对应的effective address。使bootloader能够提供给内核它所建立的virtual-to-physical mappings。

ranges

Value type: <empty> or <prop-encoded-array> encoded as an arbitrary number of (child-bus-address,parent-bus-address, length) triplets. Description: 提供了子地址空间与父地址空间的映射关系,如果值为空则父子地址相等,无需转换。 Example: soc { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges = <0x0 0xe0000000 0x00100000>; serial { compatible = "ns16550"; reg = <0x4600 0x100>; }; }; 将子节点serial的0x0地址映射到父节点soc的0xe0000000,映射长度为0x100000。此时reg的实际物理地址就为0xe0004600

dma-ranges

Value type: <empty> or <prop-encoded-array> encoded as an arbitrary number of (child-bus-address,parent-bus-address, length) triplets. Description: 提供了dma地址的映射方法。

Interrupts

描述中断的属性有4个:

interrupt-controller

一个空的属性用来指示这个节点设备是接收中断信号的控制器。

#interrupt-cells

这是上面所说中断控制器中的一个属性,用来描述需要用多少个cell来描述这个中断控制器的interrupt specifier(类似#address-cells#size-cells)。

interrupt-parent

常出现在根节点的一个属性,它的属性值是指向interrupt-controller的一个phandle。可从parent继承。

interrupts

包含interrupt specifiers列表,每一个specifier表示一个中断输出信号。

Example

/ { interrupt-parent = <&intc>; intc: interrupt-controller@10140000 { compatible = "arm,pl190"; reg = <0x10140000 0x1000 >; interrupt-controller; #interrupt-cells = <2>; }; serial@101f0000 { interrupts = < 1 0 >; }; }; Base Device Node Types

所有的设备树都必须有一个root节点,且root节点下必须包含一个cpus节点和至少一个memory节点。

root node

root节点须包含 #address-cells#size-cellsmodelcompatible等属性。

/cpus node

cpu子节点的父节点容器。须包含 #address-cells#size-cells属性。

/cpus/cpu* node

是描述系统cpu的节点。

/memory node

描述系统物理内存的layout。须包含reg节点。 Example: 假如一个64位系统有如下两块物理内存: - RAM: starting address 0x0, length 0x80000000 (2GB) - RAM: starting address 0x100000000, length 0x100000000 (4GB) 则我们可以有下面两种描述方法(#address-cells = <2> and #size-cells =<2>): Example #1 memory@0 { reg = <0x000000000 0x00000000 0x00000000 0x80000000 0x000000001 0x00000000 0x00000001 0x00000000>; }; Example #2 memory@0 { reg = <0x000000000 0x00000000 0x00000000 0x80000000>; }; memory@100000000 { reg = <0x000000001 0x00000000 0x00000001 0x00000000>; };

/chosen node

根节点下的一个子节点,不是描述设备而是描述运行时参数。常用来给内核传递bootargs: chosen { bootargs = "root=/dev/nfs rw nfsroot=192.168.1.1 console=ttyS0,115200"; };

/aliases node

1-31个字母、数字或下划线组成的设备节点full path的别名。它的值是节点的全路径,因此最终会被编码成字符串。 aliases { serial0 = "/simple-bus@fe000000/serial@llc500"; }

Device Bindings

更多具体设备具体类别的描述信息:内核源代码/Documentation/devicetree/bindings。

DTS是描述devicetree的源文本文件,它通过内核中的DTC(Devicetree Compiler)编译后生成相应平台可烧写的二进制DTB。

Devicetree Blob (DTB) Structure

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/c110673736539f04acb4f2497aa9a094.html