本系列导航:
高通平台8953 Linux DTS(Device Tree Source)设备树详解之一(背景基础知识篇)
高通平台8953 Linux DTS(Device Tree Source)设备树详解之二(DTS设备树匹配过程)
高通平台8953 Linux DTS(Device Tree Source)设备树详解之三(高通MSM8953 android7.1实例分析篇)
有上一篇文章,我们了解了dts的背景知识和相关基础,这次我们对应实际设备进行一下相关分析。
DTS设备树的匹配过程
一个dts文件确定一个项目,多个项目可以包含同一个dtsi文件。找到该项目对应的dts文件即找到了该设备树的根节点。
kernel\arch\arm\boot\dts\qcom\sdm630-mtp.dts
- /* Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- /dts-v1/;
- #include "sdm630.dtsi"
- #include "sdm630-mtp.dtsi"
- //#include "sdm660-external-codec.dtsi"
- #include "sdm660-internal-codec.dtsi"
- #include "synaptics-dsx-i2c.dtsi"
- / {
- model = "Qualcomm Technologies, Inc. SDM 630 PM660 + PM660L MTP";
- compatible = "qcom,sdm630-mtp", "qcom,sdm630", "qcom,mtp";
- qcom,board-id = <8 0>;
- qcom,pmic-id = <0x0001001b 0x0101011a 0x0 0x0>,
- <0x0001001b 0x0201011a 0x0 0x0>;
- };
- &tavil_snd {
- qcom,msm-mbhc-moist-cfg = <0>, <0>, <3>;
- };
当然devicetree的根节点也是需要和板子进行匹配的,这个匹配信息存放在sbl(second boot loader)中,对应dts文件中描述的board-id(上面代码中的qcom,board-id属性),通过共享内存传递给bootloader,由bootloader将此board-id匹配dts文件(devicetree的根节点文件),将由dtc编译后的dts文件(dtb文件)加载到内存,然后在kernel中展开dts树,并且挂载dts树上的所有设备。
(ps:cat /proc/cmdline 查看cmdline)
Dts中相关符号的含义
/ 根节点
@ 如果设备有地址,则由此符号指定
& 引用节点
: 冒号前的label是为了方便引用给节点起的别名,此label一般使用为&label
, 属性名称中可以包含逗号。如compatible属性的名字 组成方式为"[manufacturer], [model]",加入厂商名是为了避免重名。自定义属性名中通常也要有厂商名,并以逗号分隔。
# #并不表示注释。如 #address-cells ,#size-cells 用来决定reg属性的格式。
空属性并不一定表示没有赋值。如 interrupt-controller 一个空属性用来声明这个node接收中断信号
数据类型
“” 引号中的为字符串,字符串数组:”strint1”,”string2”,”string3”
< > 尖括号中的为32位整形数字,整形数组<12 3 4>
[ ] 方括号中的为32位十六进制数,十六机制数据[0x11 0x12 0x13] 其中0x可省略
构成节点名的有效字符: