aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Pratt <mcpratt@pm.me>2021-04-03 14:42:51 -0400
committerPetr Štetiar <ynezz@true.cz>2022-04-19 14:48:21 +0200
commit687646587581962572b5b0b805d2088feae36ec8 (patch)
tree65b6fef716c8bbc8c42672926edc33b13d4758c3
parent5d7805c78b7d8e9f02e53fdb2237971fa3353296 (diff)
downloadupstream-687646587581962572b5b0b805d2088feae36ec8.tar.gz
upstream-687646587581962572b5b0b805d2088feae36ec8.tar.bz2
upstream-687646587581962572b5b0b805d2088feae36ec8.zip
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 <mcpratt@pm.me> (cherry picked from commit 0976b6c4262a11a8d0dab9aeb64f5cdee266c44a)
-rw-r--r--target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts2
-rw-r--r--target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi4
-rw-r--r--target/linux/ramips/dts/mt7620a_engenius_esr600.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_fon_fon2601.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_linksys_e1700.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_netis_wf2770.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts4
-rw-r--r--target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_sercomm_na930.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts1
-rw-r--r--target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts1
-rw-r--r--target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c10
24 files changed, 60 insertions, 7 deletions
diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
index 71b532fc34..b86ab1449b 100644
--- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
+++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
@@ -186,4 +186,5 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
index 9ea28706aa..b0dd31cafc 100644
--- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
+++ b/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>;
};
diff --git a/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts b/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts
index 068f75bd96..ba1a2becda 100644
--- a/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts
+++ b/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts
@@ -136,6 +136,7 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
&pcie {
diff --git a/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts b/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts
index 2337c0f9d3..03a4c96f6b 100644
--- a/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts
+++ b/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>;
};
diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts b/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts
index 09763db388..986b047e47 100644
--- a/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts
+++ b/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>;
};
diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi
index 07b03f5c06..5cb8451547 100644
--- a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi
+++ b/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>;
};
diff --git a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts
index 35d0b3dbec..2f0f9b256e 100644
--- a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts
+++ b/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";
diff --git a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts
index b47d63be85..373205e725 100644
--- a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts
+++ b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts
@@ -137,6 +137,7 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
&wmac {
diff --git a/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts b/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts
index 487f6aaf6e..7d807bff4b 100644
--- a/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts
+++ b/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts
@@ -151,6 +151,7 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
&wmac {
diff --git a/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts b/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts
index 7044a511bc..d59b481a61 100644
--- a/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts
+++ b/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";
diff --git a/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts b/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts
index 20d0557916..6270af3b15 100644
--- a/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts
+++ b/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts
@@ -101,3 +101,7 @@
};
};
};
+
+&gsw {
+ mediatek,ephy-base = /bits/ 8 <12>;
+};
diff --git a/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts b/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts
index 962ef3371d..ee845c7b5e 100644
--- a/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts
+++ b/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts
@@ -150,6 +150,10 @@
};
};
+&gsw {
+ mediatek,ephy-base = /bits/ 8 <8>;
+};
+
&pcie {
status = "okay";
};
diff --git a/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts b/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts
index bb1303d4fb..9e0b817163 100644
--- a/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts
+++ b/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>;
};
diff --git a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts
index 0997d8a00e..0544550bf9 100644
--- a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts
+++ b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts
@@ -112,4 +112,5 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
diff --git a/target/linux/ramips/dts/mt7620a_linksys_e1700.dts b/target/linux/ramips/dts/mt7620a_linksys_e1700.dts
index 2672d54f36..c38ea8082c 100644
--- a/target/linux/ramips/dts/mt7620a_linksys_e1700.dts
+++ b/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>;
};
diff --git a/target/linux/ramips/dts/mt7620a_netis_wf2770.dts b/target/linux/ramips/dts/mt7620a_netis_wf2770.dts
index ab8c61b1d8..f839048865 100644
--- a/target/linux/ramips/dts/mt7620a_netis_wf2770.dts
+++ b/target/linux/ramips/dts/mt7620a_netis_wf2770.dts
@@ -142,6 +142,10 @@
};
};
+&gsw {
+ mediatek,ephy-base = /bits/ 8 <12>;
+};
+
&pcie {
status = "okay";
};
diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts
index 4c5baf1e50..ae35941507 100644
--- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts
+++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts
@@ -106,6 +106,7 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
&sdhci {
diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts
index b76ab2aa59..f7d8cae160 100644
--- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts
+++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts
@@ -99,6 +99,10 @@
};
};
+&gsw {
+ mediatek,ephy-base = /bits/ 8 <12>;
+};
+
&pcie {
status = "okay";
};
diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts
index 6e8eff50bc..0e963e1f02 100644
--- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts
+++ b/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 {
diff --git a/target/linux/ramips/dts/mt7620a_sercomm_na930.dts b/target/linux/ramips/dts/mt7620a_sercomm_na930.dts
index 329ecc5ea8..1ffc0a2bc8 100644
--- a/target/linux/ramips/dts/mt7620a_sercomm_na930.dts
+++ b/target/linux/ramips/dts/mt7620a_sercomm_na930.dts
@@ -167,6 +167,7 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
&ehci {
diff --git a/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts b/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts
index 247b5752ef..57cd0ed539 100644
--- a/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts
+++ b/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts
@@ -62,6 +62,7 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
&ethernet {
diff --git a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts
index 55ab939d15..bfec806c12 100644
--- a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts
+++ b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts
@@ -196,6 +196,7 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
&wmac {
diff --git a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts
index 506b828ec8..1a5ff2d0df 100644
--- a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts
+++ b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts
@@ -158,6 +158,7 @@
&gsw {
mediatek,port4-gmac;
+ mediatek,ephy-base = /bits/ 8 <8>;
};
&wmac {
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c
index 4b030f457b..54b8b204eb 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c
+++ b/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;