Browse Source

ramips: mt7620: use DTS to set PHY base address for external PHYs

Set the PHY base address to 12 for mt7530 and 8 for others,
which is based on the default setting for some devices
from printing the register with the following command
after it is written to by uboot during the boot cycle.

`md 0x10117014 1`

PHY_BASE option only uses 5 bits of the register,
bits 16 to 20, so use 8-bit integer type.

Set the option using the DTS property mediatek,ephy-base
and create the gsw node if missing.

Also, added a kernel message to display the EPHY base address.

Note:
If anything is written to a PHY address that is greater than 1 hex char (greater than 0xf)
then there is adverse effects with Atheros switches.

Signed-off-by: Michael Pratt <[email protected]>
Michael Pratt 4 years ago
parent
commit
0976b6c426
24 changed files with 60 additions and 7 deletions
  1. 1 0
      target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
  2. 1 1
      target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
  3. 1 0
      target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts
  4. 4 0
      target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts
  5. 4 0
      target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts
  6. 4 0
      target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi
  7. 4 0
      target/linux/ramips/dts/mt7620a_engenius_esr600.dts
  8. 1 0
      target/linux/ramips/dts/mt7620a_fon_fon2601.dts
  9. 1 0
      target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts
  10. 4 0
      target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts
  11. 4 0
      target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts
  12. 4 0
      target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts
  13. 4 0
      target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts
  14. 1 0
      target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts
  15. 4 0
      target/linux/ramips/dts/mt7620a_linksys_e1700.dts
  16. 4 0
      target/linux/ramips/dts/mt7620a_netis_wf2770.dts
  17. 1 0
      target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts
  18. 4 0
      target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts
  19. 1 0
      target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts
  20. 1 0
      target/linux/ramips/dts/mt7620a_sercomm_na930.dts
  21. 1 0
      target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts
  22. 1 0
      target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts
  23. 1 0
      target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts
  24. 4 6
      target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c

+ 1 - 0
target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts

@@ -186,4 +186,5 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };

+ 1 - 1
target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts

@@ -174,5 +174,5 @@
 
 &gsw {
 	mediatek,port4-gmac;
-	mediatek,ephy-base-address = /bits/ 16 < 2 >;
+	mediatek,ephy-base = /bits/ 8 <2>;
 };

+ 1 - 0
target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts

@@ -136,6 +136,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &pcie {

+ 4 - 0
target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts

@@ -177,6 +177,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <12>;
+};
+
 &wmac {
 	ralink,mtd-eeprom = <&factory 0x0>;
 };

+ 4 - 0
target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts

@@ -169,6 +169,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <12>;
+};
+
 &wmac {
 	ralink,mtd-eeprom = <&factory 0x0>;
 };

+ 4 - 0
target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi

@@ -201,6 +201,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <8>;
+};
+
 &wmac {
 	ralink,mtd-eeprom = <&factory 0x0>;
 };

+ 4 - 0
target/linux/ramips/dts/mt7620a_engenius_esr600.dts

@@ -160,6 +160,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <8>;
+};
+
 &state_default {
 	gpio {
 		groups = "i2c", "uartf", "nd_sd", "wled";

+ 1 - 0
target/linux/ramips/dts/mt7620a_fon_fon2601.dts

@@ -137,6 +137,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &wmac {

+ 1 - 0
target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts

@@ -151,6 +151,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &wmac {

+ 4 - 0
target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts

@@ -184,6 +184,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <12>;
+};
+
 &state_default {
 	gpio {
 		groups = "i2c", "uartf";

+ 4 - 0
target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts

@@ -101,3 +101,7 @@
 		};
 	};
 };
+
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <12>;
+};

+ 4 - 0
target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts

@@ -150,6 +150,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <8>;
+};
+
 &pcie {
 	status = "okay";
 };

+ 4 - 0
target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts

@@ -135,6 +135,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <12>;
+};
+
 &wmac {
 	ralink,mtd-eeprom = <&factory 0x0>;
 };

+ 1 - 0
target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts

@@ -112,4 +112,5 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };

+ 4 - 0
target/linux/ramips/dts/mt7620a_linksys_e1700.dts

@@ -144,6 +144,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <12>;
+};
+
 &wmac {
 	ralink,mtd-eeprom = <&factory 0x0>;
 };

+ 4 - 0
target/linux/ramips/dts/mt7620a_netis_wf2770.dts

@@ -142,6 +142,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <12>;
+};
+
 &pcie {
 	status = "okay";
 };

+ 1 - 0
target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts

@@ -106,6 +106,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &sdhci {

+ 4 - 0
target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts

@@ -99,6 +99,10 @@
 	};
 };
 
+&gsw {
+	mediatek,ephy-base = /bits/ 8 <12>;
+};
+
 &pcie {
 	status = "okay";
 };

+ 1 - 0
target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts

@@ -100,6 +100,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &pcie {

+ 1 - 0
target/linux/ramips/dts/mt7620a_sercomm_na930.dts

@@ -167,6 +167,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &ehci {

+ 1 - 0
target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts

@@ -62,6 +62,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &ethernet {

+ 1 - 0
target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts

@@ -196,6 +196,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &wmac {

+ 1 - 0
target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts

@@ -158,6 +158,7 @@
 
 &gsw {
 	mediatek,port4-gmac;
+	mediatek,ephy-base = /bits/ 8 <8>;
 };
 
 &wmac {

+ 4 - 6
target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c

@@ -98,9 +98,6 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode)
 	mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_MIB_CNT_EN) | (1 << 1), GSW_REG_MIB_CNT_EN);
 
 	if (mdio_mode) {
-		if (!gsw->ephy_base)
-			gsw->ephy_base = 12;
-
 		/* set MT7530 central align */
 		val = mt7530_mdio_r32(gsw, 0x7830);
 		val &= ~BIT(0);
@@ -115,11 +112,12 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode)
 	}
 
 	if (gsw->ephy_base) {
-		/* set phy base addr to ephy_base */
 		mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) |
 			(gsw->ephy_base << 16),
 			GSW_REG_GPC1);
 		fe_reset(BIT(24)); /* Resets the Ethernet PHY block. */
+
+		pr_info("gsw: ephy base address: %d\n", gsw->ephy_base);
 	}
 
 	/* global page 4 */
@@ -246,7 +244,7 @@ static int mt7620_gsw_probe(struct platform_device *pdev)
 	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	struct mt7620_gsw *gsw;
 	struct device_node *np = pdev->dev.of_node;
-	u16 val;
+	u8 val;
 
 	gsw = devm_kzalloc(&pdev->dev, sizeof(struct mt7620_gsw), GFP_KERNEL);
 	if (!gsw)
@@ -260,7 +258,7 @@ static int mt7620_gsw_probe(struct platform_device *pdev)
 
 	gsw->port4_ephy = !of_property_read_bool(np, "mediatek,port4-gmac");
 
-	if (of_property_read_u16(np, "mediatek,ephy-base-address", &val) == 0)
+	if (of_property_read_u8(np, "mediatek,ephy-base", &val) == 0)
 		gsw->ephy_base = val;
 	else
 		gsw->ephy_base = 0;