Skip to contentSkip to conversation

arm: socpfpga: gen5 clean up ETH RST & PHY mode

PATCH New Simon Goldschmidt 2 participants 5 messages Jan 13, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover arm: socpfpga: gen5 clean up ETH RST & PHY mode

Socfpga Gen5 uses ad-hoc code to unreset the ETH MACs and set their PHY mode.

Change this to use the dwmac_socfpga net driver and remove the old ad-hoc code.

Changes in v3:
- imply CONFIG_ETH_DESIGNWARE_SOCFGPA instead of changing all defconfigs

Changes in v2:
- remove detection of sub-mach via compatible version and handle all FPGAs the same
- select SYSCON and REGMAP via Kconfig
- only add CONFIG_ETH_DESIGNWARE_SOCFPGA since now REGMAP and SYSCON are selected by this one

Simon Goldschmidt (3):
net: designware: socfpga: adapt to Gen5
arm: socfpga: gen5 enable designware_socfpga
arm: socfpga: gen5: remove hacked ETH RST handling

 .../mach-socfpga/include/mach/reset_manager.h |  2 -
 arch/arm/mach-socfpga/misc.c                  | 65 --------------
 arch/arm/mach-socfpga/misc_gen5.c             | 44 +---------
 drivers/net/Kconfig                           |  3 +
 drivers/net/dwmac_socfpga.c                   | 87 +++++++------------
 5 files changed, 37 insertions(+), 164 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/3 net: designware: socfpga: adapt to Gen5

This driver was written for Arria10, but it applies to Gen5, too.

The main difference is that Gen5 has 2 MACs (Arria10 has 3) and the syscon bits are encoded in the same register, thus an offset is needed.

This offset is already read from the devicetree, but for Arria10 it is always 0, which is probably why it has been ignored. By using this offset when writing the phy mode into the syscon regiter, we can use this driver to set the phy mode for both of the MACs on Gen5.

Since the PHY mode bits in sysmgr are the same even for Stratix10, let's drop the detection of the sub-mach by checking compatible version and just use the same code for all FPGAs.

To work correctly, this driver depends on SYSCON and REGMAP, so select those via Kconfig when it is enabeld.

Tested on socfpga_socrates (where the 2nd MAC is connected, so a shift offset is required).

---

Changes in v3: None
Changes in v2:
- remove detection of sub-mach via compatible version and handle all FPGAs the same
- select SYSCON and REGMAP via Kconfig

 drivers/net/Kconfig         |  2 +
 drivers/net/dwmac_socfpga.c | 87 ++++++++++++++-----------------------
 2 files changed, 35 insertions(+), 54 deletions(-)
drivers/net/Kconfig +2 -0
index 7044c6adf3..b7c0b921e6 100644
@@ -162,6 +162,8 @@ config ETH_DESIGNWARE
 	  provide the PHY (physical media interface).
 
 config ETH_DESIGNWARE_SOCFPGA
+	select REGMAP
+	select SYSCON
 	bool "Altera SoCFPGA extras for Synopsys Designware Ethernet MAC"
 	depends on DM_ETH && ETH_DESIGNWARE
 	help
drivers/net/dwmac_socfpga.c +33 -54

110 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 2/3 arm: socfpga: gen5 enable designware_socfpga

In reply to Simon Goldschmidt

Enable the socfpga specific designware ethernet driver by default for socfpga by implying it when enabling CONFIG_ETH_DESIGNWARE for a MACH_SOCFPGA config.

This is required to remove the hacky reset and phy mode handling in arch/arm/mach-socfpga.

---

Changes in v3:
- imply CONFIG_ETH_DESIGNWARE_SOCFGPA instead of changing all defconfigs

Changes in v2:
- only add CONFIG_ETH_DESIGNWARE_SOCFPGA since now REGMAP and SYSCON are selected by this one

 drivers/net/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/net/Kconfig +1 -0
index b7c0b921e6..46b677dba0 100644
@@ -156,6 +156,7 @@ config ETH_SANDBOX_RAW
 config ETH_DESIGNWARE
 	bool "Synopsys Designware Ethernet MAC"
 	select PHYLIB
+	imply ETH_DESIGNWARE_SOCFPGA if ARCH_SOCFPGA
 	help
 	  This MAC is present in SoCs from various vendors. It supports
 	  100Mbit and 1 Gbit operation. You must enable CONFIG_PHYLIB to
Signature · 1 line
2.17.1
#3 lore raw

PATCH v3 3/3 arm: socfpga: gen5: remove hacked ETH RST handling

In reply to Simon Goldschmidt

The 'dwmac_socfpga' ETH driver can now get the MACs out of reset via the socfpga reset driver and can set PHY mode via syscon.

This means we can now remove the ad-hoc code to do this from arch/arm/mach-socfpga.

---

Changes in v3: None
Changes in v2: None

 .../mach-socfpga/include/mach/reset_manager.h |  2 -
 arch/arm/mach-socfpga/misc.c                  | 65 -------------------
 arch/arm/mach-socfpga/misc_gen5.c             | 44 +------------
 3 files changed, 1 insertion(+), 110 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -2
index d9e0b33c60..42beaecdd6 100644
@@ -10,8 +10,6 @@ void reset_cpu(ulong addr);
 
 void socfpga_per_reset(u32 reset, int set);
 void socfpga_per_reset_all(void);
-int socfpga_eth_reset_common(void (*resetfn)(const u8 of_reset_id,
-					     const u8 phymode));
 
 #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
 
arch/arm/mach-socfpga/misc.c +0 -65

71 lines not on this page · raw message

arch/arm/mach-socfpga/misc_gen5.c +1 -43

56 lines not on this page · raw message

Signature · 1 line
2.17.1
Applied
#4 lore raw

v3 cover arm: socpfpga: gen5 clean up ETH RST & PHY mode

In reply to Simon Goldschmidt
Quoted 21 lines · Simon Goldschmidt

Socfpga Gen5 uses ad-hoc code to unreset the ETH MACs and set their PHY mode.

Change this to use the dwmac_socfpga net driver and remove the old ad-hoc code.

Changes in v3:
- imply CONFIG_ETH_DESIGNWARE_SOCFGPA instead of changing all defconfigs

Changes in v2:
- remove detection of sub-mach via compatible version and handle all FPGAs the same
- select SYSCON and REGMAP via Kconfig
- only add CONFIG_ETH_DESIGNWARE_SOCFPGA since now REGMAP and SYSCON are selected by this one

Simon Goldschmidt (3):
net: designware: socfpga: adapt to Gen5
arm: socfpga: gen5 enable designware_socfpga
arm: socfpga: gen5: remove hacked ETH RST handling

Quoted 7 lines
 .../mach-socfpga/include/mach/reset_manager.h |  2 -
 arch/arm/mach-socfpga/misc.c                  | 65 --------------
 arch/arm/mach-socfpga/misc_gen5.c             | 44 +---------
 drivers/net/Kconfig                           |  3 +
 drivers/net/dwmac_socfpga.c                   | 87 +++++++------------
 5 files changed, 37 insertions(+), 164 deletions(-)

Applied all, thanks!

Signature · 2 lines
Best regards,
Marek Vasut