裝置樹中address-cells和size-cells的含義
阿新 • • 發佈:2019-01-01
#address-cells = <1>;基地址、片選號等絕對起始地址所佔字長(32位)
#size-cells = <1>; 長度所佔字長(32位)
譬如
cpus {
#address-cells = <1>;
#size-cells = <0>;
[email protected] {
compatible = "arm,cortex-a9";
reg = <0>;
};
[email protected] {
compatible = "arm,cortex-a9";
reg = <1>;
};
};
#address-cells 設定為 1,#size-cells 設定為 0。這意味著子節點的 reg 值是一個單一的 uint32,這是一個不包含大小欄位的地址,為這兩個 cpu 分配的地址是 0 和 1。cpu 節點的 #size-cells 為 0 是因為只為每個 cpu 分配一個單獨的地址。
#address-cells = <1>; #size-cells = <1>; ...
[email protected] { compatible = "arm,pl011"; reg = <0x101f0000 0x1000 >; }; [email protected] { compatible = "arm,pl011"; reg = <0x101f2000 0x1000 >; }; [email protected] { compatible = "arm,pl061"; reg = <0x101f3000 0x1000 0x101f4000 0x0010>; }; 每個裝置都被分配了一個基址以及該區域的大小。這個例子中為 GPIO 分配了兩個地址範圍:0x101f3000...0x101f3fff 和 0x101f4000..0x101f400f。
#address-cells = <2>
#size-cells = <1>;
[email protected],0 {
compatible = "smc,smc91c111";
reg = <0 0 0x1000>;
};
外部匯流排的地址值使用了兩個 cell,一個用於片選號;另一個則用於片選基址的偏移量。而長度欄位則還是單個 cell,這是因為只有地址的偏移部分才需要一個範圍量。所以,在這個例子中,每個 reg 項都有三個 cell:片選號、偏移量和長度。