学习整理:ARM Linux设备树(DTS)

2 分钟阅读

  • DTS: Device Tree Source,以文本形式描述DeviceTree
  • 通常所在目录kernel/arch/arm/boot/dts
  • dtc工具将test.dts文件,生成test.dtb文件;fdtdump工具可以将test.dtb文件,解析成test.dts文件
  • 参考链接:https://elinux.org/Device_Tree_Usage

语法说明

name

<name>[@<unit-address>]

name描述设备类型,比如网口宜用ethernet;如果有地址,则用@指定地址。

举例:

cpus {}
serial@101F2000 { }
ethernet@0,0 {}

compatible

compatible = "<manufacturer>,<model>" [, "model"]

manufacturer指定厂家名,model指定特定设备型号,后续的model指定兼容的设备型号。

举例:

compatible = "smc, smc91c11";
compatible = "samsung,k8f1315ebm", "cfi-flash";

address

#address-cells = <1>: 基地址、片选号等绝对起始地址所占字长,单位uint32

#size-cells = <1>: 长度所占字长,单位uint32

reg = <addr1 len1 [addr2 len2] [addr3 len3]>...: addr表明基址,len表明长度,addr由#address-cells个uint32值组成,len由#size-cells个uint32值组成

interrupt

interrupt-controller: 表明接收中断信号

#interrupt-cells = <3>: 中断描述法的个数

interrupt-parent = <&intc>: 指定结点所属中断控制器,若没有则依附父结点

interrupts = <0 168 4> [, <0 169 4>]: 指定中断输出信号

举例:

gic: interrupt-controller {
	compatible = "arm,cortex-a15-gic";
	ranges;
	#size-cells = <0x2>;
	#address-cells = <0x2>;
	interrupt-controller;
	#interrupt-cells = <0x3>;
	reg = <0x0 0x03001000 0x0 0x10000>,
		  <0x0 0x03002000 0x0 0x10000>;
};