1.小型模板设备树
下面写一个简单的小型设备树,目的就是了解设备树的大致结构,注意最重要的就是层次结构
- 1.搭建一个仅含有根节点“/”的基础的框架
/ {
compatible = "fsl,imx6ull-alientek-evk", "fsl,imx6ull";
}
- 2.1添加/cpus节点
/ {
compatible = "fsl,imx6ull-alientek-evk", "fsl,imx6ull";
cpus {
#address-cells = <1>;
#size-cells = <0>;
//CPU0 节点
cpu0: cpu@0 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0>;
};
};
}
- 2.2 添加/soc节点
/ {
compatible = "fsl,imx6ull-alientek-evk", "fsl,imx6ull";
cpus {
#address-cells = <1>;
#size-cells = <0>;
//CPU0 节点
cpu0: cpu@0 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0>;
};
};
//soc 节点
soc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges; /*,ranges属性,ranges属性为空,说明子空间和父空间地址范围相同*/
}
}
- 3.1 添加/soc/ocram节点
/ {
compatible = "fsl,imx6ull-alientek-evk", "fsl,imx6ull";
cpus {
#address-cells = <1>;
#size-cells = <0>;
//CPU0 节点
cpu0: cpu@0 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0>;
};
};
//soc 节点
soc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges;
//ocram 节点
ocram: sram@00900000 {
compatible = "fsl,lpm-sram";
reg = <0x00900000 0x20000>;
};
}
}
- 3.2 添加/soc/aips1(aips2、aips)节点(总线主干)
/ {
compatible = "fsl,imx6ull-alientek-evk", "fsl,imx6ull";
cpus {
#address-cells = <1>;
#size-cells = <0>;
//CPU0 节点
cpu0: cpu@0 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0>;
};
};
//soc 节点
soc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges;
//ocram 节点
ocram: sram@00900000 {
compatible = "fsl,lpm-sram";
reg = <0x00900000 0x20000>;
};
//aips1 节点
aips1: aips-bus@02000000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02000000 0x100000>;
ranges;
}
//aips2 节点
aips2: aips-bus@02100000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02100000 0x100000>;
ranges;
}
//aips3 节点
aips3: aips-bus@02200000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02200000 0x100000>;
ranges;
}
}
}
- 4.1 分别添加/soc/aips1/ecspi1节点(外设控制器节点)
/soc/aips2/usbotg1节点(外设控制器节点)
/soc/aips3/rngb节点(外设控制器节点)
/ {
compatible = "fsl,imx6ull-alientek-evk", "fsl,imx6ull";
cpus {
#address-cells = <1>;
#size-cells = <0>;
//CPU0 节点
cpu0: cpu@0 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0>;
};
};
//soc 节点
soc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges;
//ocram 节点
ocram: sram@00900000 {
compatible = "fsl,lpm-sram";
reg = <0x00900000 0x20000>;
};
//aips1 节点
aips1: aips-bus@02000000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02000000 0x100000>;
ranges;
//ecspi1 节点
ecspi1: ecspi@02008000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6ul-ecspi", "fsl,imx51-ecspi
reg = <0x02008000 0x4000>;
status = "disabled";
};
}
//aips2 节点
aips2: aips-bus@02100000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02100000 0x100000>;
ranges;
//usbotg1 节点
usbotg1: usb@02184000 {
compatible = "fsl,imx6ul-usb", "fsl,imx27-usb";
reg = <0x02184000 0x4000>;
status = "disabled";
};
}
//aips3 节点
aips3: aips-bus@02200000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02200000 0x100000>;
ranges;
//rngb节点
rngb: rngb@02284000 {
compatible = "fsl,imx6sl-rng", "fsl,imx-rng", "imx-rng";
reg = <0x02284000 0x4000>;
};
}
}
}
- 4.2 当然你可以继续追加比如,添加/soc/aips2/i2c(adc等)
/ {
compatible = "fsl,imx6ull-alientek-evk", "fsl,imx6ull";
cpus {
#address-cells = <1>;
#size-cells = <0>;
//CPU0 节点
cpu0: cpu@0 {
compatible = "arm,cortex-a7";
device_type = "cpu";
reg = <0>;
};
};
//soc 节点
soc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges;
//ocram 节点
ocram: sram@00900000 {
compatible = "fsl,lpm-sram";
reg = <0x00900000 0x20000>;
};
//aips1 节点
aips1: aips-bus@02000000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02000000 0x100000>;
ranges;
//ecspi1 节点
ecspi1: ecspi@02008000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6ul-ecspi", "fsl,imx51-ecspi
reg = <0x02008000 0x4000>;
status = "disabled";
};
}
//aips2 节点
aips2: aips-bus@02100000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02100000 0x100000>;
ranges;
//usbotg1 节点
usbotg1: usb@02184000 {
compatible = "fsl,imx6ul-usb", "fsl,imx27-usb";
reg = <0x02184000 0x4000>;
status = "disabled";
};
//adc1节点
adc1: adc@02198000 {
compatible = "fsl,imx6ul-adc", "fsl,vf610-adc";
reg = <0x02198000 0x4000>;
interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6UL_CLK_ADC1>;
num-channels = <2>;
clock-names = "adc";
status = "disabled";
};
//i2c1节点
i2c1: i2c@021a0000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6ul-i2c", "fsl,imx21-i2c";
reg = <0x021a0000 0x4000>;
interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6UL_CLK_I2C1>;
status = "disabled";
};
}
//aips3 节点
aips3: aips-bus@02200000 {
compatible = "fsl,aips-bus", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x02200000 0x100000>;
ranges;
//rngb节点
rngb: rngb@02284000 {
compatible = "fsl,imx6sl-rng", "fsl,imx-rng", "imx-rng";
reg = <0x02284000 0x4000>;
};
}
}
}
2.追加节点(常用)
**这里切记dtsi文件是通用的,所以我们在特定改板子的信息的时候需要用&label在dts里面追加节点信息,好处是,精华和冗余分开放 **
-
现在有个六轴芯片fxls8471,fxls8471 要接到 I.MX6U-ALPHA 开发板的 I2C1 接口上,那么相当于需要在 i2c1 这个节点上添加一个 fxls8471 子节点。
-
下面的这样就不对,在dtsi里面追加
i2c1: i2c@021a0000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6ul-i2c", "fsl,imx21-i2c";
reg = <0x021a0000 0x4000>;
interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6UL_CLK_I2C1>;
status = "disabled";
//fxls8471 子节点
fxls8471@1e {
compatible = "fsl,fxls8471";
reg = <0x1e>;
};
};
- 应该在dts里面追加
&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";
fxls8471@1e {
compatible = "fsl,fxls8471";
reg = <0x1e>;
position = <0>;
interrupt-parent = <&gpio5>;
interrupts = <0 8>;
};
就吹到这里了,希望可以让你更好的理解