Skip to contentSkip to conversation

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

PATCH Superseded Simon Goldschmidt 2 participants 9 messages Jan 11, 2019 – Jan 12, 2019

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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 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 +---------
 configs/socfpga_arria5_defconfig              |  1 +
 configs/socfpga_cyclone5_defconfig            |  1 +
 configs/socfpga_dbm_soc1_defconfig            |  1 +
 configs/socfpga_de0_nano_soc_defconfig        |  1 +
 configs/socfpga_de10_nano_defconfig           |  1 +
 configs/socfpga_de1_soc_defconfig             |  1 +
 configs/socfpga_is1_defconfig                 |  1 +
 configs/socfpga_sockit_defconfig              |  1 +
 configs/socfpga_socrates_defconfig            |  1 +
 configs/socfpga_sr1500_defconfig              |  1 +
 configs/socfpga_vining_fpga_defconfig         |  1 +
 drivers/net/Kconfig                           |  2 +
 drivers/net/dwmac_socfpga.c                   | 87 +++++++------------
 16 files changed, 47 insertions(+), 164 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 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 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 v2 1/3 net: designware: socfpga: adapt to Gen5

Quoted 14 lines · Simon Goldschmidt

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.

Quoted 7 lines

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).

Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

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

In reply to Simon Goldschmidt

Enable the socfpga specific designware ethernet driver for all Gen5 and Arria10 defconfigs.

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

---

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

 configs/socfpga_arria5_defconfig       | 1 +
 configs/socfpga_cyclone5_defconfig     | 1 +
 configs/socfpga_dbm_soc1_defconfig     | 1 +
 configs/socfpga_de0_nano_soc_defconfig | 1 +
 configs/socfpga_de10_nano_defconfig    | 1 +
 configs/socfpga_de1_soc_defconfig      | 1 +
 configs/socfpga_is1_defconfig          | 1 +
 configs/socfpga_sockit_defconfig       | 1 +
 configs/socfpga_socrates_defconfig     | 1 +
 configs/socfpga_sr1500_defconfig       | 1 +
 configs/socfpga_vining_fpga_defconfig  | 1 +
 11 files changed, 11 insertions(+)
configs/socfpga_arria5_defconfig +1 -0
index 0e5e74a621..a829c33dd8 100644
@@ -59,6 +59,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_cyclone5_defconfig +1 -0
index e8de0f5709..5ebc668d32 100644
@@ -60,6 +60,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_dbm_soc1_defconfig +1 -0
index b6f4f8a3dd..03a03a6ddd 100644
@@ -54,6 +54,7 @@ CONFIG_MTD_DEVICE=y
 CONFIG_DM_ETH=y
 CONFIG_PHY_GIGE=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_de0_nano_soc_defconfig +1 -0
index 9a89bb5d68..bb202ee3c8 100644
@@ -54,6 +54,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_de10_nano_defconfig +1 -0
index db516891ba..3b18e302d2 100644
@@ -50,6 +50,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_de1_soc_defconfig +1 -0
index 5bed755723..ef3ee65760 100644
@@ -49,6 +49,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_is1_defconfig +1 -0
index 682e58fdb8..9ce3ec489f 100644
@@ -54,6 +54,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_sockit_defconfig +1 -0
index abbbcb94d3..39ab85547a 100644
@@ -60,6 +60,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_socrates_defconfig +1 -0
index 53f8d3c348..29d1e557ff 100644
@@ -60,6 +60,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_sr1500_defconfig +1 -0
index 97366cdfff..7c4bc5dfc2 100644
@@ -60,6 +60,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_DM_ETH=y
 CONFIG_PHY_GIGE=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
configs/socfpga_vining_fpga_defconfig +1 -0
index 3eba09dcb1..19c2c5e1e9 100644
@@ -76,6 +76,7 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_ETH_DESIGNWARE_SOCFPGA=y
 CONFIG_MII=y
 CONFIG_DM_RESET=y
 CONFIG_SPI=y
Signature · 1 line
2.17.1
#4 lore raw

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

Quoted 7 lines · Simon Goldschmidt

Enable the socfpga specific designware ethernet driver for all Gen5 and Arria10 defconfigs.

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

Can't the designware driver Kconfig entry just imply DESIGNWARE_SOCFPGA if ARCH_SOCFPGA ?

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

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

Am 11.01.2019 um 23:04 schrieb Marek Vasut:

Quoted 11 lines · Simon Goldschmidt
Quoted 7 lines

Enable the socfpga specific designware ethernet driver for all Gen5 and Arria10 defconfigs.

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

Can't the designware driver Kconfig entry just imply DESIGNWARE_SOCFPGA if ARCH_SOCFPGA ?

Yes it can. I just didn't know if that's acceptable. But since those two options are just next to each other in the Kconfig file, maybe it's ok.

Regards,
Simon

#6 lore raw

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

Quoted 8 lines · Simon Goldschmidt

Am 11.01.2019 um 23:04 schrieb Marek Vasut:

Quoted 7 lines · Simon Goldschmidt
Quoted 6 lines

Enable the socfpga specific designware ethernet driver for all Gen5 and Arria10 defconfigs.

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

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Can't the designware driver Kconfig entry just imply DESIGNWARE_SOCFPGA if ARCH_SOCFPGA ?

Yes it can. I just didn't know if that's acceptable. But since those two options are just next to each other in the Kconfig file, maybe it's ok.

Presumably it's a good idea to declutter defconfigs.

Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH v2 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 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
#8 lore raw

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

Quoted 7 lines · 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.

Signature · 2 lines
Best regards,
Marek Vasut