前言
这篇博文用以太网设备的设备树描述来得出一个重要结论:
u-boot和Linux内核的设备树文件在书写时是可以相互参考的。
这篇博文是博文 https://blog.youkuaiyun.com/wenhao_ir/article/details/145662136 附带产生的。
公板提供的u-boot和内核的对比
公板提供的u-boot的设备树文件对以太网设备的描述
文件位置:\uboot-imx\arch\arm\dts\imx6ul-14x14-evk.dtsi
&fec1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet1>;
phy-mode = "rmii";
phy-handle = <ðphy0>;
status = "okay";
};
&fec2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet2>;
phy-mode = "rmii";
phy-handle = <ðphy1>;
status = "okay";
mdio {
#address-cells = <1>;
#size-cells = <0>;
ethphy0: ethernet-phy@2 {
reg = <2>;
micrel,led-mode = <1>;
clocks = <&clks IMX6UL_CLK_ENET_REF>;
clock-names = "rmii-ref";
};
ethphy1: ethernet-phy@1 {
reg = <1>;
micrel,led-mode = <1>;
clocks = <&clks IMX6UL_CLK_ENET2_REF>;
clock-names = "rmii-ref";
};
};
};
公板提供的Linux内核的设备树文件对以太网设备的描述
在公板中,设备树文件imx6ull-14x14-evk.dts
包含了设备树文件imx6ul-14x14-evk.dtsi
,在设备树文件imx6ul-14x14-evk.dtsi
有对以太网设备的描述,代码如下:
文件位置:/linux-imx/arch/arm/boot/dts/imx6ul-14x14-evk.dtsi
&fec1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet1>;
phy-mode = "rmii";
phy-handle = <ðphy0>;
status = "okay";
};
&fec2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet2>;
phy-mode = "rmii";
phy-handle = <ðphy1>;
status = "okay";
mdio {
#address-cells = <1>;
#size-cells = <0>;
ethphy0: ethernet-phy@2 {
reg = <2>;
micrel,led-mode = <1>;
clocks = <&clks IMX6UL_CLK_ENET_REF>;
clock-names = "rmii-ref";
};
ethphy1: ethernet-phy@1 {
reg = <1>;
micrel,led-mode = <1>;
clocks = <&clks IMX6UL_CLK_ENET2_REF>;
clock-names = "rmii-ref";
};
};
};
分析说明(完全一样)
我们对比二者,发现二者是完全一样的,所以可以说u-boot和Linux内核的设备树文件在书写时是可以相互参考的。
100ask提供的u-boot和内核的对比
100ask提供的u-boot的设备树文件对以太网设备的描述
文件位置:\uboot-imx\arch\arm\dts\imx6ul-14x14-evk.dtsi
&fec1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet1>;
phy-mode = "rmii";
phy-handle = <ðphy0>;
status = "disabled";
};
&fec2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet2>;
phy-mode = "rmii";
phy-handle = <ðphy1>;
phy-reset-gpios = <&gpio5 6 GPIO_ACTIVE_LOW>;
phy-reset-duration = <26>;
status = "okay";
mdio {
#address-cells = <1>;
#size-cells = <0>;
ethphy0: ethernet-phy@2 {
reg = <0>;
//micrel,led-mode = <1>;
clocks = <&clks IMX6UL_CLK_ENET_REF>;
clock-names = "rmii-ref";
};
ethphy1: ethernet-phy@1 {
reg = <1>;
//micrel,led-mode = <1>;
clocks = <&clks IMX6UL_CLK_ENET2_REF>;
clock-names = "rmii-ref";
};
};
};
100ask提供的Linux内核的设备树文件对以太网设备的描述
文件位置:/Linux-4.9.88/arch/arm/boot/dts/100ask_imx6ull-14x14.dts
&fec1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet1>;
phy-mode = "rmii";
phy-handle = <ðphy0>;
phy-reset-gpios = <&gpio5 9 GPIO_ACTIVE_LOW>;
phy-reset-duration = <26>;
status = "okay";
};
&fec2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet2>;
phy-mode = "rmii";
phy-handle = <ðphy1>;
phy-reset-gpios = <&gpio5 6 GPIO_ACTIVE_LOW>;
phy-reset-duration = <26>;
status = "okay";
mdio {
#address-cells = <1>;
#size-cells = <0>;
ethphy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
smsc,disable-energy-detect;
reg = <0>;
};
ethphy1: ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
smsc,disable-energy-detect;
reg = <1>;
};
};
};
分析说明(大部分一样)
二者对比来看,u-boot是没有启用以太网1(fec1)的,只启用了以太网2(fec2),原因在博文 https://blog.youkuaiyun.com/wenhao_ir/article/details/145662136 中有详细说明。
内核是以太网1(fec1)和以太网2(fec2)都启用了的。
既然二者都启用了以太网2(fec2),我们就对比下二者对以太网2(fec2)的描述,结论是二者对以太网2(fec2)的描述虽然并不完全一样,但有很大部分是一样的,所以可以说u-boot和Linux内核的设备树文件在书写时是可以相互参考的。