linux设备树中的#address-cells 、 #size-cells

“#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>;
}
}

  • 9
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值