Device Tree basic overview


1. Device Tree


Device Tree (Device Tree) is a data structure description of the hardware.
Role: Provides device information.
Time: When the operating system boot device initialization stage, the hardware structure of the information data is detected and passed to the operating system.
Device Tree source file (xxxx.dts) DTC device tree compiled binary files (xxxx.dtb)


2. The basic syntax tree equipment


The basic unit of the apparatus is a node of the tree (node), which are organized into a tree structure node, except the root node, each node has only one parent node, a device tree file can have only one root node. Each node contains a number of characteristics of a number of key-value pairs (property / value) described in the node. Each node identified by node name. (Similar to the linux file system)

/{                                            //根节点
	Property = value;                         //描述信息
	<name>[@<unit-address>]{                  //子节点
		Property = value                      //描述信息
	};
	……
};

3. The node name naming convention


The format is the name of the node [@]. If the node is not a reg property, then the node name can not include the @ unit-address. The specific format and unit-address is associated on which to hang the device bus. For example, the CPU, unit-address which is addressed from zero, in order to add 1 to a specific device, such as an Ethernet controller, which is unit-address register address. The name of the root node is determined, it must be "/."

reg = <0x10001000 0x24 0x20001000 0x24>;

4. Node aliases


A device may use the content of other nodes can be referenced to its content by the alias nodes. Reference purposes may be combined contents of the two nodes, part replacement, or use parts.

/{                                            //根节点
	demo:demo0@0x48000000{
		compatible = “xxx”;
	};
	……
};

Node Name: demo0 @ 0x48000000
node path: / demo0 @ 0x48000000
node alias: Demo
Demo == / demo0 80000000 @

Reference:

1&demo{
	Reg = <0x10001000 4 0x20001000 4>
	……
};
2./{
	reference-node{
		property = <&demo>;
		……
	};
};

The combined node content


A part of the information hardware device does not change, but the other part of the information is likely to change, there have been merged node content. Namely: the preparation of a good first node, only the part of the attribute value is described; adding a portion of the user attribute values. In the parallel path, the node name of the same "two" nodes will merge into a real node. (Similar to the namespace in c ++)


6. The device tree key-value pairs associated syntax


[1]. String information

compatible = "随风,飘落";

[2]. 32-bit unsigned integer array

word-array = <32 45 67 89>; 
reg = <0x10001000 0x24 0x20001000 0x24>;

[3] The binary array

bi-array = [0c 20 11 24]; 
mac = [FE 02 11 CB 40 58];

[4]. Array of characters

string-list = "aaa" , "bbb" , "ccc";

7. The default attribute meaning


[1] The device tree grammar has been defined, the meaning attribute has a general specification node device if the device information and the driver separation frame, it is possible to find when the node kernel initialization, the device automatically generates the corresponding analytical information.
Common properties are: compatible, address address, interrupt interrupt
simple example:
compatible properties: a matching device and the node device driver property, the rule is a value of the table drive apparatus compatible ID field (string), and the device tree compatible node device attribute value exactly. compatible = "vendor name, device name";

struct platform_driver {
	int (*probe)(struct platform_device *);
	int (*remove)(struct platform_device *);
	struct device_driver driver;
	const struct platform_device_id *id_table;
};
struct device_driver {
	const char		*name;
	struct bus_type		*bus;
	struct module		*owner;
	const struct of_device_id	*of_match_table;
};
struct of_device_id
{
	char	compatible[128];      //用来和设备树中的compatible属性进行匹配
};

[2]. ARM Linux kernel defined, a generic device class attributes have a default meaning the kernel can not be resolved automatically generate the corresponding device information, but the core has been prepared by direct extraction of the respective functions.
Common attributes are: MAC address, GPIO, clock ...

GPIO properties:
gpio-Controller: Description is a description of the node controller gpio
# gpio-cells: description attribute gpio cell content using a node of
the attribute name = <node alias & GPIO GPIO reference numerals operating mode>;
EG: GPIOs = <& gpx0 1 1>;

supplement

Device node structure description related information

struct device_node {
	const char *name;			//名字
	const char *type;			//类型
	char	*full_name;			//节点全名
}
发布了3 篇原创文章 · 获赞 22 · 访问量 1157

Guess you like

Origin blog.csdn.net/xjpyinxll/article/details/104547109