Syntax of the device tree

The device tree source file also needs to be written according to certain rules, just like C language, it also needs to follow some grammatical rules.
1. Node format
label: node-name@unit-address
label: label
node-name: node name
unit-address: unit address

label is a label and can be ignored. The function of label is to refer to node conveniently.

/{
    
    
	uart0:uart@FE001000{
    
    
		compatible="ns16550"
		reg=<0xFE001000 0x100>
	};
};

You can use the following two methods to modify the node uart@fe001000:

&uart0{
    
    
	status = "disabled";
};
/* or */
&{
    
    /uart@FE001000} {
    
    
	status = "disabled";
}

2. Attribute format
Simply put, properties is "name=value", and value has multiple ways of taking values.
A 32-bit data, surrounded by angle brackets:
interrupts = <17 0xc>;
a 64-bit data (represented by two 32-bit data), surrounded by angle brackets:
clock-frequency = <0x00000001 0x00000000>;
there is an end character string, surrounded by double quotes:
compatible = “simple-bus”;
byte sequence, surrounded by square brackets, such as:
local-mac-address = [00 00 12 34 56 78];
local-mac- address = [000012345678];
can be a combination of various values, separated by commas
compatible = “ns16550”, “ns8250”;
example = <0xf00f0000 19>, “a strange property format”;

3. Some standard attributes
(1) The compatible attribute
"compatible" means "compatible". For a certain LED, there may be three drivers A, B, and C in the kernel that support it, so it can be written like this: led { compatible =
" A ", "B", "C"; }; When the kernel starts, it will find a driver for this LED in this order of priority: A, B, C. (2) model attribute The model attribute is somewhat similar to the compatible attribute, but there are differences. The compatible attribute is a list of strings, indicating that your hardware is compatible with drivers such as A, B, and C; the model is used to accurately define what the hardware is. For example, the root node can be written like this:




/ { compatible = "samsung,smdk2440", "samsung,mini2440"; model = "jz2440_v3"; }; It means that this single board is compatible with "smdk2440" in the kernel and "mini2440". From the compatible attribute, you can know which boards it is compatible with, but what board is it? Use the model attribute to specify. The status attribute is related to the status of the device just by looking at the name. The value of the status attribute is also a string, which is the status information of the device. The optional status is as follows:




value describe
“okey” "indicating that the device is operational"
“disabled” "It indicates that the device is currently inoperable, but it can become operable in the future, for example, after a hot-swappable device is plugged in. As for the specific meaning of disabled, it depends on the binding document of the device."
“fail” "indicates that the device is inoperable, that the device has detected a series of errors, and that the device is unlikely to become operable"
“fail-sss” The meaning is the same as "fail", and the following sss part is the detected error content

Guess you like

Origin blog.csdn.net/Cloud_1234_5678/article/details/110225051