rtl838x: dts: use macros for phy and switch definitions
authorPetr Štetiar <ynezz@true.cz>
Wed, 4 Nov 2020 15:20:17 +0000 (16:20 +0100)
committerPetr Štetiar <ynezz@true.cz>
Mon, 9 Nov 2020 08:14:02 +0000 (09:14 +0100)
It's quite more readable, saves some tedious copy&pasting, not so
error prone etc.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
target/linux/rtl838x/dts/rtl8382_allnet_all-sg8208m.dts
target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-10p.dts
target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-16.dts
target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-28.dts
target/linux/rtl838x/dts/rtl838x.dtsi

index 5433b7f37286ba000313627082116a9838dce0ef..a5dd3be0a4ab666bbe89a2d632676497d78649bb 100644 (file)
                #address-cells = <1>;
                #size-cells = <0>;
 
-               /* Internal phy */
-               phy8: ethernet-phy@8 {
-                       reg = <8>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-
-               phy9: ethernet-phy@9 {
-                       reg = <9>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-
-               phy10: ethernet-phy@10 {
-                       reg = <10>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-
-               phy11: ethernet-phy@11 {
-                       reg = <11>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-
-               phy12: ethernet-phy@12 {
-                       reg = <12>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-
-               phy13: ethernet-phy@13 {
-                       reg = <13>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-
-               phy14: ethernet-phy@14 {
-                       reg = <14>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-
-               phy15: ethernet-phy@15 {
-                       reg = <15>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
+               INTERNAL_PHY(8)
+               INTERNAL_PHY(9)
+               INTERNAL_PHY(10)
+               INTERNAL_PHY(11)
+               INTERNAL_PHY(12)
+               INTERNAL_PHY(13)
+               INTERNAL_PHY(14)
+               INTERNAL_PHY(15)
        };
 };
 
                #address-cells = <1>;
                #size-cells = <0>;
 
-               port@0 {
-                       reg = <8>;
-                       label = "lan1";
-                       phy-handle = <&phy8>;
-                       phy-mode = "internal";
-               };
-
-               port@1 {
-                       reg = <9>;
-                       label = "lan2";
-                       phy-handle = <&phy9>;
-                       phy-mode = "internal";
-               };
-
-               port@2 {
-                       reg = <10>;
-                       label = "lan3";
-                       phy-handle = <&phy10>;
-                       phy-mode = "internal";
-               };
-
-               port@3 {
-                       reg = <11>;
-                       label = "lan4";
-                       phy-handle = <&phy11>;
-                       phy-mode = "internal";
-               };
-
-               port@4 {
-                       reg = <12>;
-                       label = "lan5";
-                       phy-handle = <&phy12>;
-                       phy-mode = "internal";
-               };
-
-               port@5 {
-                       reg = <13>;
-                       label = "lan6";
-                       phy-handle = <&phy13>;
-                       phy-mode = "internal";
-               };
-
-               port@6 {
-                       reg = <14>;
-                       label = "lan7";
-                       phy-handle = <&phy14>;
-                       phy-mode = "internal";
-               };
-
-               port@7 {
-                       reg = <15>;
-                       label = "lan8";
-                       phy-handle = <&phy15>;
-                       phy-mode = "internal";
-               };
+               SWITCH_PORT(8, 1, internal)
+               SWITCH_PORT(9, 2, internal)
+               SWITCH_PORT(10, 3, internal)
+               SWITCH_PORT(11, 4, internal)
+               SWITCH_PORT(12, 5, internal)
+               SWITCH_PORT(13, 6, internal)
+               SWITCH_PORT(14, 7, internal)
+               SWITCH_PORT(15, 8, internal)
 
                port@28 {
                        ethernet = <&ethernet0>;
index 89e3746ad5af09e51d8b77db9a4c578484764dd3..9987316c21a9a2cb9508c61e9b771e6af4d607f3 100644 (file)
@@ -99,8 +99,6 @@
        };
 };
 
-
-
 &ethernet0 {
        mdio: mdio-bus {
                compatible = "realtek,rtl838x-mdio";
                #address-cells = <1>;
                #size-cells = <0>;
 
-               /* Internal phy */
-               phy8: ethernet-phy@8 {
-                       reg = <8>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy9: ethernet-phy@9 {
-                       reg = <9>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy10: ethernet-phy@10 {
-                       reg = <10>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy11: ethernet-phy@11 {
-                       reg = <11>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy12: ethernet-phy@12 {
-                       reg = <12>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy13: ethernet-phy@13 {
-                       reg = <13>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy14: ethernet-phy@14 {
-                       reg = <14>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy15: ethernet-phy@15 {
-                       reg = <15>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy24: ethernet-phy@24 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-                       reg = <24>;
-               };
-               phy26: ethernet-phy@26 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-                       reg = <26>;
-               };
+               INTERNAL_PHY(8)
+               INTERNAL_PHY(9)
+               INTERNAL_PHY(10)
+               INTERNAL_PHY(11)
+               INTERNAL_PHY(12)
+               INTERNAL_PHY(13)
+               INTERNAL_PHY(14)
+               INTERNAL_PHY(15)
+               INTERNAL_PHY(24)
+               INTERNAL_PHY(26)
        };
 };
 
                #address-cells = <1>;
                #size-cells = <0>;
 
-               port@0 {
-                       reg = <8>;
-                       label = "lan1";
-                       phy-handle = <&phy8>;
-                       phy-mode = "internal";
-               };
-               port@1 {
-                       reg = <9>;
-                       label = "lan2";
-                       phy-handle = <&phy9>;
-                       phy-mode = "internal";
-               };
-               port@2 {
-                       reg = <10>;
-                       label = "lan3";
-                       phy-handle = <&phy10>;
-                       phy-mode = "internal";
-               };
-               port@3 {
-                       reg = <11>;
-                       label = "lan4";
-                       phy-handle = <&phy11>;
-                       phy-mode = "internal";
-               };
-               port@4 {
-                       reg = <12>;
-                       label = "lan5";
-                       phy-handle = <&phy12>;
-                       phy-mode = "internal";
-               };
-               port@5 {
-                       reg = <13>;
-                       label = "lan6";
-                       phy-handle = <&phy13>;
-                       phy-mode = "internal";
-               };
-               port@6 {
-                       reg = <14>;
-                       label = "lan7";
-                       phy-handle = <&phy14>;
-                       phy-mode = "internal";
-               };
-               port@7 {
-                       reg = <15>;
-                       label = "lan8";
-                       phy-handle = <&phy15>;
-                       phy-mode = "internal";
-               };
+               SWITCH_PORT(8, 1, internal)
+               SWITCH_PORT(9, 2, internal)
+               SWITCH_PORT(10, 3, internal)
+               SWITCH_PORT(11, 4, internal)
+               SWITCH_PORT(12, 5, internal)
+               SWITCH_PORT(13, 6, internal)
+               SWITCH_PORT(14, 7, internal)
+               SWITCH_PORT(15, 8, internal)
+               SWITCH_PORT(24, 9, internal)
+               SWITCH_PORT(26, 10, internal)
 
-               port@24 {
-                       reg = <24>;
-                       label = "lan9";
-                       phy-mode = "internal";
-                       phy-handle = <&phy24>;
-               };
-               port@26 {
-                       reg = <26>;
-                       label = "lan10";
-                       phy-mode = "internal";
-                       phy-handle = <&phy26>;
-               };
                port@28 {
                        ethernet = <&ethernet0>;
                        reg = <28>;
index 3843af1371a790656f43bb804370eb5e1b801b23..ac51185ed034589d5757026d70e8cc347ebf5fb5 100644 (file)
                #address-cells = <1>;
                #size-cells = <0>;
 
-               /* External phy RTL8218B */
-               phy0: ethernet-phy@0 {
-                       reg = <0>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy1: ethernet-phy@1 {
-                       reg = <1>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy2: ethernet-phy@2 {
-                       reg = <2>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy3: ethernet-phy@3 {
-                       reg = <3>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy4: ethernet-phy@4 {
-                       reg = <4>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy5: ethernet-phy@5 {
-                       reg = <5>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy6: ethernet-phy@6 {
-                       reg = <6>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy7: ethernet-phy@7 {
-                       reg = <7>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
+               EXTERNAL_PHY(0)
+               EXTERNAL_PHY(1)
+               EXTERNAL_PHY(2)
+               EXTERNAL_PHY(3)
+               EXTERNAL_PHY(4)
+               EXTERNAL_PHY(5)
+               EXTERNAL_PHY(6)
+               EXTERNAL_PHY(7)
 
-               /* Internal phy RTL8218B */
-               phy8: ethernet-phy@8 {
-                       reg = <8>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy9: ethernet-phy@9 {
-                       reg = <9>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy10: ethernet-phy@10 {
-                       reg = <10>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy11: ethernet-phy@11 {
-                       reg = <11>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy12: ethernet-phy@12 {
-                       reg = <12>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy13: ethernet-phy@13 {
-                       reg = <13>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy14: ethernet-phy@14 {
-                       reg = <14>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy15: ethernet-phy@15 {
-                       reg = <15>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
+               INTERNAL_PHY(8)
+               INTERNAL_PHY(9)
+               INTERNAL_PHY(10)
+               INTERNAL_PHY(11)
+               INTERNAL_PHY(12)
+               INTERNAL_PHY(13)
+               INTERNAL_PHY(14)
+               INTERNAL_PHY(15)
 
-               /* External phy: RTL8214FC */
-               phy24: ethernet-phy@24 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       sfp;
-                       media = "fibre";
-                       reg = <24>;
-               };
-               phy25: ethernet-phy@25 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       sfp;
-                       media = "fibre";
-                       reg = <25>;
-               };
-               phy26: ethernet-phy@26 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       sfp;
-                       media = "fibre";
-                       reg = <26>;
-               };
-               phy27: ethernet-phy@27 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       sfp;
-                       media = "fibre";
-                       reg = <27>;
-               };
+               EXTERNAL_SFP_PHY(24)
+               EXTERNAL_SFP_PHY(25)
+               EXTERNAL_SFP_PHY(26)
+               EXTERNAL_SFP_PHY(27)
        };
 };
 
                #address-cells = <1>;
                #size-cells = <0>;
 
-               port@0 {
-                       reg = <0>;
-                       label = "lan1";
-                       phy-handle = <&phy0>;
-                       phy-mode = "qsgmii";
-               };
-               port@1 {
-                       reg = <1>;
-                       label = "lan2";
-                       phy-handle = <&phy1>;
-                       phy-mode = "qsgmii";
-               };
-               port@2 {
-                       reg = <2>;
-                       label = "lan3";
-                       phy-handle = <&phy2>;
-                       phy-mode = "qsgmii";
-               };
-               port@3 {
-                       reg = <3>;
-                       label = "lan4";
-                       phy-handle = <&phy3>;
-                       phy-mode = "qsgmii";
-               };
-               port@4 {
-                       reg = <4>;
-                       label = "lan5";
-                       phy-handle = <&phy4>;
-                       phy-mode = "qsgmii";
-               };
-               port@5 {
-                       reg = <5>;
-                       label = "lan6";
-                       phy-handle = <&phy5>;
-                       phy-mode = "qsgmii";
-               };
-               port@6 {
-                       reg = <6>;
-                       label = "lan7";
-                       phy-handle = <&phy6>;
-                       phy-mode = "qsgmii";
-               };
-               port@7 {
-                       reg = <7>;
-                       label = "lan8";
-                       phy-handle = <&phy7>;
-                       phy-mode = "qsgmii";
-               };
-               port@8 {
-                       reg = <8>;
-                       label = "lan9";
-                       phy-handle = <&phy8>;
-                       phy-mode = "internal";
-               };
-               port@9 {
-                       reg = <9>;
-                       label = "lan10";
-                       phy-handle = <&phy9>;
-                       phy-mode = "internal";
-               };
-               port@10 {
-                       reg = <10>;
-                       label = "lan11";
-                       phy-handle = <&phy10>;
-                       phy-mode = "internal";
-               };
-               port@11 {
-                       reg = <11>;
-                       label = "lan12";
-                       phy-handle = <&phy11>;
-                       phy-mode = "internal";
-               };
-               port@12 {
-                       reg = <12>;
-                       label = "lan13";
-                       phy-handle = <&phy12>;
-                       phy-mode = "internal";
-               };
-               port@13 {
-                       reg = <13>;
-                       label = "lan14";
-                       phy-handle = <&phy13>;
-                       phy-mode = "internal";
-               };
-               port@14 {
-                       reg = <14>;
-                       label = "lan15";
-                       phy-handle = <&phy14>;
-                       phy-mode = "internal";
-               };
-               port@15 {
-                       reg = <15>;
-                       label = "lan16";
-                       phy-handle = <&phy15>;
-                       phy-mode = "internal";
-               };
+               SWITCH_PORT(0, 1, qsgmii)
+               SWITCH_PORT(1, 2, qsgmii)
+               SWITCH_PORT(2, 3, qsgmii)
+               SWITCH_PORT(3, 4, qsgmii)
+               SWITCH_PORT(4, 5, qsgmii)
+               SWITCH_PORT(5, 6, qsgmii)
+               SWITCH_PORT(6, 7, qsgmii)
+               SWITCH_PORT(7, 8, qsgmii)
+
+               SWITCH_PORT(8, 9, internal)
+               SWITCH_PORT(9, 10, internal)
+               SWITCH_PORT(10, 11, internal)
+               SWITCH_PORT(11, 12, internal)
+               SWITCH_PORT(12, 13, internal)
+               SWITCH_PORT(13, 14, internal)
+               SWITCH_PORT(14, 15, internal)
+               SWITCH_PORT(15, 16, internal)
+
+               SWITCH_PORT(24, 17, qsgmii)
+               SWITCH_PORT(25, 18, qsgmii)
+               SWITCH_PORT(26, 19, qsgmii)
+               SWITCH_PORT(27, 20, qsgmii)
 
-               port@24 {
-                       reg = <24>;
-                       label = "lan17";
-                       phy-handle = <&phy24>;
-                       phy-mode = "qsgmii";
-               };
-               port@25 {
-                       reg = <25>;
-                       label = "lan18";
-                       phy-handle = <&phy25>;
-                       phy-mode = "qsgmii";
-               };
-               port@26 {
-                       reg = <26>;
-                       label = "lan19";
-                       phy-handle = <&phy26>;
-                       phy-mode = "qsgmii";
-               };
-               port@27 {
-                       reg = <27>;
-                       label = "lan20";
-                       phy-handle = <&phy27>;
-                       phy-mode = "qsgmii";
-               };
                port@28 {
                        ethernet = <&ethernet0>;
                        reg = <28>;
index f154ca963d1ccbf6ee7affbb968326aad5c6d30f..edd4fb140f6aa720439d122b8c7c2a1d5b778f1e 100644 (file)
                #address-cells = <1>;
                #size-cells = <0>;
 
-               /* External phy RTL8218B */
-               phy0: ethernet-phy@0 {
-                       reg = <0>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy1: ethernet-phy@1 {
-                       reg = <1>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy2: ethernet-phy@2 {
-                       reg = <2>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy3: ethernet-phy@3 {
-                       reg = <3>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy4: ethernet-phy@4 {
-                       reg = <4>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy5: ethernet-phy@5 {
-                       reg = <5>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy6: ethernet-phy@6 {
-                       reg = <6>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy7: ethernet-phy@7 {
-                       reg = <7>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
+               EXTERNAL_PHY(0)
+               EXTERNAL_PHY(1)
+               EXTERNAL_PHY(2)
+               EXTERNAL_PHY(3)
+               EXTERNAL_PHY(4)
+               EXTERNAL_PHY(5)
+               EXTERNAL_PHY(6)
+               EXTERNAL_PHY(7)
 
-               /* Internal phy RTL8218B */
-               phy8: ethernet-phy@8 {
-                       reg = <8>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy9: ethernet-phy@9 {
-                       reg = <9>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy10: ethernet-phy@10 {
-                       reg = <10>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy11: ethernet-phy@11 {
-                       reg = <11>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy12: ethernet-phy@12 {
-                       reg = <12>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy13: ethernet-phy@13 {
-                       reg = <13>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy14: ethernet-phy@14 {
-                       reg = <14>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
-               phy15: ethernet-phy@15 {
-                       reg = <15>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       phy-is-integrated;
-               };
+               INTERNAL_PHY(8)
+               INTERNAL_PHY(9)
+               INTERNAL_PHY(10)
+               INTERNAL_PHY(11)
+               INTERNAL_PHY(12)
+               INTERNAL_PHY(13)
+               INTERNAL_PHY(14)
+               INTERNAL_PHY(15)
 
-               /* External phy RTL8218B */
-               phy16: ethernet-phy@16 {
-                       reg = <16>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy17: ethernet-phy@17 {
-                       reg = <17>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy18: ethernet-phy@18 {
-                       reg = <18>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy19: ethernet-phy@19 {
-                       reg = <19>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy20: ethernet-phy@20 {
-                       reg = <20>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy21: ethernet-phy@21 {
-                       reg = <21>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy22: ethernet-phy@22 {
-                       reg = <22>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
-               phy23: ethernet-phy@23 {
-                       reg = <23>;
-                       compatible = "ethernet-phy-ieee802.3-c22";
-               };
+               EXTERNAL_PHY(16)
+               EXTERNAL_PHY(17)
+               EXTERNAL_PHY(18)
+               EXTERNAL_PHY(19)
+               EXTERNAL_PHY(20)
+               EXTERNAL_PHY(21)
+               EXTERNAL_PHY(22)
+               EXTERNAL_PHY(23)
 
-               /* External phy: RTL8214FC */
-               phy24: ethernet-phy@24 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       sfp;
-                       media = "fibre";
-                       reg = <24>;
-               };
-               phy25: ethernet-phy@25 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       sfp;
-                       media = "fibre";
-                       reg = <25>;
-               };
-               phy26: ethernet-phy@26 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       sfp;
-                       media = "fibre";
-                       reg = <26>;
-               };
-               phy27: ethernet-phy@27 {
-                       compatible = "ethernet-phy-ieee802.3-c22";
-                       sfp;
-                       media = "fibre";
-                       reg = <27>;
-               };
+               EXTERNAL_SFP_PHY(24)
+               EXTERNAL_SFP_PHY(25)
+               EXTERNAL_SFP_PHY(26)
+               EXTERNAL_SFP_PHY(27)
        };
 };
 
                #address-cells = <1>;
                #size-cells = <0>;
 
-               port@0 {
-                       reg = <0>;
-                       label = "lan1";
-                       phy-handle = <&phy0>;
-                       phy-mode = "qsgmii";
-               };
-               port@1 {
-                       reg = <1>;
-                       label = "lan2";
-                       phy-handle = <&phy1>;
-                       phy-mode = "qsgmii";
-               };
-               port@2 {
-                       reg = <2>;
-                       label = "lan3";
-                       phy-handle = <&phy2>;
-                       phy-mode = "qsgmii";
-               };
-               port@3 {
-                       reg = <3>;
-                       label = "lan4";
-                       phy-handle = <&phy3>;
-                       phy-mode = "qsgmii";
-               };
-               port@4 {
-                       reg = <4>;
-                       label = "lan5";
-                       phy-handle = <&phy4>;
-                       phy-mode = "qsgmii";
-               };
-               port@5 {
-                       reg = <5>;
-                       label = "lan6";
-                       phy-handle = <&phy5>;
-                       phy-mode = "qsgmii";
-               };
-               port@6 {
-                       reg = <6>;
-                       label = "lan7";
-                       phy-handle = <&phy6>;
-                       phy-mode = "qsgmii";
-               };
-               port@7 {
-                       reg = <7>;
-                       label = "lan8";
-                       phy-handle = <&phy7>;
-                       phy-mode = "qsgmii";
-               };
-               port@8 {
-                       reg = <8>;
-                       label = "lan9";
-                       phy-handle = <&phy8>;
-                       phy-mode = "internal";
-               };
-               port@9 {
-                       reg = <9>;
-                       label = "lan10";
-                       phy-handle = <&phy9>;
-                       phy-mode = "internal";
-               };
-               port@10 {
-                       reg = <10>;
-                       label = "lan11";
-                       phy-handle = <&phy10>;
-                       phy-mode = "internal";
-               };
-               port@11 {
-                       reg = <11>;
-                       label = "lan12";
-                       phy-handle = <&phy11>;
-                       phy-mode = "internal";
-               };
-               port@12 {
-                       reg = <12>;
-                       label = "lan13";
-                       phy-handle = <&phy12>;
-                       phy-mode = "internal";
-               };
-               port@13 {
-                       reg = <13>;
-                       label = "lan14";
-                       phy-handle = <&phy13>;
-                       phy-mode = "internal";
-               };
-               port@14 {
-                       reg = <14>;
-                       label = "lan15";
-                       phy-handle = <&phy14>;
-                       phy-mode = "internal";
-               };
-               port@15 {
-                       reg = <15>;
-                       label = "lan16";
-                       phy-handle = <&phy15>;
-                       phy-mode = "internal";
-               };
-               port@16 {
-                       reg = <16>;
-                       label = "lan17";
-                       phy-handle = <&phy16>;
-                       phy-mode = "qsgmii";
-               };
-               port@17 {
-                       reg = <17>;
-                       label = "lan18";
-                       phy-handle = <&phy17>;
-                       phy-mode = "qsgmii";
-               };
-               port@18 {
-                       reg = <18>;
-                       label = "lan19";
-                       phy-handle = <&phy18>;
-                       phy-mode = "qsgmii";
-               };
-               port@19 {
-                       reg = <19>;
-                       label = "lan20";
-                       phy-handle = <&phy19>;
-                       phy-mode = "qsgmii";
-               };
-               port@20 {
-                       reg = <20>;
-                       label = "lan21";
-                       phy-handle = <&phy20>;
-                       phy-mode = "qsgmii";
-               };
-               port@21 {
-                       reg = <21>;
-                       label = "lan22";
-                       phy-handle = <&phy21>;
-                       phy-mode = "qsgmii";
-               };
-               port@22 {
-                       reg = <22>;
-                       label = "lan23";
-                       phy-handle = <&phy22>;
-                       phy-mode = "qsgmii";
-               };
-               port@23 {
-                       reg = <23>;
-                       label = "lan24";
-                       phy-handle = <&phy23>;
-                       phy-mode = "qsgmii";
-               };
+               SWITCH_PORT(0, 1, qsgmii)
+               SWITCH_PORT(1, 2, qsgmii)
+               SWITCH_PORT(2, 3, qsgmii)
+               SWITCH_PORT(3, 4, qsgmii)
+               SWITCH_PORT(4, 5, qsgmii)
+               SWITCH_PORT(5, 6, qsgmii)
+               SWITCH_PORT(6, 7, qsgmii)
+               SWITCH_PORT(7, 8, qsgmii)
+
+               SWITCH_PORT(8, 9, internal)
+               SWITCH_PORT(9, 10, internal)
+               SWITCH_PORT(10, 11, internal)
+               SWITCH_PORT(11, 12, internal)
+               SWITCH_PORT(12, 13, internal)
+               SWITCH_PORT(13, 14, internal)
+               SWITCH_PORT(14, 15, internal)
+               SWITCH_PORT(15, 16, internal)
+
+               SWITCH_PORT(16, 17, qsgmii)
+               SWITCH_PORT(17, 18, qsgmii)
+               SWITCH_PORT(18, 19, qsgmii)
+               SWITCH_PORT(19, 20, qsgmii)
+               SWITCH_PORT(20, 21, qsgmii)
+               SWITCH_PORT(21, 22, qsgmii)
+               SWITCH_PORT(22, 23, qsgmii)
+               SWITCH_PORT(23, 24, qsgmii)
+
+               SWITCH_PORT(24, 25, qsgmii)
+               SWITCH_PORT(25, 26, qsgmii)
+               SWITCH_PORT(26, 27, qsgmii)
+               SWITCH_PORT(27, 28, qsgmii)
 
-               port@24 {
-                       reg = <24>;
-                       label = "lan25";
-                       phy-handle = <&phy24>;
-                       phy-mode = "qsgmii";
-               };
-               port@25 {
-                       reg = <25>;
-                       label = "lan26";
-                       phy-handle = <&phy25>;
-                       phy-mode = "qsgmii";
-               };
-               port@26 {
-                       reg = <26>;
-                       label = "lan27";
-                       phy-handle = <&phy26>;
-                       phy-mode = "qsgmii";
-               };
-               port@27 {
-                       reg = <27>;
-                       label = "lan28";
-                       phy-handle = <&phy27>;
-                       phy-mode = "qsgmii";
-               };
                port@28 {
                        ethernet = <&ethernet0>;
                        reg = <28>;
index 99c324bf52d219d862b4acd50e0d4c09adf65b8c..37bbcefd441e0490af7bea50cdfa3f6b629e5fab 100644 (file)
@@ -2,6 +2,39 @@
 
 /dts-v1/;
 
+#define STRINGIZE(s) #s
+#define LAN_LABEL(p, s) STRINGIZE(p ## s)
+#define SWITCH_PORT_LABEL(n) LAN_LABEL(lan, n)
+
+#define INTERNAL_PHY(n) \
+       phy##n: ethernet-phy@##n { \
+               reg = <##n>; \
+               compatible = "ethernet-phy-ieee802.3-c22"; \
+               phy-is-integrated; \
+       };
+
+#define EXTERNAL_PHY(n) \
+       phy##n: ethernet-phy@##n { \
+               reg = <##n>; \
+               compatible = "ethernet-phy-ieee802.3-c22"; \
+       };
+
+#define EXTERNAL_SFP_PHY(n) \
+       phy##n: ethernet-phy@##n { \
+               compatible = "ethernet-phy-ieee802.3-c22"; \
+               sfp; \
+               media = "fibre"; \
+               reg = <##n>; \
+       };
+
+#define SWITCH_PORT(n, s, m) \
+       port@##n { \
+               reg = <##n>; \
+               label = SWITCH_PORT_LABEL(s) ; \
+               phy-handle = <&phy##n>; \
+               phy-mode = #m ; \
+       };
+
 / {
        #address-cells = <1>;
        #size-cells = <1>;