logo资料库

linux设备树使用手册(注释版).pdf

第1页 / 共67页
第2页 / 共67页
第3页 / 共67页
第4页 / 共67页
第5页 / 共67页
第6页 / 共67页
第7页 / 共67页
第8页 / 共67页
资料共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 / 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 2 / 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 { }; }; 3 / 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 位无符号整数,用尖括号限定: 4 / 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"; 5 / 67
Basic Concepts 2.基本概念 ----------------------------------------- To understand how the device tree is used, we will start with a simple machine and build up a device tree to describe it s tep by step. 我们将以一个简单机开始,然后通过一步步的建立一个描述这个简单机 的设备树,来了解如何使用设备树。 Sample Machine 2.1.模型机 Consider the following imaginary machine (loosely based on AR M Versatile), manufactured by "Acme" and named "Coyote's Reve nge": 考虑下面这个假想的机器(大致基于 ARM Versatile),制造商为“Ac me”,并命名为“Coyote's Revenge”: ■ One 32bit ARM CPU 一个 32 位 ARM CPU 6 / 67
■ processor local bus attached to memory mapped serial po rt, spi bus controller, i2c controller, interrupt controller, and external bus bridge 处理器本地总线连接到内存映射的串行口、spi 总线控制器、i 2c 控制器、中断控制器和外部总线桥 ■ 256MB of SDRAM based at 0 256MB SDRAM 起始地址为 0 ■ 2 Serial ports based at 0x101F1000 and 0x101F2000 两个串口起始地址:0x101F1000 和 0x101F2000 ■ GPIO controller based at 0x101F3000 GPIO 控制器起始地址:0x101F3000 ■ SPI controller based at 0x10170000 with following devic es 带有以下设备的 SPI 控制器起始地址:0x10170000 ■ MMC slot with SS pin attached to GPIO #1 MMC 插槽的 SS 管脚连接至 GPIO #1 ■ External bus bridge with following devices 外部总线桥挂载以下设备 ■ SMC SMC91111 Ethernet device attached to external bus based at 0x10100000 SMC SMC91111 以太网设备连接到外部总线,起始地址: 0x10100000 7 / 67
■ i2c controller based at 0x10160000 with following devices i2c 控制器起始地址:0x10160000,并挂载以下设备 ■ Maxim DS1338 real time clock. Responds to s lave address 1101000 (0x58) Maxim DS1338 实时时钟。响应至从地址 1101000 (0x58) ■ 64MB of NOR flash based at 0x30000000 64MB NOR 闪存起始地址 0x30000000 Initial structure 2.2 初始结构 The first step is to lay down a skeleton structure for the ma chine. This is the bare minimum structure required for a vali d device tree. At this stage you want to uniquely identify th e machine. 8 / 67
分享到:
收藏