“#address-cells, #size-cells”属性用来定义当前node的子node中”reg”属性的解析格式。并且单位都是u32,即#address-cells = <1> ,#size-cells = <1>,中的1代表一个32位。详情见后面的例子。
Property name: #address-cells, #size-cells
Value type:
Description: The #address-cells and #size-cells properties may be used in any device node that has children in the devicetree hierarchy and describes how child device nodes should be addressed. The #address-cells property defines the number of cells used to encode the address field in a child node’s reg property. The #size-cells property defines the number of cells used to encode the size field in a child node’s reg property.
The #address-cells and #size-cells properties are not inherited from ancestors in the devicetree. They shall be explicitly defined.
A DTSpec-compliant boot program shall supply #address-cells and #size-cells on all nodes that have children.
If missing, a client program should assume a default value of 2 for #address-cells, and a value of 1 for #size-cells.
Example: See the following devicetree excerpt:
soc {
#address-cells = <1>;
#size-cells = <1>;
serial {
compatible = “ns16550”;
reg = <0x4600 0x100>;
clock-frequency = <0>;
interrupts = <0xA 0x8>;
interrupt-parent = <&ipic>;
};
};
In this example, the #address-cells and #size-cells properties of the soc node are both set to 1. This setting specifies that one cell is required to represent an address and one cell is required to represent the size of nodes that are children of this node.
The serial device reg property necessarily follows this specification set in the parent (soc) node—the address is represented by a single cell (0x4600), and the size is represented by a single cell (0x100).
举例说明:
1、如果node”soc”中”#address-cells=<1>”、”#size-cells=<1>”,那么子node”serial”中”reg”属性的解析为“addr1 = 0x0, size1 = 0x100, addr2 = 0x0, size2 = 0x200”:
soc {
#address-cells = <1>;
#size-cells = <1>;
serial {
reg = <0x0 0x100 0x0 0x200>;
}
}
2、如果node”soc”中”#address-cells=<2>”、”#size-cells=<2>”,那么子node”serial”中”reg”属性的解析为“addr1 = 0x100, size1 = 0x200”:
soc {
#address-cells = <2>;
#size-cells = <2>;
serial {
reg = <0x0 0x100 0x0 0x200>;
}
}
3、如果node”soc”中”#address-cells=<2>”、”#size-cells=<0>”,那么子node”serial”中”reg”属性的解析为“addr1 = 0x100, addr2 = 0x200”:
soc {
#address-cells = <2>;
#size-cells = <0>;
serial {
reg = <0x0 0x100 0x0 0x200>;
}
}