理解Device Tree Usage
2019-03-13 23:30:43来源:博客园 阅读 ()
基础数据结构
/dts-v1/; / { node1 { a-string-property = "A string"; a-string-list-property = "first string", "second string"; // hex is implied in byte arrays. no '0x' prefix is required a-byte-data-property = [01 23 34 56]; child-node1 { first-child-property; second-child-property = <1>; a-string-property = "Hello, world"; }; child-node2 { }; }; node2 { an-empty-property; a-cell-property = <1 2 3 4>; /* each number (cell) is a uint32 */ child-node1 { }; }; };
-
一个简单的root节点:“/”
-
一组子节点:“node1”和“node2”
-
一组node1的子节点:“child-node1”和“child-node2”
-
一堆分散在设备树中的属性
-
文本字符串(以null结尾),用双引号表示:
-
string-property = "a string";
-
‘cell’是被<>括号括起来的32bit无符号int数
-
cell-property = <0xbeef 123 0xabcd1234>;
-
二进制数据是被[]括号括起来
-
binary-property = [0x01 0x23 0x45 0x67];
-
不同类型的数据,可以以逗号“,”串起来
-
mixed-property = "a string", [0x01 0x23 0x45 0x67], <0x12345678>;
-
逗号“,”也可以用来表示字符串列表:
-
string-list = "red fish", "blue fish";
基础概念Basic Concepts
-
一个32位宽的ARM CPU
-
处理器本地总线连接到内存映射串口、spi总线控制器、i2c控制器、中断控制器和外部总线桥
-
从0地址开始的256MB 字节的SDRAM
-
2个串口,寄存器基地址分别是0x101F1000和0x101F2000
-
GPIO的控制寄存器的基地址是0x101F3000
-
SPI的控制寄存器的基地址是0x10170000,并挂载下列设备
-
MMC slot,SS管脚连接到GPIO1
-
外部总线桥接着下列设备
-
SMC SMC91111网络设备连接到外部总线,基地址是0x10100000
-
i2c 控制寄存器基地址是0x10160000,并挂载下列设备
-
Maxim DS1338实时时钟,其地址是1101000(0x58)
-
64M的Nor flash基地址是0x30000000
初始化结构体(Initial structure)
/dts-v1/; / { compatible = "acme,coyotes-revenge"; };
CPUs
/dts-v1/; / { compatible = "acme,coyotes-revenge"; cpus { cpu@0 { compatible = "arm,cortex-a9"; }; cpu@1 { compatible = "arm,cortex-a9"; }; }; };
设备(Devices)
/dts-v1/; / { compatible = "acme,coyotes-revenge"; cpus { cpu@0 { compatible = "arm,cortex-a9"; }; cpu@1 { compatible = "arm,cortex-a9"; }; }; serial@101F0000 { compatible = "arm,pl011"; }; serial@101F2000 { compatible = "arm,pl011"; }; gpio@101F3000 { compatible = "arm,pl061"; }; interrupt-controller@10140000 { compatible = "arm,pl190"; }; spi@10115000 { compatible = "arm,pl022"; }; external-bus { ethernet@0,0 { compatible = "smc,smc91c111"; }; i2c@1,0 { compatible = "acme,a1234-i2c-bus"; rtc@58 { compatible = "maxim,ds1338"; }; }; flash@2,0 { compatible = "samsung,k8f1315ebm", "cfi-flash"; }; }; };
-
每一个节点都有一个“compatible”属性
-
flash节点的“compatible”属性包含了两个字符串,下一节将说明为什么
-
就像之前提到的,节点名字反映的是设备的种类,而不是代表具体的品牌型号。 请参阅ePAPR规范的2.2.2节,其中列出了已定义的通用节点名。应该尽可能使用这些节点名,而不要发明新的名字。
理解“compatible”属性
如何寻址(How addressing work)
* reg * #address-cells * #size-cells
CPU寻址
cpus { #address-cells = <1>; #size-cells = <0>; cpu@0 { compatible = "arm,cortex-a9"; reg = <0>; }; cpu@1 { compatible = "arm,cortex-a9"; reg = <1>; }; };
内存映射设备
/dts-v1/; / { #address-cells = <1>; #size-cells = <1>; ... serial@101f0000 { compatible = "arm,pl011"; reg = <0x101f0000 0x1000 >; }; serial@101f2000 { compatible = "arm,pl011"; reg = <0x101f2000 0x1000 >; }; gpio@101f3000 { compatible = "arm,pl061"; reg = <0x101f3000 0x1000 0x101f4000 0x0010>; }; interrupt-controller@10140000 { compatible = "arm,pl190"; reg = <0x10140000 0x1000 >; }; spi@10115000 { compatible = "arm,pl022"; reg = <0x10115000 0x1000 >; }; ... };
external-bus { #address-cells = <2>; #size-cells = <1>; ethernet@0,0 { compatible = "smc,smc91c111"; reg = <0 0 0x1000>; }; i2c@1,0 { compatible = "acme,a1234-i2c-bus"; reg = <1 0 0x1000>; rtc@58 { compatible = "maxim,ds1338"; }; }; flash@2,0 { compatible = "samsung,k8f1315ebm", "cfi-flash"; reg = <2 0 0x4000000>; }; };
非内存映射设备
i2c@1,0 { compatible = "acme,a1234-i2c-bus"; #address-cells = <1>; #size-cells = <0>; reg = <1 0 0x1000>; rtc@58 { compatible = "maxim,ds1338"; reg = <58>; }; };
ranges(地址转换)
/dts-v1/; / { compatible = "acme,coyotes-revenge"; #address-cells = <1>; #size-cells = <1>; ... external-bus { #address-cells = <2> #size-cells = <1>; ranges = <0 0 0x10100000 0x10000 // Chipselect 1, Ethernet 1 0 0x10160000 0x10000 // Chipselect 2, i2c controller 2 0 0x30000000 0x1000000>; // Chipselect 3, NOR Flash ethernet@0,0 { compatible = "smc,smc91c111"; reg = <0 0 0x1000>; }; i2c@1,0 { compatible = "acme,a1234-i2c-bus"; #address-cells = <1>; #size-cells = <0>; reg = <1 0 0x1000>; rtc@58 { compatible = "maxim,ds1338"; reg = <58>; }; }; flash@2,0 { compatible = "samsung,k8f1315ebm", "cfi-flash"; reg = <2 0 0x4000000>; }; }; };
* Offset 0 from chip select 0 is mapped to address range 0x10100000..0x1010ffff * Offset 0 from chip select 1 is mapped to address range 0x10160000..0x1016ffff * Offset 0 from chip select 2 is mapped to address range 0x30000000..0x30ffffff
原文链接:https://www.cnblogs.com/djw316/p/10524820.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- 系统对 Device Tree Overlays 的支持方式 2020-05-22
- 【读书笔记】https://source.android.google.cn/devices/boo 2020-02-06
- Bringing up interface eth0: Device eth0 does not seem to 2020-01-18
- Linux性能调优 | 01 平均负载的理解和分析 2019-11-05
- 深入理解perf报告中的swapper进程 2019-09-30
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash