没有合适的资源?快使用搜索试试~ 我知道了~
首页linux设备树使用手册(注释版)
linux设备树使用手册(注释版)
需积分: 49 202 下载量 189 浏览量
更新于2023-03-16
评论 8
收藏 995KB PDF 举报
文档主要讲解的是设备树源文件dts的编写方法,包括:dts的主要组成部分和相关的语法格式等。文档中有个人的一些注释说明,如果错误,请留言回复,感谢。
资源详情
资源评论
资源推荐
1 / 67
设备树使用手册
This page walks through how to write a device tree for a new machi
ne. It is intended to provide an overview of device tree concepts and
how they are used to describe a machine.
本文将介绍如何为一个新机器编写设备树。我们准备提供一个有关设备
树概念的概述和如何使用这些设备树来描述一个机器。
For a full technical description of device tree data format, refer to the
ePAPR specification. The ePAPR specification covers a lot more deta
il than the basic topics covered on this page, please refer to it for m
ore advanced usage that isn't covered by this page.
完整的设备树数据格式的技术说明书请参考 ePAPR 规范。ePAPR 规
范涵盖了比本文基本主题更丰富的细节,要查阅本文没有涉及到的高级
用法请参考该规范。
(1)#address-cells:即地址值需要几个cell来描述;
#size-cells:size需要用几个cell来描述,一般size是表示设备的地址范围;
一个celll固定就是一个32bit,因此如果地址需要用64bit表示,那么就需要2个cell;
例:
#address-cells表示用几个cell表示地址,#size-cells表示用几个cell表示地址长度
{
#address-cells = <0x2>; // 在root node下使用2个u32来代表address。
#size-cells = <0x2>; // 在root node下使用2个u32来代表size。
...
memory { // memory device
...
reg = <0x90000000 00000000 0x800000 00000000>;
// 0x90000000 00000000 是存取memory的address
// 0x800000 00000000 是memory的size。
...
};
}
(2)AMBA:arm公司制定的片上总线协议
(3)宋宝华:关于设备树的讲解很到位
(4)对于ARM GIC中断控制器而言,#interrupt-cells为3,它3个cell的具体含义Documentation/devicetree/bindings/arm/
gic.txt就有如下文字说明:
01 The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI
02 interrupts.
04 The 2nd cell contains the interrupt number for the interrupt type.
05 SPI interrupts are in the range [0-987]. PPI interrupts are in the
06 range [0-15].
07
2 / 67
目 录
设备树使用手册 ............................................................................................................................... 1
1.基本数据格式 ................................................................................................................................ 3
2.基本概念........................................................................................................................................ 6
2.1.模型机 ................................................................................................................................. 6
2.2 初始结构 ............................................................................................................................. 8
2.3.中央处理器 ....................................................................................................................... 10
2.4.节点名称 ........................................................................................................................... 11
2.5.设备 ................................................................................................................................... 13
2.6.理解 compatible 属性 ..................................................................................................... 17
3.如何编址...................................................................................................................................... 20
3.1.CPU 编址 .......................................................................................................................... 21
3.2.内存映射设备 ................................................................................................................... 23
3.3.非内存映射设备 ............................................................................................................... 28
3.4.范围(地址转换) ........................................................................................................... 30
4.中断如何工作 .............................................................................................................................. 36
4.1 需要注意的事情: ........................................................................................................... 43
5.设备特定数据 .............................................................................................................................. 45
6.特殊节点...................................................................................................................................... 47
6.1. 1aliases 节点 ................................................................................................................... 47
6.2. chosen 节点...................................................................................................................... 48
7.高级主题...................................................................................................................................... 50
7.1 高级模型机 ...................................................................................................................... 50
7.2.PCI 主桥 ......................................................................................................................... 51
7.2.1PCI 总线编号 ......................................................................................................... 52
7.2.2 PCI 地址转换 ........................................................................................................ 53
7.3 高级中断映射 .................................................................................................................. 58
8.附注 ............................................................................................................................................. 67
08 The 3rd cell is the flags, encoded as follows:
09 bits[3:0] trigger type and level flags.
10 1 = low-to-high edge triggered
11 2 = high-to-low edge triggered
12 4 = active high level-sensitive
13 8 = active low level-sensitive
14 bits[15:8] PPI interrupt cpu mask. Each bit corresponds to each of
15 the 8 possible cpus attached to the GIC. A bit set to '1' indicated
16 the interrupt is wired to that CPU. Only valid for PPI interrupts.
另外,值得注意的是,一个设备还可能用到多个中断号。对于ARM GIC而言,若某设备使用了SPI的168、169号2个中断,而言都是高电平触发,则该设备结点
的interrupts属性可定义为:interrupts = <0 168 4>, <0 169 4>;
但是,xilinx的dts中,sd1的中断描述:interrupts = <0x0 0x2f 0x4>;中断号是0x2f,即47,这是因为spi中断是从第32开始的,真正的中断号需要计算:
32+47=79,正确。
3 / 67
Basic Data Format
1.基本数据格式
-----------------------------------------
The device tree is a simple tree structure of nodes and properties. Pro
perties are key-value pairs, and node may contain both properties and
child nodes. For example, the following is a simple tree in the .dts f
ormat:
设备树是一个包含节点和属性的简单树状结构。属性就是键-值对,而
节点可以同时包含属性和子节点。例如,以下就是一个 .dts 格式的简
单树:
/ {
node1 {
a-string-property = "A string";
a-string-list-property = "first string", "second string";
a-byte-data-property = [0x01 0x23 0x34 0x56];
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 {
};
};
4 / 67
};
This tree is obviously pretty useless because it doesn't describe anythi
ng, but it does show the structure of nodes an properties. There is:
这棵树显然是没什么用的,因为它并没有描述任何东西,但它确实体现
了节点的一些属性:
■ a single root node: "/"
一个单独的根节点:“/”
■ a couple of child nodes: "node1" and "node2"
两个子节点:“node1”和“node2”
■ a couple of children for node1: "child-node1" and "child-node2"
两个 node1 的子节点:“child-node1”和“child-node2”
■ a bunch of properties scattered through the tree.
一堆分散在树里的属性。
Properties are simple key-value pairs where the value can either be e
mpty or contain an arbitrary byte stream. While data types are not en
coded into the data structure, there are a few fundamental data repres
entations that can be expressed in a device tree source file.
属性是简单的键-值对,它的值可以为空或者包含一个任意字节流。虽
然数据类型并没有编码进数据结构,但在设备树源文件中任有几个基本
的数据表示形式。
■ Text strings (null terminated) are represented with double quotes:
文本字符串(无结束符)可以用双引号表示:
string-property = "a string"
■ 'Cells' are 32 bit unsigned integers delimited by angle brackets:
‘Cells’是 32 位无符号整数,用尖括号限定:
5 / 67
cell-property = <0xbeef 123 0xabcd1234>
■ binary data is delimited with square brackets:
二进制数据用方括号限定:
binary-property = [0x01 0x23 0x45 0x67];
■ Data of differing representations can be concatenated together usin
g a comma:
不同表示形式的数据可以使用逗号连在一起:
mixed-property = "a string", [0x01 0x23 0x45 0x67], <0x12345678>;
■ Commas are also used to create lists of strings:
逗号也可用于创建字符串列表:
string-list = "red fish", "blue fish";
剩余66页未读,继续阅读
Ye__sea
- 粉丝: 85
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0