[LEDE-DEV] [PATCH RFC] ramips: convert mt7530 to use numerical mediatek, portmap property

Daniel Golle daniel at makrotopia.org
Wed Feb 22 06:36:41 PST 2017


Just like on Rt305x, use numerical values for portmap instead of
strings. Map strings in device-tree definitions to numerical values
such that:
"llllw" = <0x2f>
"wllll" = <0x3e>
"lllll" = <0x3f>

Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
Apply only after switch to kernel 4.9!

 target/linux/ramips/dts/AI-BR100.dts               |  2 +-
 target/linux/ramips/dts/ArcherC20i.dts             |  2 +-
 target/linux/ramips/dts/ArcherC50.dts              |  2 +-
 target/linux/ramips/dts/ArcherMR200.dts            |  2 +-
 target/linux/ramips/dts/CS-QR10.dts                |  2 +-
 target/linux/ramips/dts/D240.dts                   |  2 +-
 target/linux/ramips/dts/DB-WRT01.dts               |  2 +-
 target/linux/ramips/dts/DIR-810L.dts               |  2 +-
 target/linux/ramips/dts/GL-MT300A.dts              |  2 +-
 target/linux/ramips/dts/GL-MT300N.dts              |  2 +-
 target/linux/ramips/dts/GL-MT750.dts               |  2 +-
 target/linux/ramips/dts/HC5861.dts                 |  2 +-
 target/linux/ramips/dts/HC5XXX.dtsi                |  2 +-
 target/linux/ramips/dts/MAC1200RV2.dts             |  2 +-
 target/linux/ramips/dts/MIWIFI-MINI.dts            |  2 +-
 target/linux/ramips/dts/MLW221.dts                 |  2 +-
 target/linux/ramips/dts/MLWG2.dts                  |  2 +-
 target/linux/ramips/dts/MT7620a.dts                |  2 +-
 target/linux/ramips/dts/MT7620a_MT7530.dts         |  2 +-
 target/linux/ramips/dts/MT7620a_MT7610e.dts        |  2 +-
 target/linux/ramips/dts/MT7620a_V22SG.dts          |  2 +-
 target/linux/ramips/dts/MZK-750DHP.dts             |  2 +-
 target/linux/ramips/dts/MZK-EX300NP.dts            |  2 +-
 target/linux/ramips/dts/MZK-EX750NP.dts            |  2 +-
 target/linux/ramips/dts/MicroWRT.dts               |  2 +-
 target/linux/ramips/dts/NA930.dts                  |  2 +-
 target/linux/ramips/dts/OY-0001.dts                |  2 +-
 target/linux/ramips/dts/PSG1208.dts                |  2 +-
 target/linux/ramips/dts/PSG1218.dts                |  2 +-
 target/linux/ramips/dts/RT-N14U.dts                |  2 +-
 target/linux/ramips/dts/TINY-AC.dts                |  2 +-
 target/linux/ramips/dts/WHR-300HP2.dts             |  2 +-
 target/linux/ramips/dts/WHR-600D.dts               |  2 +-
 target/linux/ramips/dts/WL-WN575A3.dts             |  2 +-
 target/linux/ramips/dts/WMR-300.dts                |  2 +-
 target/linux/ramips/dts/WRH-300CR.dts              |  2 +-
 target/linux/ramips/dts/WRTNODE.dts                |  2 +-
 target/linux/ramips/dts/WRTNODE2.dtsi              |  2 +-
 target/linux/ramips/dts/WT3020-4M.dts              |  2 +-
 target/linux/ramips/dts/WT3020-8M.dts              |  2 +-
 target/linux/ramips/dts/Y1.dts                     |  2 +-
 target/linux/ramips/dts/Y1S.dts                    |  2 +-
 target/linux/ramips/dts/YOUKU-YK1.dts              |  2 +-
 target/linux/ramips/dts/ZBT-APE522II.dts           |  2 +-
 target/linux/ramips/dts/ZBT-CPE102.dts             |  2 +-
 target/linux/ramips/dts/ZBT-WA05.dts               |  2 +-
 target/linux/ramips/dts/ZBT-WE826.dts              |  2 +-
 target/linux/ramips/dts/ZBT-WR8305RT.dts           |  2 +-
 target/linux/ramips/dts/ZTE-Q7.dts                 |  2 +-
 target/linux/ramips/dts/kn_rc.dts                  |  2 +-
 target/linux/ramips/dts/kn_rf.dts                  |  2 +-
 .../files-4.9/drivers/net/ethernet/mtk/mt7530.c    | 72 ++++++++--------------
 52 files changed, 77 insertions(+), 97 deletions(-)

diff --git a/target/linux/ramips/dts/AI-BR100.dts b/target/linux/ramips/dts/AI-BR100.dts
index b21e4c25ca..2e95376ae9 100644
--- a/target/linux/ramips/dts/AI-BR100.dts
+++ b/target/linux/ramips/dts/AI-BR100.dts
@@ -100,7 +100,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/ArcherC20i.dts b/target/linux/ramips/dts/ArcherC20i.dts
index 5d0fc308c3..207e1144a6 100644
--- a/target/linux/ramips/dts/ArcherC20i.dts
+++ b/target/linux/ramips/dts/ArcherC20i.dts
@@ -120,7 +120,7 @@
 &ethernet {
 		pinctrl-names = "default";
 		mtd-mac-address = <&rom 0xf100>;
-		mediatek,portmap = "wllll";
+		mediatek,portmap = <0x3e>;
 	};
 
 &ehci {
diff --git a/target/linux/ramips/dts/ArcherC50.dts b/target/linux/ramips/dts/ArcherC50.dts
index ac392f390b..7fda22d3e5 100644
--- a/target/linux/ramips/dts/ArcherC50.dts
+++ b/target/linux/ramips/dts/ArcherC50.dts
@@ -151,7 +151,7 @@
 &ethernet {
 		pinctrl-names = "default";
 		mtd-mac-address = <&rom 0xf100>;
-		mediatek,portmap = "wllll";
+		mediatek,portmap = <0x3e>;
 	};
 
 &ehci {
diff --git a/target/linux/ramips/dts/ArcherMR200.dts b/target/linux/ramips/dts/ArcherMR200.dts
index f41014bbf6..ec2c82bb8b 100644
--- a/target/linux/ramips/dts/ArcherMR200.dts
+++ b/target/linux/ramips/dts/ArcherMR200.dts
@@ -161,7 +161,7 @@
 
 &ethernet {
 		mtd-mac-address = <&rom 0xf100>;
-		mediatek,portmap = "llll";
+		mediatek,portmap = <0x3f>;
 	};
 
 &ehci {
diff --git a/target/linux/ramips/dts/CS-QR10.dts b/target/linux/ramips/dts/CS-QR10.dts
index 81d897a0e8..29534d01d4 100644
--- a/target/linux/ramips/dts/CS-QR10.dts
+++ b/target/linux/ramips/dts/CS-QR10.dts
@@ -123,7 +123,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &gsw {
diff --git a/target/linux/ramips/dts/D240.dts b/target/linux/ramips/dts/D240.dts
index ef45d38e61..dab9a4aecd 100644
--- a/target/linux/ramips/dts/D240.dts
+++ b/target/linux/ramips/dts/D240.dts
@@ -136,7 +136,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/DB-WRT01.dts b/target/linux/ramips/dts/DB-WRT01.dts
index c4a32ea9e9..2a2f5f2e3a 100644
--- a/target/linux/ramips/dts/DB-WRT01.dts
+++ b/target/linux/ramips/dts/DB-WRT01.dts
@@ -83,7 +83,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &gsw {
diff --git a/target/linux/ramips/dts/DIR-810L.dts b/target/linux/ramips/dts/DIR-810L.dts
index 9621183e07..374b67172f 100644
--- a/target/linux/ramips/dts/DIR-810L.dts
+++ b/target/linux/ramips/dts/DIR-810L.dts
@@ -117,7 +117,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x28>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &gsw {
diff --git a/target/linux/ramips/dts/GL-MT300A.dts b/target/linux/ramips/dts/GL-MT300A.dts
index d4c8351f1e..9cbd689f9a 100644
--- a/target/linux/ramips/dts/GL-MT300A.dts
+++ b/target/linux/ramips/dts/GL-MT300A.dts
@@ -133,7 +133,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4000>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/GL-MT300N.dts b/target/linux/ramips/dts/GL-MT300N.dts
index 927ea54d0e..c4c6ef4085 100644
--- a/target/linux/ramips/dts/GL-MT300N.dts
+++ b/target/linux/ramips/dts/GL-MT300N.dts
@@ -122,7 +122,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4000>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/GL-MT750.dts b/target/linux/ramips/dts/GL-MT750.dts
index 1266dd3230..c77e5fdfcb 100644
--- a/target/linux/ramips/dts/GL-MT750.dts
+++ b/target/linux/ramips/dts/GL-MT750.dts
@@ -128,7 +128,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4000>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/HC5861.dts b/target/linux/ramips/dts/HC5861.dts
index 3e812f691d..abfaa38d72 100644
--- a/target/linux/ramips/dts/HC5861.dts
+++ b/target/linux/ramips/dts/HC5861.dts
@@ -58,7 +58,7 @@
 	mtd-mac-address = <&factory 0x4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 
 	port at 4 {
 		status = "okay";
diff --git a/target/linux/ramips/dts/HC5XXX.dtsi b/target/linux/ramips/dts/HC5XXX.dtsi
index 3bea77e233..651fac0c8b 100644
--- a/target/linux/ramips/dts/HC5XXX.dtsi
+++ b/target/linux/ramips/dts/HC5XXX.dtsi
@@ -110,7 +110,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &sdhci {
diff --git a/target/linux/ramips/dts/MAC1200RV2.dts b/target/linux/ramips/dts/MAC1200RV2.dts
index 6d58b25b87..d9ef5d91d2 100644
--- a/target/linux/ramips/dts/MAC1200RV2.dts
+++ b/target/linux/ramips/dts/MAC1200RV2.dts
@@ -72,7 +72,7 @@
 &ethernet {
 	pinctrl-names = "default";
 	mtd-mac-address = <&factory 0xd>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/MIWIFI-MINI.dts b/target/linux/ramips/dts/MIWIFI-MINI.dts
index 45e1f2ef5f..18a38d08ff 100644
--- a/target/linux/ramips/dts/MIWIFI-MINI.dts
+++ b/target/linux/ramips/dts/MIWIFI-MINI.dts
@@ -119,7 +119,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x28>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/MLW221.dts b/target/linux/ramips/dts/MLW221.dts
index f02602fb9f..c397d65835 100644
--- a/target/linux/ramips/dts/MLW221.dts
+++ b/target/linux/ramips/dts/MLW221.dts
@@ -104,7 +104,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/MLWG2.dts b/target/linux/ramips/dts/MLWG2.dts
index fc281934e1..09104e33ef 100644
--- a/target/linux/ramips/dts/MLWG2.dts
+++ b/target/linux/ramips/dts/MLWG2.dts
@@ -104,7 +104,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/MT7620a.dts b/target/linux/ramips/dts/MT7620a.dts
index 3ed22d5c9a..073200b0bf 100644
--- a/target/linux/ramips/dts/MT7620a.dts
+++ b/target/linux/ramips/dts/MT7620a.dts
@@ -76,7 +76,7 @@
 	status = "okay";
 	pinctrl-names = "default";
 	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 
 	port at 4 {
 		status = "okay";
diff --git a/target/linux/ramips/dts/MT7620a_MT7530.dts b/target/linux/ramips/dts/MT7620a_MT7530.dts
index 70f92536f3..61584de857 100644
--- a/target/linux/ramips/dts/MT7620a_MT7530.dts
+++ b/target/linux/ramips/dts/MT7620a_MT7530.dts
@@ -55,7 +55,7 @@
 	status = "okay";
 	pinctrl-names = "default";
 	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 
 	port at 5 {
 		status = "okay";
diff --git a/target/linux/ramips/dts/MT7620a_MT7610e.dts b/target/linux/ramips/dts/MT7620a_MT7610e.dts
index 1670b9c86b..7686e8c02e 100644
--- a/target/linux/ramips/dts/MT7620a_MT7610e.dts
+++ b/target/linux/ramips/dts/MT7620a_MT7610e.dts
@@ -71,7 +71,7 @@
 	status = "okay";
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &gsw {
diff --git a/target/linux/ramips/dts/MT7620a_V22SG.dts b/target/linux/ramips/dts/MT7620a_V22SG.dts
index ea17512082..a5dca0c0e9 100644
--- a/target/linux/ramips/dts/MT7620a_V22SG.dts
+++ b/target/linux/ramips/dts/MT7620a_V22SG.dts
@@ -70,7 +70,7 @@
 	status = "okay";
 	pinctrl-names = "default";
 	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 
 	port at 4 {
 		status = "okay";
diff --git a/target/linux/ramips/dts/MZK-750DHP.dts b/target/linux/ramips/dts/MZK-750DHP.dts
index dfefb0e320..34ad680165 100644
--- a/target/linux/ramips/dts/MZK-750DHP.dts
+++ b/target/linux/ramips/dts/MZK-750DHP.dts
@@ -103,7 +103,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &gsw {
diff --git a/target/linux/ramips/dts/MZK-EX300NP.dts b/target/linux/ramips/dts/MZK-EX300NP.dts
index 854d8a141b..85f56518b1 100644
--- a/target/linux/ramips/dts/MZK-EX300NP.dts
+++ b/target/linux/ramips/dts/MZK-EX300NP.dts
@@ -123,7 +123,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/MZK-EX750NP.dts b/target/linux/ramips/dts/MZK-EX750NP.dts
index 29a11898e8..cf63439450 100644
--- a/target/linux/ramips/dts/MZK-EX750NP.dts
+++ b/target/linux/ramips/dts/MZK-EX750NP.dts
@@ -128,7 +128,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/MicroWRT.dts b/target/linux/ramips/dts/MicroWRT.dts
index 6f8179cc57..3921d07004 100644
--- a/target/linux/ramips/dts/MicroWRT.dts
+++ b/target/linux/ramips/dts/MicroWRT.dts
@@ -91,7 +91,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/NA930.dts b/target/linux/ramips/dts/NA930.dts
index a5393e2a9a..3f934afdb4 100644
--- a/target/linux/ramips/dts/NA930.dts
+++ b/target/linux/ramips/dts/NA930.dts
@@ -132,7 +132,7 @@
 	status = "okay";
 	pinctrl-names = "default";
 	pinctrl-0 = <&rgmii1_pins &mdio_pins>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 
 	port at 4 {
 		status = "okay";
diff --git a/target/linux/ramips/dts/OY-0001.dts b/target/linux/ramips/dts/OY-0001.dts
index ff6fe1e2e2..41939c3c5e 100644
--- a/target/linux/ramips/dts/OY-0001.dts
+++ b/target/linux/ramips/dts/OY-0001.dts
@@ -95,7 +95,7 @@
 &ethernet {
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &gsw {
diff --git a/target/linux/ramips/dts/PSG1208.dts b/target/linux/ramips/dts/PSG1208.dts
index 547da2fdfa..7a6c7588f8 100644
--- a/target/linux/ramips/dts/PSG1208.dts
+++ b/target/linux/ramips/dts/PSG1208.dts
@@ -92,7 +92,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &pcie {
diff --git a/target/linux/ramips/dts/PSG1218.dts b/target/linux/ramips/dts/PSG1218.dts
index 1e53dcef3d..28088f8b08 100644
--- a/target/linux/ramips/dts/PSG1218.dts
+++ b/target/linux/ramips/dts/PSG1218.dts
@@ -98,7 +98,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x28>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &pcie {
diff --git a/target/linux/ramips/dts/RT-N14U.dts b/target/linux/ramips/dts/RT-N14U.dts
index 8bb2701040..cc3332d6ad 100644
--- a/target/linux/ramips/dts/RT-N14U.dts
+++ b/target/linux/ramips/dts/RT-N14U.dts
@@ -110,7 +110,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/TINY-AC.dts b/target/linux/ramips/dts/TINY-AC.dts
index 460227db10..082318b4d2 100644
--- a/target/linux/ramips/dts/TINY-AC.dts
+++ b/target/linux/ramips/dts/TINY-AC.dts
@@ -112,7 +112,7 @@
 	status = "okay";
 	pinctrl-names = "default";
 	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 
 	port at 4 {
 		status = "okay";
diff --git a/target/linux/ramips/dts/WHR-300HP2.dts b/target/linux/ramips/dts/WHR-300HP2.dts
index 44387541b1..793bf03aec 100644
--- a/target/linux/ramips/dts/WHR-300HP2.dts
+++ b/target/linux/ramips/dts/WHR-300HP2.dts
@@ -137,7 +137,7 @@
 &ethernet {
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &gsw {
diff --git a/target/linux/ramips/dts/WHR-600D.dts b/target/linux/ramips/dts/WHR-600D.dts
index 9370d15bbf..d01a3d2c34 100644
--- a/target/linux/ramips/dts/WHR-600D.dts
+++ b/target/linux/ramips/dts/WHR-600D.dts
@@ -133,7 +133,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &gsw {
diff --git a/target/linux/ramips/dts/WL-WN575A3.dts b/target/linux/ramips/dts/WL-WN575A3.dts
index 213cf9c70b..0285ec1509 100644
--- a/target/linux/ramips/dts/WL-WN575A3.dts
+++ b/target/linux/ramips/dts/WL-WN575A3.dts
@@ -125,5 +125,5 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x2e>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
diff --git a/target/linux/ramips/dts/WMR-300.dts b/target/linux/ramips/dts/WMR-300.dts
index a56f71642e..ccac37be10 100644
--- a/target/linux/ramips/dts/WMR-300.dts
+++ b/target/linux/ramips/dts/WMR-300.dts
@@ -88,7 +88,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/WRH-300CR.dts b/target/linux/ramips/dts/WRH-300CR.dts
index c336ba317a..6c64daf66a 100644
--- a/target/linux/ramips/dts/WRH-300CR.dts
+++ b/target/linux/ramips/dts/WRH-300CR.dts
@@ -109,7 +109,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x2e>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/WRTNODE.dts b/target/linux/ramips/dts/WRTNODE.dts
index df10eefcbf..0152c797d5 100644
--- a/target/linux/ramips/dts/WRTNODE.dts
+++ b/target/linux/ramips/dts/WRTNODE.dts
@@ -73,7 +73,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/WRTNODE2.dtsi b/target/linux/ramips/dts/WRTNODE2.dtsi
index ca7aa3befc..d9c4e6b06a 100644
--- a/target/linux/ramips/dts/WRTNODE2.dtsi
+++ b/target/linux/ramips/dts/WRTNODE2.dtsi
@@ -75,7 +75,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &sdhci {
diff --git a/target/linux/ramips/dts/WT3020-4M.dts b/target/linux/ramips/dts/WT3020-4M.dts
index c2d83f9fab..88fff785c5 100644
--- a/target/linux/ramips/dts/WT3020-4M.dts
+++ b/target/linux/ramips/dts/WT3020-4M.dts
@@ -84,7 +84,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/WT3020-8M.dts b/target/linux/ramips/dts/WT3020-8M.dts
index 987eed4ee5..f86960350b 100644
--- a/target/linux/ramips/dts/WT3020-8M.dts
+++ b/target/linux/ramips/dts/WT3020-8M.dts
@@ -84,7 +84,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/Y1.dts b/target/linux/ramips/dts/Y1.dts
index ac9b7d56c0..af501c284a 100644
--- a/target/linux/ramips/dts/Y1.dts
+++ b/target/linux/ramips/dts/Y1.dts
@@ -45,5 +45,5 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
diff --git a/target/linux/ramips/dts/Y1S.dts b/target/linux/ramips/dts/Y1S.dts
index cfa5e2123a..1d95a12363 100644
--- a/target/linux/ramips/dts/Y1S.dts
+++ b/target/linux/ramips/dts/Y1S.dts
@@ -72,7 +72,7 @@
 	mtd-mac-address = <&factory 0x4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 
 	port at 4 {
 		status = "okay";
diff --git a/target/linux/ramips/dts/YOUKU-YK1.dts b/target/linux/ramips/dts/YOUKU-YK1.dts
index 260f86ab96..1763fb431a 100644
--- a/target/linux/ramips/dts/YOUKU-YK1.dts
+++ b/target/linux/ramips/dts/YOUKU-YK1.dts
@@ -105,7 +105,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/ZBT-APE522II.dts b/target/linux/ramips/dts/ZBT-APE522II.dts
index 9a8b700a50..07d7ff63fe 100644
--- a/target/linux/ramips/dts/ZBT-APE522II.dts
+++ b/target/linux/ramips/dts/ZBT-APE522II.dts
@@ -109,7 +109,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/ZBT-CPE102.dts b/target/linux/ramips/dts/ZBT-CPE102.dts
index 089084077d..f609a86954 100644
--- a/target/linux/ramips/dts/ZBT-CPE102.dts
+++ b/target/linux/ramips/dts/ZBT-CPE102.dts
@@ -102,7 +102,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/ZBT-WA05.dts b/target/linux/ramips/dts/ZBT-WA05.dts
index 33538892c3..2ed4a35714 100644
--- a/target/linux/ramips/dts/ZBT-WA05.dts
+++ b/target/linux/ramips/dts/ZBT-WA05.dts
@@ -102,7 +102,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/ZBT-WE826.dts b/target/linux/ramips/dts/ZBT-WE826.dts
index 8a453bca32..c7c5eb070f 100644
--- a/target/linux/ramips/dts/ZBT-WE826.dts
+++ b/target/linux/ramips/dts/ZBT-WE826.dts
@@ -102,7 +102,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/ZBT-WR8305RT.dts b/target/linux/ramips/dts/ZBT-WR8305RT.dts
index 81598bd237..c46165b63e 100644
--- a/target/linux/ramips/dts/ZBT-WR8305RT.dts
+++ b/target/linux/ramips/dts/ZBT-WR8305RT.dts
@@ -94,7 +94,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "llllw";
+	mediatek,portmap = <0x2f>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/ZTE-Q7.dts b/target/linux/ramips/dts/ZTE-Q7.dts
index 9ec1d89a41..099ce51dba 100644
--- a/target/linux/ramips/dts/ZTE-Q7.dts
+++ b/target/linux/ramips/dts/ZTE-Q7.dts
@@ -92,7 +92,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&ephy_pins>;
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/kn_rc.dts b/target/linux/ramips/dts/kn_rc.dts
index e25783f685..d9c33f0288 100644
--- a/target/linux/ramips/dts/kn_rc.dts
+++ b/target/linux/ramips/dts/kn_rc.dts
@@ -115,7 +115,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/dts/kn_rf.dts b/target/linux/ramips/dts/kn_rf.dts
index 4f2b71035e..11a817f708 100644
--- a/target/linux/ramips/dts/kn_rf.dts
+++ b/target/linux/ramips/dts/kn_rf.dts
@@ -115,7 +115,7 @@
 
 &ethernet {
 	mtd-mac-address = <&factory 0x4>;
-	mediatek,portmap = "wllll";
+	mediatek,portmap = <0x3e>;
 };
 
 &wmac {
diff --git a/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c b/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
index 1ec62e06d7..ad4dd2f939 100644
--- a/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
+++ b/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
@@ -195,56 +195,38 @@ struct mt7530_priv {
 	struct mt7530_port_entry	port_entries[MT7530_NUM_PORTS];
 };
 
-struct mt7530_mapping {
-	char	*name;
-	u16	pvids[MT7530_NUM_PORTS];
-	u8	members[MT7530_NUM_VLANS];
-	u8	etags[MT7530_NUM_VLANS];
-	u16	vids[MT7530_NUM_VLANS];
-} mt7530_defaults[] = {
-	{
-		.name = "llllw",
-		.pvids = { 1, 1, 1, 1, 2, 1, 1 },
-		.members = { 0, 0x6f, 0x50 },
-		.etags = { 0, 0x40, 0x40 },
-		.vids = { 0, 1, 2 },
-	}, {
-		.name = "wllll",
-		.pvids = { 2, 1, 1, 1, 1, 1, 1 },
-		.members = { 0, 0x7e, 0x41 },
-		.etags = { 0, 0x40, 0x40 },
-		.vids = { 0, 1, 2 },
-	},
-};
-
-struct mt7530_mapping*
-mt7530_find_mapping(struct device_node *np)
-{
-	const char *map;
-	int i;
-
-	if (of_property_read_string(np, "mediatek,portmap", &map))
-		return NULL;
-
-	for (i = 0; i < ARRAY_SIZE(mt7530_defaults); i++)
-		if (!strcmp(map, mt7530_defaults[i].name))
-			return &mt7530_defaults[i];
-
-	return NULL;
-}
-
 static void
-mt7530_apply_mapping(struct mt7530_priv *mt7530, struct mt7530_mapping *map)
+mt7530_apply_portmap(struct mt7530_priv *mt7530, struct device_node *np)
 {
+	const __be32 *port_map_ptr;
+	/* all ports in LAN VLAN by default */
+	unsigned char port_map = 0x3f;
 	int i = 0;
 
+	port_map_ptr = of_get_property(np, "mediatek,portmap", NULL);
+	if (port_map_ptr)
+		port_map = be32_to_cpu(*port_map_ptr);
+
+	/* assign ports to either VLAN 1 (bit set) or 2 (bit unset) */
 	for (i = 0; i < MT7530_NUM_PORTS; i++)
-		mt7530->port_entries[i].pvid = map->pvids[i];
+		mt7530->port_entries[i].pvid = (port_map & 1<<i)?1:2;
 
 	for (i = 0; i < MT7530_NUM_VLANS; i++) {
-		mt7530->vlan_entries[i].member = map->members[i];
-		mt7530->vlan_entries[i].etags = map->etags[i];
-		mt7530->vlan_entries[i].vid = map->vids[i];
+		switch (i) {
+			case 1:
+			case 2:
+				mt7530->vlan_entries[i].member = (i==1)?
+					1<<MT7530_CPU_PORT | port_map:
+					1<<MT7530_CPU_PORT | (0x7f & ~port_map);
+				mt7530->vlan_entries[i].etags = 0x40;
+				mt7530->vlan_entries[i].vid = i;
+				break;
+			default:
+				mt7530->vlan_entries[i].member = 0;
+				mt7530->vlan_entries[i].etags = 0;
+				mt7530->vlan_entries[i].vid = 0;
+				break;
+		}
 	}
 }
 
@@ -878,10 +860,8 @@ mt7530_probe(struct device *dev, void __iomem *base, struct mii_bus *bus, int vl
 		return ret;
 	}
 
+	mt7530_apply_portmap(mt7530, dev->of_node);
 
-	map = mt7530_find_mapping(dev->of_node);
-	if (map)
-		mt7530_apply_mapping(mt7530, map);
 	mt7530_apply_config(swdev);
 
 	/* magic vodoo */
-- 
2.11.1




More information about the Lede-dev mailing list