设备树,用于无需PHY连接到DSA交换机

时间:2015-06-25 09:20:20

标签: linux linux-kernel embedded-linux ethernet device-tree

我们在为Marvell DSA交换机和Xilinx Zynq处理器配置时创建设备树时遇到了一些问题。它们是这样连接的:

|——————————————|               |——————————————————————————————|
|     e000b000—|———— SGMII ————|—port6 (0x16)      port3 —— PHY3
| Zynq         |               |         mv88e6321            |
|     e000c000—|—x           x—|—port5             port4 —— PHY4
|——————————————|               |——————————————————————————————|
        |___________ MDIO _______________|

我们有一个Linux内核的设备树,如下所示:

ps7_ethernet_0: ps7-ethernet@e000b000 {
            #address-cells = <1>;
            #size-cells = <0>;
            clock-names = "ref_clk", "aper_clk";
            clocks = <&clkc 13>, <&clkc 30>;
            compatible = "xlnx,ps7-ethernet-1.00.a";
            interrupt-parent = <&ps7_scugic_0>;
            interrupts = <0 22 4>;
            local-mac-address = [00 0a 35 00 00 00];
            phy-handle = <&phy0>;
            phy-mode = "gmii";
            reg = <0xe000b000 0x1000>;
            xlnx,ptp-enet-clock = <0x69f6bcb>;
            xlnx,enet-reset = "";
            xlnx,eth-mode = <0x0>;
            xlnx,has-mdio = <0x1>;
            mdio_0: mdio {
                #address-cells = <1>;
                #size-cells = <0>;
                phy0: phy@16 {
                    compatiable = "marvell,dsa";
                    reg = <0x16>;
                } ;
            } ;

} ;

    dsa@0 {
            compatible = "marvell,dsa";

            #address-cells = <2>;
            #size-cells = <0>;

            interrupts = <10>;

            dsa,ethernet = <&ps7_ethernet_0>;
            dsa,mii-bus = <&mdio_0>;

            switch@0 {
                #address-cells = <1>;
                #size-cells = <0>;
                reg = <0 0>;
             port@3 {
                    reg = <3>;
                    label = "lan0";                
             };
             port@4 {
                    reg = <4>;
                    label = "lan1";
             };
             port@5 {
                    reg = <5>;
                    label = "lan2";
             };
             port@6 {
                    reg = <6>;
                    label = "cpu";       
             };
        };
        };     
} ;

问题是,从图中可以看出,端口6没有连接PHY,即Zynq和交换机之间的连接是无PHY的,但我必须指定<phy0> in设备树使dsa驱动程序看到开关。但是,它显然试图与不存在的PHY通信并且失败了。

所以问题是:如何为连接到像这样的处理器的dsa交换机创建一个合适的设备树?

感谢您的帮助!

(有一个类似的问题P1010 MAC to Switch port direct connection without PHY,但我无法对此发表评论,不幸的是没有答案)

1 个答案:

答案 0 :(得分:2)

当没有指定&amp; phy0时,您可以将其写为固定链接

fixed-link =&lt; 0 1 1000 0 0&gt ;;

其中0是模拟PHY ID,1->全双工和速度为1000 Mb / s。 您还需要禁用交换机端口6所连接的处理器端口的自动协商。

ps7_ethernet_0: ps7-ethernet@e000b000 {
        #address-cells = <1>;
        #size-cells = <0>;
        clock-names = "ref_clk", "aper_clk";
        clocks = <&clkc 13>, <&clkc 30>;
        compatible = "xlnx,ps7-ethernet-1.00.a";
        interrupt-parent = <&ps7_scugic_0>;
        interrupts = <0 22 4>;
        local-mac-address = [00 0a 35 00 00 00];
        fixed-link = <0 1 1000 0 0>;
        phy-mode = "gmii";
        reg = <0xe000b000 0x1000>;
        xlnx,ptp-enet-clock = <0x69f6bcb>;
        xlnx,enet-reset = "";
        xlnx,eth-mode = <0x0>;
        xlnx,has-mdio = <0x1>;
        mdio_0: mdio {
            #address-cells = <1>;
            #size-cells = <0>;
        } ;

};

dsa@0 {
        compatible = "marvell,dsa";

        #address-cells = <2>;
        #size-cells = <0>;

        interrupts = <10>;

        dsa,ethernet = <&ps7_ethernet_0>;
        dsa,mii-bus = <&mdio_0>;

        switch@0 {
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <22 0>;
         port@3 {
                reg = <3>;
                label = "lan0";                
         };
         port@4 {
                reg = <4>;
                label = "lan1";
         };
         port@5 {
                reg = <5>;
                label = "lan2";
         };
         port@6 {
                reg = <6>;
                label = "cpu";       
         };
    };
    };     

};

我假设开关芯片SMI地址是0x16;如果不是使reg =&lt; 22,0&gt;至&lt; 0,0&gt;和之前在@ 0下一样。 您还可能需要添加mdio驱动程序注册地址和兼容属性,这些属性未在设备树中指定。