Skip to contentSkip to conversation

Enable mt7531 switch support for MT7629

PATCH Superseded MarkLee 2 participants 5 messages May 27, 2020 – Jun 15, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

MarkLee

author
#0 lore raw

cover Enable mt7531 switch support for MT7629

This patch series enable MT7629 sgmii mode with mt7531 switch support,
1. enable mt7629 sgmii mode support in mediatek eth driver
2. enable mt7629 ethernet dts node with sgmii mode and mt7531 switch support

MarkLee (2):
eth: mtk-eth: enable mt7629 sgmii mode support in mediatek eth driver
arm: dts: mediatek: enable sgmii mode and mt7531 switch for mt7629

 arch/arm/dts/mt7629-rfb.dts | 12 +++++++-----
 drivers/net/mtk_eth.h       |  5 +++++
 2 files changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 eth: mtk-eth: enable mt7629 sgmii mode support in mediatek eth driver

The sgmii mode init flow is almost the same for all mediatek SoC, the only difference is the register offset(SGMSYS_GEN2_SPEED) is 0x2028 for old chip(mt7622) but changed to 0x128 for newer chip(mt7629 and the following chips).

---
 drivers/net/mtk_eth.h | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/mtk_eth.h +5 -0
index f2940c9996..3c85eab91a 100644
@@ -44,7 +44,12 @@
 #define SGMSYS_QPHY_PWR_STATE_CTRL	0xe8
 #define SGMII_PHYA_PWD			BIT(4)
 
+#if defined(CONFIG_TARGET_MT7622)
 #define SGMSYS_GEN2_SPEED		0x2028
+#else
+#define SGMSYS_GEN2_SPEED		0x128
+#endif
+
 #define SGMSYS_SPEED_2500		BIT(2)
 
 /* Frame Engine Registers */
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/2 eth: mtk-eth: enable mt7629 sgmii mode support in mediatek eth driver

Hi MarkLee,

Quoted 16 lines · MarkLee

The sgmii mode init flow is almost the same for all mediatek SoC, the only difference is the register offset(SGMSYS_GEN2_SPEED) is 0x2028 for old chip(mt7622) but changed to 0x128 for newer chip(mt7629 and the following chips).

---
 drivers/net/mtk_eth.h | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/mtk_eth.h +0 -0
index f2940c9996..3c85eab91a 100644

drivers/net/mtk_eth.h line 51

Quoted 8 lines
drivers/net/mtk_eth.h +4 -0
@@ -44,7 +44,12 @@
 #define SGMSYS_QPHY_PWR_STATE_CTRL     0xe8
 #define SGMII_PHYA_PWD                 BIT(4)
 
+#if defined(CONFIG_TARGET_MT7622)
 #define SGMSYS_GEN2_SPEED              0x2028
+#else
+#define SGMSYS_GEN2_SPEED              0x128
+#endif

You can't check #ifdefs in drivers. You should use a compatible string, then device_get_driver_data() to decide what the value is here.

Or if this is board-specific you could add it to the device-tree node as a property, if it is in the binding.

Regards,
Simon

#3 lore raw

PATCH 1/2 eth: mtk-eth: enable mt7629 sgmii mode support in mediatek eth driver

Quoted 22 lines · Simon Glass

Hi MarkLee,

Quoted 19 lines · MarkLee

The sgmii mode init flow is almost the same for all mediatek SoC, the only difference is the register offset(SGMSYS_GEN2_SPEED) is 0x2028 for old chip(mt7622) but changed to 0x128 for newer chip(mt7629 and the following chips).

---
 drivers/net/mtk_eth.h | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/mtk_eth.h +0 -0
index f2940c9996..3c85eab91a 100644
@@ -44,7 +44,12 @@
 #define SGMSYS_QPHY_PWR_STATE_CTRL     0xe8
 #define SGMII_PHYA_PWD                 BIT(4)
 
Quoted 9 lines

drivers/net/mtk_eth.h line 51

Quoted 5 lines
drivers/net/mtk_eth.h +4 -0
+#if defined(CONFIG_TARGET_MT7622)
 #define SGMSYS_GEN2_SPEED              0x2028
+#else
+#define SGMSYS_GEN2_SPEED              0x128
+#endif

You can't check #ifdefs in drivers. You should use a compatible string, then device_get_driver_data() to decide what the value is here.

Thanks for your review and suggestion, will change to use private data from dts to decide the value in the following V2 patch.

Quoted 6 lines

Or if this is board-specific you could add it to the device-tree node as a property, if it is in the binding.

Regards,
Simon

author
#4 lore raw

PATCH 2/2 arm: dts: mediatek: enable sgmii mode and mt7531 switch for mt7629

In reply to MarkLee

This patch enable sgmii mode and mt7531 switch support in mt7629 ethernet dts node.

---
 arch/arm/dts/mt7629-rfb.dts | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/arm/dts/mt7629-rfb.dts +7 -5
index 687fe1c029..5864f5551b 100644
@@ -24,12 +24,14 @@
 
 &eth {
 	status = "okay";
-	mediatek,gmac-id = <1>;
-	phy-mode = "gmii";
-	phy-handle = <&phy0>;
+	mediatek,gmac-id = <0>;
+	phy-mode = "sgmii";
+	mediatek,switch = "mt7531";
+	reset-gpios = <&gpio 28 GPIO_ACTIVE_HIGH>;
 
-	phy0: ethernet-phy at 0 {
-		reg = <0>;
+	fixed-link {
+		speed = <1000>;
+		full-duplex;
 	};
 };
 
Signature · 1 line
2.17.1