[PATCH v2 6/6] rtl838x: dts: use macros for phy and switch definitions
Petr Štetiar
ynezz at true.cz
Wed Nov 4 11:47:25 EST 2020
It's quite more readable, saves some tedious copy&pasting, more error
prone etc.
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
.../dts/rtl8382_allnet_all-sg8208m.dts | 111 +-----
.../dts/rtl8382_d-link_dgs-1210-10p.dts | 125 +-----
.../dts/rtl8382_d-link_dgs-1210-16.dts | 261 ++-----------
.../dts/rtl8382_d-link_dgs-1210-28.dts | 359 +++---------------
target/linux/rtl838x/dts/rtl838x.dtsi | 33 ++
5 files changed, 170 insertions(+), 719 deletions(-)
diff --git a/target/linux/rtl838x/dts/rtl8382_allnet_all-sg8208m.dts b/target/linux/rtl838x/dts/rtl8382_allnet_all-sg8208m.dts
index 5433b7f37286..a5dd3be0a4ab 100644
--- a/target/linux/rtl838x/dts/rtl8382_allnet_all-sg8208m.dts
+++ b/target/linux/rtl838x/dts/rtl8382_allnet_all-sg8208m.dts
@@ -103,46 +103,14 @@
#address-cells = <1>;
#size-cells = <0>;
- /* Internal phy */
- phy8: ethernet-phy at 8 {
- reg = <8>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
-
- phy9: ethernet-phy at 9 {
- reg = <9>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
-
- phy10: ethernet-phy at 10 {
- reg = <10>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
-
- phy11: ethernet-phy at 11 {
- reg = <11>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
-
- phy12: ethernet-phy at 12 {
- reg = <12>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
-
- phy13: ethernet-phy at 13 {
- reg = <13>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
-
- phy14: ethernet-phy at 14 {
- reg = <14>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
-
- phy15: ethernet-phy at 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)
};
};
@@ -151,61 +119,14 @@
#address-cells = <1>;
#size-cells = <0>;
- port at 0 {
- reg = <8>;
- label = "lan1";
- phy-handle = <&phy8>;
- phy-mode = "internal";
- };
-
- port at 1 {
- reg = <9>;
- label = "lan2";
- phy-handle = <&phy9>;
- phy-mode = "internal";
- };
-
- port at 2 {
- reg = <10>;
- label = "lan3";
- phy-handle = <&phy10>;
- phy-mode = "internal";
- };
-
- port at 3 {
- reg = <11>;
- label = "lan4";
- phy-handle = <&phy11>;
- phy-mode = "internal";
- };
-
- port at 4 {
- reg = <12>;
- label = "lan5";
- phy-handle = <&phy12>;
- phy-mode = "internal";
- };
-
- port at 5 {
- reg = <13>;
- label = "lan6";
- phy-handle = <&phy13>;
- phy-mode = "internal";
- };
-
- port at 6 {
- reg = <14>;
- label = "lan7";
- phy-handle = <&phy14>;
- phy-mode = "internal";
- };
-
- port at 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 at 28 {
ethernet = <ðernet0>;
diff --git a/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-10p.dts b/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-10p.dts
index 89e3746ad5af..9987316c21a9 100644
--- a/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-10p.dts
+++ b/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-10p.dts
@@ -99,8 +99,6 @@
};
};
-
-
ðernet0 {
mdio: mdio-bus {
compatible = "realtek,rtl838x-mdio";
@@ -108,49 +106,16 @@
#address-cells = <1>;
#size-cells = <0>;
- /* Internal phy */
- phy8: ethernet-phy at 8 {
- reg = <8>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy9: ethernet-phy at 9 {
- reg = <9>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy10: ethernet-phy at 10 {
- reg = <10>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy11: ethernet-phy at 11 {
- reg = <11>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy12: ethernet-phy at 12 {
- reg = <12>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy13: ethernet-phy at 13 {
- reg = <13>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy14: ethernet-phy at 14 {
- reg = <14>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy15: ethernet-phy at 15 {
- reg = <15>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy24: ethernet-phy at 24 {
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- reg = <24>;
- };
- phy26: ethernet-phy at 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)
};
};
@@ -159,67 +124,17 @@
#address-cells = <1>;
#size-cells = <0>;
- port at 0 {
- reg = <8>;
- label = "lan1";
- phy-handle = <&phy8>;
- phy-mode = "internal";
- };
- port at 1 {
- reg = <9>;
- label = "lan2";
- phy-handle = <&phy9>;
- phy-mode = "internal";
- };
- port at 2 {
- reg = <10>;
- label = "lan3";
- phy-handle = <&phy10>;
- phy-mode = "internal";
- };
- port at 3 {
- reg = <11>;
- label = "lan4";
- phy-handle = <&phy11>;
- phy-mode = "internal";
- };
- port at 4 {
- reg = <12>;
- label = "lan5";
- phy-handle = <&phy12>;
- phy-mode = "internal";
- };
- port at 5 {
- reg = <13>;
- label = "lan6";
- phy-handle = <&phy13>;
- phy-mode = "internal";
- };
- port at 6 {
- reg = <14>;
- label = "lan7";
- phy-handle = <&phy14>;
- phy-mode = "internal";
- };
- port at 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 at 24 {
- reg = <24>;
- label = "lan9";
- phy-mode = "internal";
- phy-handle = <&phy24>;
- };
- port at 26 {
- reg = <26>;
- label = "lan10";
- phy-mode = "internal";
- phy-handle = <&phy26>;
- };
port at 28 {
ethernet = <ðernet0>;
reg = <28>;
diff --git a/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-16.dts b/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-16.dts
index 3843af1371a7..ac51185ed034 100644
--- a/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-16.dts
+++ b/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-16.dts
@@ -14,107 +14,28 @@
#address-cells = <1>;
#size-cells = <0>;
- /* External phy RTL8218B */
- phy0: ethernet-phy at 0 {
- reg = <0>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy1: ethernet-phy at 1 {
- reg = <1>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy2: ethernet-phy at 2 {
- reg = <2>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy3: ethernet-phy at 3 {
- reg = <3>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy4: ethernet-phy at 4 {
- reg = <4>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy5: ethernet-phy at 5 {
- reg = <5>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy6: ethernet-phy at 6 {
- reg = <6>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy7: ethernet-phy at 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 at 8 {
- reg = <8>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy9: ethernet-phy at 9 {
- reg = <9>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy10: ethernet-phy at 10 {
- reg = <10>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy11: ethernet-phy at 11 {
- reg = <11>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy12: ethernet-phy at 12 {
- reg = <12>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy13: ethernet-phy at 13 {
- reg = <13>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy14: ethernet-phy at 14 {
- reg = <14>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy15: ethernet-phy at 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 at 24 {
- compatible = "ethernet-phy-ieee802.3-c22";
- sfp;
- media = "fibre";
- reg = <24>;
- };
- phy25: ethernet-phy at 25 {
- compatible = "ethernet-phy-ieee802.3-c22";
- sfp;
- media = "fibre";
- reg = <25>;
- };
- phy26: ethernet-phy at 26 {
- compatible = "ethernet-phy-ieee802.3-c22";
- sfp;
- media = "fibre";
- reg = <26>;
- };
- phy27: ethernet-phy at 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)
};
};
@@ -123,127 +44,29 @@
#address-cells = <1>;
#size-cells = <0>;
- port at 0 {
- reg = <0>;
- label = "lan1";
- phy-handle = <&phy0>;
- phy-mode = "qsgmii";
- };
- port at 1 {
- reg = <1>;
- label = "lan2";
- phy-handle = <&phy1>;
- phy-mode = "qsgmii";
- };
- port at 2 {
- reg = <2>;
- label = "lan3";
- phy-handle = <&phy2>;
- phy-mode = "qsgmii";
- };
- port at 3 {
- reg = <3>;
- label = "lan4";
- phy-handle = <&phy3>;
- phy-mode = "qsgmii";
- };
- port at 4 {
- reg = <4>;
- label = "lan5";
- phy-handle = <&phy4>;
- phy-mode = "qsgmii";
- };
- port at 5 {
- reg = <5>;
- label = "lan6";
- phy-handle = <&phy5>;
- phy-mode = "qsgmii";
- };
- port at 6 {
- reg = <6>;
- label = "lan7";
- phy-handle = <&phy6>;
- phy-mode = "qsgmii";
- };
- port at 7 {
- reg = <7>;
- label = "lan8";
- phy-handle = <&phy7>;
- phy-mode = "qsgmii";
- };
- port at 8 {
- reg = <8>;
- label = "lan9";
- phy-handle = <&phy8>;
- phy-mode = "internal";
- };
- port at 9 {
- reg = <9>;
- label = "lan10";
- phy-handle = <&phy9>;
- phy-mode = "internal";
- };
- port at 10 {
- reg = <10>;
- label = "lan11";
- phy-handle = <&phy10>;
- phy-mode = "internal";
- };
- port at 11 {
- reg = <11>;
- label = "lan12";
- phy-handle = <&phy11>;
- phy-mode = "internal";
- };
- port at 12 {
- reg = <12>;
- label = "lan13";
- phy-handle = <&phy12>;
- phy-mode = "internal";
- };
- port at 13 {
- reg = <13>;
- label = "lan14";
- phy-handle = <&phy13>;
- phy-mode = "internal";
- };
- port at 14 {
- reg = <14>;
- label = "lan15";
- phy-handle = <&phy14>;
- phy-mode = "internal";
- };
- port at 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 at 24 {
- reg = <24>;
- label = "lan17";
- phy-handle = <&phy24>;
- phy-mode = "qsgmii";
- };
- port at 25 {
- reg = <25>;
- label = "lan18";
- phy-handle = <&phy25>;
- phy-mode = "qsgmii";
- };
- port at 26 {
- reg = <26>;
- label = "lan19";
- phy-handle = <&phy26>;
- phy-mode = "qsgmii";
- };
- port at 27 {
- reg = <27>;
- label = "lan20";
- phy-handle = <&phy27>;
- phy-mode = "qsgmii";
- };
port at 28 {
ethernet = <ðernet0>;
reg = <28>;
diff --git a/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-28.dts b/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-28.dts
index f154ca963d1c..edd4fb140f6a 100644
--- a/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-28.dts
+++ b/target/linux/rtl838x/dts/rtl8382_d-link_dgs-1210-28.dts
@@ -14,141 +14,37 @@
#address-cells = <1>;
#size-cells = <0>;
- /* External phy RTL8218B */
- phy0: ethernet-phy at 0 {
- reg = <0>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy1: ethernet-phy at 1 {
- reg = <1>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy2: ethernet-phy at 2 {
- reg = <2>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy3: ethernet-phy at 3 {
- reg = <3>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy4: ethernet-phy at 4 {
- reg = <4>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy5: ethernet-phy at 5 {
- reg = <5>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy6: ethernet-phy at 6 {
- reg = <6>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy7: ethernet-phy at 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 at 8 {
- reg = <8>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy9: ethernet-phy at 9 {
- reg = <9>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy10: ethernet-phy at 10 {
- reg = <10>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy11: ethernet-phy at 11 {
- reg = <11>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy12: ethernet-phy at 12 {
- reg = <12>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy13: ethernet-phy at 13 {
- reg = <13>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy14: ethernet-phy at 14 {
- reg = <14>;
- compatible = "ethernet-phy-ieee802.3-c22";
- phy-is-integrated;
- };
- phy15: ethernet-phy at 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 at 16 {
- reg = <16>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy17: ethernet-phy at 17 {
- reg = <17>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy18: ethernet-phy at 18 {
- reg = <18>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy19: ethernet-phy at 19 {
- reg = <19>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy20: ethernet-phy at 20 {
- reg = <20>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy21: ethernet-phy at 21 {
- reg = <21>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy22: ethernet-phy at 22 {
- reg = <22>;
- compatible = "ethernet-phy-ieee802.3-c22";
- };
- phy23: ethernet-phy at 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 at 24 {
- compatible = "ethernet-phy-ieee802.3-c22";
- sfp;
- media = "fibre";
- reg = <24>;
- };
- phy25: ethernet-phy at 25 {
- compatible = "ethernet-phy-ieee802.3-c22";
- sfp;
- media = "fibre";
- reg = <25>;
- };
- phy26: ethernet-phy at 26 {
- compatible = "ethernet-phy-ieee802.3-c22";
- sfp;
- media = "fibre";
- reg = <26>;
- };
- phy27: ethernet-phy at 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)
};
};
@@ -157,175 +53,38 @@
#address-cells = <1>;
#size-cells = <0>;
- port at 0 {
- reg = <0>;
- label = "lan1";
- phy-handle = <&phy0>;
- phy-mode = "qsgmii";
- };
- port at 1 {
- reg = <1>;
- label = "lan2";
- phy-handle = <&phy1>;
- phy-mode = "qsgmii";
- };
- port at 2 {
- reg = <2>;
- label = "lan3";
- phy-handle = <&phy2>;
- phy-mode = "qsgmii";
- };
- port at 3 {
- reg = <3>;
- label = "lan4";
- phy-handle = <&phy3>;
- phy-mode = "qsgmii";
- };
- port at 4 {
- reg = <4>;
- label = "lan5";
- phy-handle = <&phy4>;
- phy-mode = "qsgmii";
- };
- port at 5 {
- reg = <5>;
- label = "lan6";
- phy-handle = <&phy5>;
- phy-mode = "qsgmii";
- };
- port at 6 {
- reg = <6>;
- label = "lan7";
- phy-handle = <&phy6>;
- phy-mode = "qsgmii";
- };
- port at 7 {
- reg = <7>;
- label = "lan8";
- phy-handle = <&phy7>;
- phy-mode = "qsgmii";
- };
- port at 8 {
- reg = <8>;
- label = "lan9";
- phy-handle = <&phy8>;
- phy-mode = "internal";
- };
- port at 9 {
- reg = <9>;
- label = "lan10";
- phy-handle = <&phy9>;
- phy-mode = "internal";
- };
- port at 10 {
- reg = <10>;
- label = "lan11";
- phy-handle = <&phy10>;
- phy-mode = "internal";
- };
- port at 11 {
- reg = <11>;
- label = "lan12";
- phy-handle = <&phy11>;
- phy-mode = "internal";
- };
- port at 12 {
- reg = <12>;
- label = "lan13";
- phy-handle = <&phy12>;
- phy-mode = "internal";
- };
- port at 13 {
- reg = <13>;
- label = "lan14";
- phy-handle = <&phy13>;
- phy-mode = "internal";
- };
- port at 14 {
- reg = <14>;
- label = "lan15";
- phy-handle = <&phy14>;
- phy-mode = "internal";
- };
- port at 15 {
- reg = <15>;
- label = "lan16";
- phy-handle = <&phy15>;
- phy-mode = "internal";
- };
- port at 16 {
- reg = <16>;
- label = "lan17";
- phy-handle = <&phy16>;
- phy-mode = "qsgmii";
- };
- port at 17 {
- reg = <17>;
- label = "lan18";
- phy-handle = <&phy17>;
- phy-mode = "qsgmii";
- };
- port at 18 {
- reg = <18>;
- label = "lan19";
- phy-handle = <&phy18>;
- phy-mode = "qsgmii";
- };
- port at 19 {
- reg = <19>;
- label = "lan20";
- phy-handle = <&phy19>;
- phy-mode = "qsgmii";
- };
- port at 20 {
- reg = <20>;
- label = "lan21";
- phy-handle = <&phy20>;
- phy-mode = "qsgmii";
- };
- port at 21 {
- reg = <21>;
- label = "lan22";
- phy-handle = <&phy21>;
- phy-mode = "qsgmii";
- };
- port at 22 {
- reg = <22>;
- label = "lan23";
- phy-handle = <&phy22>;
- phy-mode = "qsgmii";
- };
- port at 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 at 24 {
- reg = <24>;
- label = "lan25";
- phy-handle = <&phy24>;
- phy-mode = "qsgmii";
- };
- port at 25 {
- reg = <25>;
- label = "lan26";
- phy-handle = <&phy25>;
- phy-mode = "qsgmii";
- };
- port at 26 {
- reg = <26>;
- label = "lan27";
- phy-handle = <&phy26>;
- phy-mode = "qsgmii";
- };
- port at 27 {
- reg = <27>;
- label = "lan28";
- phy-handle = <&phy27>;
- phy-mode = "qsgmii";
- };
port at 28 {
ethernet = <ðernet0>;
reg = <28>;
diff --git a/target/linux/rtl838x/dts/rtl838x.dtsi b/target/linux/rtl838x/dts/rtl838x.dtsi
index 99c324bf52d2..37bbcefd441e 100644
--- a/target/linux/rtl838x/dts/rtl838x.dtsi
+++ b/target/linux/rtl838x/dts/rtl838x.dtsi
@@ -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>;
More information about the openwrt-devel
mailing list