All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes
@ 2022-04-27 10:41 Marek Behún
  2022-04-27 10:41 ` [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata Marek Behún
                   ` (20 more replies)
  0 siblings, 21 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún, Chris Packham,
	Heinrich Schuchardt, Konstantin Porotchkin, Mario Six,
	Mark Kettenis, Phil Sutter, Rogier Stam, Simon Glass,
	Vladimir Oltean, Vladimir Vid

From: Marek Behún <marek.behun@nic.cz>

Hello Stefan,

here come some refactors, cleanups and fixed for the mvneta driver.

Marek Behún (19):
  net: mvneta: Get rid of platdata
  net: mvneta: Fix 10Mbps speed
  net: mvneta: Use DM MDIO API for connecting PHY
  net: mvneta: Remember fixed link instead of PHY address in priv data
  arm: mvebu: Espressobin: Use DM registered MDIO to configure switch
  net: mdio-uclass: add dm_phy_find_by_ofnode() helper
  arm: mvebu: turris_mox: Use DM registered MDIO
  net: mvneta: Don't register MDIO bus
  net: mvneta: Fix unused variable warning if DM_GPIO is disabled
  net: mvneta: Drop one indentation level in mvneta_adjust_link()
  net: mvneta: Use bool instead of int for boolean variable
  net: mvneta: Drop unnecessary space
  net: mventa: Don't check for CONFIG_PHYLIB
  net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS
  net: mvneta: Convert to use PHY_FIXED for fixed-link
  net: mvneta: Write PHY address just before enabling HW polling
  net: mvneta: Drop fixed_link member from private struct
  net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in
  net: mvneta: Drop unneeded macro

 .../dts/armada-3720-turris-mox-u-boot.dtsi    |  19 -
 board/CZ.NIC/turris_mox/turris_mox.c          |  88 ++---
 board/Marvell/mvebu_armada-37xx/board.c       |  26 +-
 configs/clearfog_defconfig                    |   1 +
 configs/controlcenterdc_defconfig             |   1 +
 configs/db-88f6820-amc_defconfig              |   1 +
 configs/db-88f6820-gp_defconfig               |   1 +
 configs/db-mv784mp-gp_defconfig               |   1 +
 configs/ds414_defconfig                       |   1 +
 configs/helios4_defconfig                     |   1 +
 configs/maxbcm_defconfig                      |   1 +
 configs/mvebu_espressobin-88f3720_defconfig   |   3 +
 configs/theadorable_debug_defconfig           |   1 +
 configs/turris_mox_defconfig                  |   1 +
 configs/turris_omnia_defconfig                |   2 +
 configs/uDPU_defconfig                        |   1 +
 drivers/net/Kconfig                           |   1 +
 drivers/net/mvneta.c                          | 343 ++++--------------
 include/miiphy.h                              |   9 +
 net/mdio-uclass.c                             |  22 ++
 20 files changed, 181 insertions(+), 343 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:28   ` Ramon Fried
  2022-05-02  6:48   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed Marek Behún
                   ` (19 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Drop .of_to_plat() from the mvneta driver and parse the two properties
in .probe().

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 15dc714058..d1c5f7930d 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1692,7 +1692,6 @@ static int mvneta_recv(struct udevice *dev, int flags, uchar **packetp)
 
 static int mvneta_probe(struct udevice *dev)
 {
-	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct mvneta_port *pp = dev_get_priv(dev);
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	struct ofnode_phandle_args sfp_args;
@@ -1729,7 +1728,10 @@ static int mvneta_probe(struct udevice *dev)
 		buffer_loc.rx_buffers = (phys_addr_t)(bd_space + size);
 	}
 
-	pp->base = (void __iomem *)pdata->iobase;
+	pp->base = dev_read_addr_ptr(dev);
+	pp->phy_interface = dev_read_phy_mode(dev);
+	if (pp->phy_interface == PHY_INTERFACE_MODE_NA)
+		return -EINVAL;
 
 	/* Configure MBUS address windows */
 	if (device_is_compatible(dev, "marvell,armada-3700-neta"))
@@ -1737,9 +1739,6 @@ static int mvneta_probe(struct udevice *dev)
 	else
 		mvneta_conf_mbus_windows(pp);
 
-	/* PHY interface is already decoded in mvneta_of_to_plat() */
-	pp->phy_interface = pdata->phy_interface;
-
 	/* fetch 'fixed-link' property from 'neta' node */
 	fl_node = fdt_subnode_offset(blob, node, "fixed-link");
 	if (fl_node != -FDT_ERR_NOTFOUND) {
@@ -1808,20 +1807,6 @@ static const struct eth_ops mvneta_ops = {
 	.write_hwaddr	= mvneta_write_hwaddr,
 };
 
-static int mvneta_of_to_plat(struct udevice *dev)
-{
-	struct eth_pdata *pdata = dev_get_plat(dev);
-
-	pdata->iobase = dev_read_addr(dev);
-
-	/* Get phy-mode / phy_interface from DT */
-	pdata->phy_interface = dev_read_phy_mode(dev);
-	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
-		return -EINVAL;
-
-	return 0;
-}
-
 static const struct udevice_id mvneta_ids[] = {
 	{ .compatible = "marvell,armada-370-neta" },
 	{ .compatible = "marvell,armada-xp-neta" },
@@ -1833,7 +1818,6 @@ U_BOOT_DRIVER(mvneta) = {
 	.name	= "mvneta",
 	.id	= UCLASS_ETH,
 	.of_match = mvneta_ids,
-	.of_to_plat = mvneta_of_to_plat,
 	.probe	= mvneta_probe,
 	.ops	= &mvneta_ops,
 	.priv_auto	= sizeof(struct mvneta_port),
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
  2022-04-27 10:41 ` [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:28   ` Ramon Fried
  2022-05-02  6:48   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY Marek Behún
                   ` (18 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

In mvneta_adjust_link() we need to set MII_SPEED bit only if PHY reports
the speed at 100Mbps.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index d1c5f7930d..79cdb93341 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1195,7 +1195,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 
 			if (phydev->speed == SPEED_1000)
 				val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
-			else
+			else if (pp->speed == SPEED_100)
 				val |= MVNETA_GMAC_CONFIG_MII_SPEED;
 
 			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
  2022-04-27 10:41 ` [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata Marek Behún
  2022-04-27 10:41 ` [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:28   ` Ramon Fried
  2022-05-02  6:48   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data Marek Behún
                   ` (17 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún, Mario Six, Chris Packham,
	Phil Sutter, Konstantin Porotchkin, Vladimir Vid

From: Marek Behún <marek.behun@nic.cz>

Use the modern DM MDIO API for connecting PHY in the mvneta driver.

This requires enabling MVMDIO driver in several config files.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 configs/clearfog_defconfig                  |  1 +
 configs/controlcenterdc_defconfig           |  1 +
 configs/db-88f6820-amc_defconfig            |  1 +
 configs/db-88f6820-gp_defconfig             |  1 +
 configs/db-mv784mp-gp_defconfig             |  1 +
 configs/ds414_defconfig                     |  1 +
 configs/helios4_defconfig                   |  1 +
 configs/maxbcm_defconfig                    |  1 +
 configs/mvebu_espressobin-88f3720_defconfig |  1 +
 configs/theadorable_debug_defconfig         |  1 +
 configs/turris_mox_defconfig                |  1 +
 configs/turris_omnia_defconfig              |  1 +
 configs/uDPU_defconfig                      |  1 +
 drivers/net/Kconfig                         |  1 +
 drivers/net/mvneta.c                        | 11 +++++------
 15 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig
index 880f16a6e0..b8f59d2962 100644
--- a/configs/clearfog_defconfig
+++ b/configs/clearfog_defconfig
@@ -63,6 +63,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_PCI_MVEBU=y
 CONFIG_SCSI=y
diff --git a/configs/controlcenterdc_defconfig b/configs/controlcenterdc_defconfig
index d4b966b93f..df38b2c54f 100644
--- a/configs/controlcenterdc_defconfig
+++ b/configs/controlcenterdc_defconfig
@@ -77,6 +77,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_DM_PCI_COMPAT=y
 CONFIG_PCI_MVEBU=y
diff --git a/configs/db-88f6820-amc_defconfig b/configs/db-88f6820-amc_defconfig
index 46c822fccd..9b77b4a5f0 100644
--- a/configs/db-88f6820-amc_defconfig
+++ b/configs/db-88f6820-amc_defconfig
@@ -67,6 +67,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_PCI_MVEBU=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/db-88f6820-gp_defconfig b/configs/db-88f6820-gp_defconfig
index 2dcbc2f29a..f56d1fbf25 100644
--- a/configs/db-88f6820-gp_defconfig
+++ b/configs/db-88f6820-gp_defconfig
@@ -62,6 +62,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_PCI_MVEBU=y
 CONFIG_SCSI=y
diff --git a/configs/db-mv784mp-gp_defconfig b/configs/db-mv784mp-gp_defconfig
index f19cc54975..5683f11836 100644
--- a/configs/db-mv784mp-gp_defconfig
+++ b/configs/db-mv784mp-gp_defconfig
@@ -65,6 +65,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_PCI_MVEBU=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/ds414_defconfig b/configs/ds414_defconfig
index a3279c15c5..a83fe079b3 100644
--- a/configs/ds414_defconfig
+++ b/configs/ds414_defconfig
@@ -65,6 +65,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_PCI_MVEBU=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/helios4_defconfig b/configs/helios4_defconfig
index 7d812e8fab..c2130bacb4 100644
--- a/configs/helios4_defconfig
+++ b/configs/helios4_defconfig
@@ -63,6 +63,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_PCI_MVEBU=y
 CONFIG_SCSI=y
diff --git a/configs/maxbcm_defconfig b/configs/maxbcm_defconfig
index 8dd6adf247..40f79d47ea 100644
--- a/configs/maxbcm_defconfig
+++ b/configs/maxbcm_defconfig
@@ -47,6 +47,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550=y
 CONFIG_KIRKWOOD_SPI=y
diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
index ff05630d20..af30f1b363 100644
--- a/configs/mvebu_espressobin-88f3720_defconfig
+++ b/configs/mvebu_espressobin-88f3720_defconfig
@@ -76,6 +76,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MVNETA=y
+CONFIG_MVMDIO=y
 CONFIG_NVME_PCI=y
 CONFIG_PCI=y
 CONFIG_PCI_AARDVARK=y
diff --git a/configs/theadorable_debug_defconfig b/configs/theadorable_debug_defconfig
index 86129e7d2d..9a03a0a7a3 100644
--- a/configs/theadorable_debug_defconfig
+++ b/configs/theadorable_debug_defconfig
@@ -70,6 +70,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_DM_PCI_COMPAT=y
 CONFIG_PCI_MVEBU=y
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
index 9a76a118c2..bcd3699a4f 100644
--- a/configs/turris_mox_defconfig
+++ b/configs/turris_mox_defconfig
@@ -82,6 +82,7 @@ CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
+CONFIG_MVMDIO=y
 CONFIG_NVME_PCI=y
 CONFIG_PCI=y
 CONFIG_PCI_AARDVARK=y
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index ad56d3824b..6b218bd7a7 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -82,6 +82,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
+CONFIG_MVMDIO=y
 CONFIG_NVME_PCI=y
 CONFIG_PCI=y
 CONFIG_PCI_MVEBU=y
diff --git a/configs/uDPU_defconfig b/configs/uDPU_defconfig
index c07bad5076..f2852ad29b 100644
--- a/configs/uDPU_defconfig
+++ b/configs/uDPU_defconfig
@@ -73,6 +73,7 @@ CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MVNETA=y
+CONFIG_MVMDIO=y
 CONFIG_PCI=y
 CONFIG_PCI_AARDVARK=y
 CONFIG_PHY=y
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 347fe8aa42..47f7a262f2 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -445,6 +445,7 @@ config MVNETA
 	bool "Marvell Armada XP/385/3700 network interface support"
 	depends on ARMADA_XP || ARMADA_38X || ARMADA_3700
 	select PHYLIB
+	select DM_MDIO
 	help
 	  This driver supports the network interface units in the
 	  Marvell ARMADA XP, ARMADA 38X and ARMADA 3700 SoCs
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 79cdb93341..24a491dcde 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1571,16 +1571,15 @@ static int mvneta_start(struct udevice *dev)
 
 			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
 		} else {
-			/* Set phy address of the port */
-			mvreg_write(pp, MVNETA_PHY_ADDR, pp->phyaddr);
-
-			phydev = phy_connect(pp->bus, pp->phyaddr, dev,
-					     pp->phy_interface);
+			phydev = dm_eth_phy_connect(dev);
 			if (!phydev) {
-				printf("phy_connect failed\n");
+				printf("dm_eth_phy_connect failed\n");
 				return -ENODEV;
 			}
 
+			/* Set PHY address in case we will enable HW polling */
+			mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
+
 			pp->phydev = phydev;
 			phy_config(phydev);
 			phy_startup(phydev);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (2 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:28   ` Ramon Fried
  2022-05-02  6:48   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 05/19] arm: mvebu: Espressobin: Use DM registered MDIO to configure switch Marek Behún
                   ` (16 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

We don't need to remember PHY address anymore, because since using DM
MDIO for connecting PHY, the address is parsed by mdio-uclass from
the ofnode.

But the driver uses a special value of the address to signal fixed link
usage.

Drop phyaddr add fixed_link in driver private structure. This simplifies
code a little.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 24a491dcde..83e9629138 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -277,12 +277,12 @@ struct mvneta_port {
 	u16 rx_ring_size;
 
 	phy_interface_t phy_interface;
+	bool fixed_link;
 	unsigned int link;
 	unsigned int duplex;
 	unsigned int speed;
 
 	int init;
-	int phyaddr;
 	struct phy_device *phydev;
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	struct gpio_desc phy_reset_gpio;
@@ -576,13 +576,6 @@ static void mvneta_rxq_buf_size_set(struct mvneta_port *pp,
 	mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), val);
 }
 
-static int mvneta_port_is_fixed_link(struct mvneta_port *pp)
-{
-	/* phy_addr is set to invalid value for fixed link */
-	return pp->phyaddr > PHY_MAX_ADDR;
-}
-
-
 /* Start the Ethernet port RX and TX activity */
 static void mvneta_port_up(struct mvneta_port *pp)
 {
@@ -834,7 +827,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
 	mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
 
 	/* Enable PHY polling in hardware if not in fixed-link mode */
-	if (!mvneta_port_is_fixed_link(pp)) {
+	if (!pp->fixed_link) {
 		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
 		val |= MVNETA_PHY_POLLING_ENABLE;
 		mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
@@ -1173,7 +1166,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 	struct phy_device *phydev = pp->phydev;
 	int status_change = 0;
 
-	if (mvneta_port_is_fixed_link(pp)) {
+	if (pp->fixed_link) {
 		debug("Using fixed link, skip link adjust\n");
 		return;
 	}
@@ -1548,7 +1541,7 @@ static int mvneta_start(struct udevice *dev)
 	mvneta_port_power_up(pp, pp->phy_interface);
 
 	if (!pp->init || pp->link == 0) {
-		if (mvneta_port_is_fixed_link(pp)) {
+		if (pp->fixed_link) {
 			u32 val;
 
 			pp->init = 1;
@@ -1698,7 +1691,6 @@ static int mvneta_probe(struct udevice *dev)
 	void *blob = (void *)gd->fdt_blob;
 	int node = dev_of_offset(dev);
 	struct mii_dev *bus;
-	unsigned long addr;
 	void *bd_space;
 	int ret;
 	int fl_node;
@@ -1742,14 +1734,9 @@ static int mvneta_probe(struct udevice *dev)
 	fl_node = fdt_subnode_offset(blob, node, "fixed-link");
 	if (fl_node != -FDT_ERR_NOTFOUND) {
 		/* set phy_addr to invalid value for fixed link */
-		pp->phyaddr = PHY_MAX_ADDR + 1;
 		pp->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex");
 		pp->speed = fdtdec_get_int(blob, fl_node, "speed", 0);
-	} else {
-		/* Now read phyaddr from DT */
-		addr = fdtdec_get_int(blob, node, "phy", 0);
-		addr = fdt_node_offset_by_phandle(blob, addr);
-		pp->phyaddr = fdtdec_get_int(blob, addr, "reg", 0);
+		pp->fixed_link = true;
 	}
 
 	bus = mdio_alloc();
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 05/19] arm: mvebu: Espressobin: Use DM registered MDIO to configure switch
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (3 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-05-02  6:48   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper Marek Behún
                   ` (15 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún, Konstantin Porotchkin,
	Rogier Stam, Mark Kettenis

From: Marek Behún <marek.behun@nic.cz>

In order to be able to get rid of the non-DM MDIO bus registered in
mvneta driver, we need to stop using board_network_enable() and instead
use the DM registered MDIO device to configure switch in
last_stage_init().

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 board/Marvell/mvebu_armada-37xx/board.c     | 26 ++++++++++++++++-----
 configs/mvebu_espressobin-88f3720_defconfig |  1 +
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c
index 98e1b36d11..3e5e0a0b5c 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -11,6 +11,7 @@
 #include <i2c.h>
 #include <init.h>
 #include <mmc.h>
+#include <miiphy.h>
 #include <phy.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
@@ -254,14 +255,15 @@ int board_xhci_enable(fdt_addr_t base)
 	return 0;
 }
 
+#ifdef CONFIG_LAST_STAGE_INIT
 /* Helper function for accessing switch devices in multi-chip connection mode */
-static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
+static int mii_multi_chip_mode_write(struct udevice *bus, int dev_smi_addr,
 				     int smi_addr, int reg, u16 value)
 {
 	u16 smi_cmd = 0;
 
-	if (bus->write(bus, dev_smi_addr, 0,
-		       MVEBU_SW_SMI_DATA_REG, value) != 0) {
+	if (dm_mdio_write(bus, dev_smi_addr, MDIO_DEVAD_NONE,
+			  MVEBU_SW_SMI_DATA_REG, value) != 0) {
 		printf("Error writing to the PHY addr=%02x reg=%02x\n",
 		       smi_addr, reg);
 		return -EFAULT;
@@ -272,8 +274,8 @@ static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
 		  (1 << SW_SMI_CMD_SMI_OP_OFF) |
 		  (smi_addr << SW_SMI_CMD_DEV_ADDR_OFF) |
 		  (reg << SW_SMI_CMD_REG_ADDR_OFF);
-	if (bus->write(bus, dev_smi_addr, 0,
-		       MVEBU_SW_SMI_CMD_REG, smi_cmd) != 0) {
+	if (dm_mdio_write(bus, dev_smi_addr, MDIO_DEVAD_NONE,
+			  MVEBU_SW_SMI_CMD_REG, smi_cmd) != 0) {
 		printf("Error writing to the PHY addr=%02x reg=%02x\n",
 		       smi_addr, reg);
 		return -EFAULT;
@@ -283,11 +285,22 @@ static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
 }
 
 /* Bring-up board-specific network stuff */
-int board_network_enable(struct mii_dev *bus)
+int last_stage_init(void)
 {
+	struct udevice *bus;
+	ofnode node;
+
 	if (!of_machine_is_compatible("globalscale,espressobin"))
 		return 0;
 
+	node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
+	if (!ofnode_valid(node) ||
+	    uclass_get_device_by_ofnode(UCLASS_MDIO, node, &bus) ||
+	    device_probe(bus)) {
+		printf("Cannot find MDIO bus\n");
+		return 0;
+	}
+
 	/*
 	 * FIXME: remove this code once Topaz driver gets available
 	 * A3720 Community Board Only
@@ -327,6 +340,7 @@ int board_network_enable(struct mii_dev *bus)
 
 	return 0;
 }
+#endif
 
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, struct bd_info *bd)
diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
index af30f1b363..37e4fdc41e 100644
--- a/configs/mvebu_espressobin-88f3720_defconfig
+++ b/configs/mvebu_espressobin-88f3720_defconfig
@@ -25,6 +25,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_ARCH_EARLY_INIT_R=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_BOARD_LATE_INIT=y
+CONFIG_LAST_STAGE_INIT=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (4 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 05/19] arm: mvebu: Espressobin: Use DM registered MDIO to configure switch Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:28   ` Ramon Fried
  2022-05-02  7:00   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 07/19] arm: mvebu: turris_mox: Use DM registered MDIO Marek Behún
                   ` (14 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún, Heinrich Schuchardt,
	Vladimir Oltean, Simon Glass

From: Marek Behún <marek.behun@nic.cz>

Add helper to resolve PHY node from it's ofnode via DM MDIO subsystem.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 include/miiphy.h  |  9 +++++++++
 net/mdio-uclass.c | 22 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/include/miiphy.h b/include/miiphy.h
index 110921f20d..c66a1845b5 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -188,6 +188,15 @@ int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, u16 va
  */
 int dm_mdio_reset(struct udevice *mdio_dev);
 
+/**
+ * dm_phy_find_by_ofnode - Find PHY device by ofnode
+ *
+ * @phynode: PHY's ofnode
+ *
+ * Return: pointer to phy_device, or NULL on error
+ */
+struct phy_device *dm_phy_find_by_ofnode(ofnode phynode);
+
 /**
  * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO
  *
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index 7593618d9a..4401492ca0 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -129,6 +129,28 @@ static int dm_mdio_pre_remove(struct udevice *dev)
 	return 0;
 }
 
+struct phy_device *dm_phy_find_by_ofnode(ofnode phynode)
+{
+	struct mdio_perdev_priv *pdata;
+	struct udevice *mdiodev;
+	u32 phy_addr;
+
+	if (ofnode_read_u32(phynode, "reg", &phy_addr))
+		return NULL;
+
+	if (uclass_get_device_by_ofnode(UCLASS_MDIO,
+					ofnode_get_parent(phynode),
+					&mdiodev))
+		return NULL;
+
+	if (device_probe(mdiodev))
+		return NULL;
+
+	pdata = dev_get_uclass_priv(mdiodev);
+
+	return phy_find_by_mask(pdata->mii_bus, BIT(phy_addr));
+}
+
 struct phy_device *dm_mdio_phy_connect(struct udevice *mdiodev, int phyaddr,
 				       struct udevice *ethdev,
 				       phy_interface_t interface)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 07/19] arm: mvebu: turris_mox: Use DM registered MDIO
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (5 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-05-02  7:00   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus Marek Behún
                   ` (13 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

In order to be able to get rid of the non-DM MDIO bus registered in
mvneta driver, start using the DM registered one in Turris MOX board
code.

This also allows us to drop the hack introduced in MOX' -u-boot.dtsi
file.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 .../dts/armada-3720-turris-mox-u-boot.dtsi    | 19 ----
 board/CZ.NIC/turris_mox/turris_mox.c          | 88 +++++++++----------
 2 files changed, 44 insertions(+), 63 deletions(-)

diff --git a/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi b/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi
index 28a36a6103..71d5e70ca4 100644
--- a/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi
+++ b/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi
@@ -3,25 +3,6 @@
  * 2022 by Marek Behún <kabel@kernel.org>
  */
 
-/ {
-	mdio {
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		old_binding_phy1: ethernet-phy@1 {
-			reg = <1>;
-		};
-	};
-};
-
-&eth0 {
-	pinctrl-0 = <&rgmii_pins>, <&smi_pins>;
-	/delete-property/ phy-handle;
-	phy = <&old_binding_phy1>;
-};
-
-/delete-node/ &mdio;
-
 &usb3 {
 	vbus-supply = <&exp_usb3_vbus>;
 };
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
index 9702d1fc78..a4738b3a3c 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -13,6 +13,7 @@
 #include <button.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/of_extra.h>
 #include <env.h>
 #include <fdt_support.h>
 #include <init.h>
@@ -216,35 +217,35 @@ static int mox_get_topology(const u8 **ptopology, int *psize, int *pis_sd)
 #define SW_SMI_CMD_R(d, r)	(0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
 #define SW_SMI_CMD_W(d, r)	(0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
 
-static int sw_multi_read(struct mii_dev *bus, int sw, int dev, int reg)
+static int sw_multi_read(struct udevice *bus, int sw, int dev, int reg)
 {
-	bus->write(bus, sw, 0, 0, SW_SMI_CMD_R(dev, reg));
+	dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 0, SW_SMI_CMD_R(dev, reg));
 	mdelay(5);
-	return bus->read(bus, sw, 0, 1);
+	return dm_mdio_read(bus, sw, MDIO_DEVAD_NONE, 1);
 }
 
-static void sw_multi_write(struct mii_dev *bus, int sw, int dev, int reg,
+static void sw_multi_write(struct udevice *bus, int sw, int dev, int reg,
 			   u16 val)
 {
-	bus->write(bus, sw, 0, 1, val);
-	bus->write(bus, sw, 0, 0, SW_SMI_CMD_W(dev, reg));
+	dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 1, val);
+	dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 0, SW_SMI_CMD_W(dev, reg));
 	mdelay(5);
 }
 
-static int sw_scratch_read(struct mii_dev *bus, int sw, int reg)
+static int sw_scratch_read(struct udevice *bus, int sw, int reg)
 {
 	sw_multi_write(bus, sw, 0x1c, 0x1a, (reg & 0x7f) << 8);
 	return sw_multi_read(bus, sw, 0x1c, 0x1a) & 0xff;
 }
 
-static void sw_led_write(struct mii_dev *bus, int sw, int port, int reg,
+static void sw_led_write(struct udevice *bus, int sw, int port, int reg,
 			 u16 val)
 {
 	sw_multi_write(bus, sw, port, 0x16, 0x8000 | ((reg & 7) << 12)
 					    | (val & 0x7ff));
 }
 
-static void sw_blink_leds(struct mii_dev *bus, int peridot, int topaz)
+static void sw_blink_leds(struct udevice *bus, int peridot, int topaz)
 {
 	int i, p;
 	struct {
@@ -275,7 +276,7 @@ static void sw_blink_leds(struct mii_dev *bus, int peridot, int topaz)
 	}
 }
 
-static void check_switch_address(struct mii_dev *bus, int addr)
+static void check_switch_address(struct udevice *bus, int addr)
 {
 	if (sw_scratch_read(bus, addr, 0x70) >> 3 != addr)
 		printf("Check of switch MDIO address failed for 0x%02x\n",
@@ -374,36 +375,22 @@ static void mox_phy_modify(struct phy_device *phydev, int page, int reg,
 static void mox_phy_leds_start_blinking(void)
 {
 	struct phy_device *phydev;
-	struct mii_dev *bus;
-	const char *node_name;
-	int node;
+	ofnode phy_node;
 
-	node = fdt_path_offset(gd->fdt_blob, "ethernet0");
-	if (node < 0) {
-		printf("Cannot get eth0!\n");
-		return;
-	}
+	phy_node = ofnode_get_phy_node(ofnode_path("ethernet0"));
+	if (!ofnode_valid(phy_node))
+		goto err;
 
-	node_name = fdt_get_name(gd->fdt_blob, node, NULL);
-	if (!node_name) {
-		printf("Cannot get eth0 node name!\n");
-		return;
-	}
-
-	bus = miiphy_get_dev_by_name(node_name);
-	if (!bus) {
-		printf("Cannot get MDIO bus device!\n");
-		return;
-	}
-
-	phydev = phy_find_by_mask(bus, BIT(1));
-	if (!phydev) {
-		printf("Cannot get ethernet PHY!\n");
-		return;
-	}
+	phydev = dm_phy_find_by_ofnode(phy_node);
+	if (!phydev)
+		goto err;
 
 	mox_phy_modify(phydev, 3, 0x12, 0x700, 0x400);
 	mox_phy_modify(phydev, 3, 0x10, 0xff, 0xbb);
+
+	return;
+err:
+	printf("Cannot get ethernet PHY!\n");
 }
 
 static bool read_reset_button(void)
@@ -611,6 +598,26 @@ int show_board_info(void)
 	return 0;
 }
 
+static struct udevice *mox_mdio_bus(void)
+{
+	struct udevice *bus;
+	ofnode node;
+
+	node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
+	if (!ofnode_valid(node))
+		goto err;
+
+	dm_mdio_probe_devices();
+
+	if (uclass_get_device_by_ofnode(UCLASS_MDIO, node, &bus))
+		goto err;
+
+	return bus;
+err:
+	printf("Cannot get MDIO bus device!\n");
+	return NULL;
+}
+
 int last_stage_init(void)
 {
 	struct gpio_desc reset_gpio = {};
@@ -636,16 +643,9 @@ int last_stage_init(void)
 	 * 0x70 of Peridot (and potentially Topaz) modules
 	 */
 	if (peridot || topaz) {
-		struct mii_dev *bus;
-		const char *node_name;
-		int node;
+		struct udevice *bus = mox_mdio_bus();
 
-		node = fdt_path_offset(gd->fdt_blob, "ethernet0");
-		node_name = (node >= 0) ? fdt_get_name(gd->fdt_blob, node, NULL) : NULL;
-		bus = node_name ? miiphy_get_dev_by_name(node_name) : NULL;
-		if (!bus) {
-			printf("Cannot get MDIO bus device!\n");
-		} else {
+		if (bus) {
 			int i;
 
 			for (i = 0; i < peridot; ++i)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (6 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 07/19] arm: mvebu: turris_mox: Use DM registered MDIO Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:29   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled Marek Behún
                   ` (12 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

This MDIO bus is now handled by a proper mvmdio DM driver. Remove it
from mvneta.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 143 +------------------------------------------
 1 file changed, 2 insertions(+), 141 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 83e9629138..19f8145fc0 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -288,7 +288,6 @@ struct mvneta_port {
 	struct gpio_desc phy_reset_gpio;
 	struct gpio_desc sfp_tx_disable_gpio;
 #endif
-	struct mii_dev *bus;
 };
 
 /* The mvneta_tx_desc and mvneta_rx_desc structures describe the
@@ -414,15 +413,6 @@ static struct buffer_location buffer_loc;
  */
 #define BD_SPACE	(1 << 20)
 
-/*
- * Dummy implementation that can be overwritten by a board
- * specific function
- */
-__weak int board_network_enable(struct mii_dev *bus)
-{
-	return 0;
-}
-
 /* Utility/helper methods */
 
 /* Write helper method */
@@ -1421,118 +1411,6 @@ static int mvneta_init(struct udevice *dev)
 
 /* U-Boot only functions follow here */
 
-/* SMI / MDIO functions */
-
-static int smi_wait_ready(struct mvneta_port *pp)
-{
-	u32 timeout = MVNETA_SMI_TIMEOUT;
-	u32 smi_reg;
-
-	/* wait till the SMI is not busy */
-	do {
-		/* read smi register */
-		smi_reg = mvreg_read(pp, MVNETA_SMI);
-		if (timeout-- == 0) {
-			printf("Error: SMI busy timeout\n");
-			return -EFAULT;
-		}
-	} while (smi_reg & MVNETA_SMI_BUSY);
-
-	return 0;
-}
-
-/*
- * mvneta_mdio_read - miiphy_read callback function.
- *
- * Returns 16bit phy register value, or 0xffff on error
- */
-static int mvneta_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
-{
-	struct mvneta_port *pp = bus->priv;
-	u32 smi_reg;
-	u32 timeout;
-
-	/* check parameters */
-	if (addr > MVNETA_PHY_ADDR_MASK) {
-		printf("Error: Invalid PHY address %d\n", addr);
-		return -EFAULT;
-	}
-
-	if (reg > MVNETA_PHY_REG_MASK) {
-		printf("Err: Invalid register offset %d\n", reg);
-		return -EFAULT;
-	}
-
-	/* wait till the SMI is not busy */
-	if (smi_wait_ready(pp) < 0)
-		return -EFAULT;
-
-	/* fill the phy address and regiser offset and read opcode */
-	smi_reg = (addr << MVNETA_SMI_DEV_ADDR_OFFS)
-		| (reg << MVNETA_SMI_REG_ADDR_OFFS)
-		| MVNETA_SMI_OPCODE_READ;
-
-	/* write the smi register */
-	mvreg_write(pp, MVNETA_SMI, smi_reg);
-
-	/* wait till read value is ready */
-	timeout = MVNETA_SMI_TIMEOUT;
-
-	do {
-		/* read smi register */
-		smi_reg = mvreg_read(pp, MVNETA_SMI);
-		if (timeout-- == 0) {
-			printf("Err: SMI read ready timeout\n");
-			return -EFAULT;
-		}
-	} while (!(smi_reg & MVNETA_SMI_READ_VALID));
-
-	/* Wait for the data to update in the SMI register */
-	for (timeout = 0; timeout < MVNETA_SMI_TIMEOUT; timeout++)
-		;
-
-	return mvreg_read(pp, MVNETA_SMI) & MVNETA_SMI_DATA_MASK;
-}
-
-/*
- * mvneta_mdio_write - miiphy_write callback function.
- *
- * Returns 0 if write succeed, -EINVAL on bad parameters
- * -ETIME on timeout
- */
-static int mvneta_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
-			     u16 value)
-{
-	struct mvneta_port *pp = bus->priv;
-	u32 smi_reg;
-
-	/* check parameters */
-	if (addr > MVNETA_PHY_ADDR_MASK) {
-		printf("Error: Invalid PHY address %d\n", addr);
-		return -EFAULT;
-	}
-
-	if (reg > MVNETA_PHY_REG_MASK) {
-		printf("Err: Invalid register offset %d\n", reg);
-		return -EFAULT;
-	}
-
-	/* wait till the SMI is not busy */
-	if (smi_wait_ready(pp) < 0)
-		return -EFAULT;
-
-	/* fill the phy addr and reg offset and write opcode and data */
-	smi_reg = value << MVNETA_SMI_DATA_OFFS;
-	smi_reg |= (addr << MVNETA_SMI_DEV_ADDR_OFFS)
-		| (reg << MVNETA_SMI_REG_ADDR_OFFS);
-	smi_reg &= ~MVNETA_SMI_OPCODE_READ;
-
-	/* write the smi register */
-	mvreg_write(pp, MVNETA_SMI, smi_reg);
-
-	return 0;
-}
-
 static int mvneta_start(struct udevice *dev)
 {
 	struct mvneta_port *pp = dev_get_priv(dev);
@@ -1690,10 +1568,9 @@ static int mvneta_probe(struct udevice *dev)
 #endif
 	void *blob = (void *)gd->fdt_blob;
 	int node = dev_of_offset(dev);
-	struct mii_dev *bus;
 	void *bd_space;
-	int ret;
 	int fl_node;
+	int ret;
 
 	/*
 	 * Allocate buffer area for descs and rx_buffers. This is only
@@ -1739,22 +1616,6 @@ static int mvneta_probe(struct udevice *dev)
 		pp->fixed_link = true;
 	}
 
-	bus = mdio_alloc();
-	if (!bus) {
-		printf("Failed to allocate MDIO bus\n");
-		return -ENOMEM;
-	}
-
-	bus->read = mvneta_mdio_read;
-	bus->write = mvneta_mdio_write;
-	snprintf(bus->name, sizeof(bus->name), dev->name);
-	bus->priv = (void *)pp;
-	pp->bus = bus;
-
-	ret = mdio_register(bus);
-	if (ret)
-		return ret;
-
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	ret = dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args);
 	if (!ret && ofnode_is_enabled(sfp_args.node))
@@ -1774,7 +1635,7 @@ static int mvneta_probe(struct udevice *dev)
 		dm_gpio_set_value(&pp->sfp_tx_disable_gpio, 0);
 #endif
 
-	return board_network_enable(bus);
+	return 0;
 }
 
 static void mvneta_stop(struct udevice *dev)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (7 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:29   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link() Marek Behún
                   ` (11 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

The `ret` variable in mvneta_probe() is unused if DM_GPIO is disabled.

Since the variable is used only once after assigning value, we can
inline the usage and drop the variable.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 19f8145fc0..72789fc5c6 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1570,7 +1570,6 @@ static int mvneta_probe(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	void *bd_space;
 	int fl_node;
-	int ret;
 
 	/*
 	 * Allocate buffer area for descs and rx_buffers. This is only
@@ -1617,8 +1616,8 @@ static int mvneta_probe(struct udevice *dev)
 	}
 
 #if CONFIG_IS_ENABLED(DM_GPIO)
-	ret = dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args);
-	if (!ret && ofnode_is_enabled(sfp_args.node))
+	if (!dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args) &&
+	    ofnode_is_enabled(sfp_args.node))
 		gpio_request_by_name_nodev(sfp_args.node, "tx-disable-gpio", 0,
 					   &pp->sfp_tx_disable_gpio, GPIOD_IS_OUT);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link()
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (8 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:29   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable Marek Behún
                   ` (10 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Drop one indentation level in the mvneta_adjust_link() function.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 72789fc5c6..66d5e10174 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1161,31 +1161,29 @@ static void mvneta_adjust_link(struct udevice *dev)
 		return;
 	}
 
-	if (phydev->link) {
-		if ((pp->speed != phydev->speed) ||
-		    (pp->duplex != phydev->duplex)) {
-			u32 val;
+	if (phydev->link &&
+	    (pp->speed != phydev->speed || pp->duplex != phydev->duplex)) {
+		u32 val;
 
-			val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
-			val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
-				 MVNETA_GMAC_CONFIG_GMII_SPEED |
-				 MVNETA_GMAC_CONFIG_FULL_DUPLEX |
-				 MVNETA_GMAC_AN_SPEED_EN |
-				 MVNETA_GMAC_AN_DUPLEX_EN);
+		val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
+		val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
+			 MVNETA_GMAC_CONFIG_GMII_SPEED |
+			 MVNETA_GMAC_CONFIG_FULL_DUPLEX |
+			 MVNETA_GMAC_AN_SPEED_EN |
+			 MVNETA_GMAC_AN_DUPLEX_EN);
 
-			if (phydev->duplex)
-				val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
+		if (phydev->duplex)
+			val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
 
-			if (phydev->speed == SPEED_1000)
-				val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
-			else if (pp->speed == SPEED_100)
-				val |= MVNETA_GMAC_CONFIG_MII_SPEED;
+		if (phydev->speed == SPEED_1000)
+			val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
+		else if (pp->speed == SPEED_100)
+			val |= MVNETA_GMAC_CONFIG_MII_SPEED;
 
-			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
+		mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
 
-			pp->duplex = phydev->duplex;
-			pp->speed  = phydev->speed;
-		}
+		pp->duplex = phydev->duplex;
+		pp->speed  = phydev->speed;
 	}
 
 	if (phydev->link != pp->link) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (9 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link() Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:29   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space Marek Behún
                   ` (9 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Use the bool type instead of int for status_change variable.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 66d5e10174..7d582c1206 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1154,7 +1154,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 {
 	struct mvneta_port *pp = dev_get_priv(dev);
 	struct phy_device *phydev = pp->phydev;
-	int status_change = 0;
+	bool status_change = false;
 
 	if (pp->fixed_link) {
 		debug("Using fixed link, skip link adjust\n");
@@ -1193,7 +1193,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 		}
 
 		pp->link = phydev->link;
-		status_change = 1;
+		status_change = true;
 	}
 
 	if (status_change) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (10 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:30   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB Marek Behún
                   ` (8 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Drop unnecessary space in mvneta_adjust_link().

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 7d582c1206..5c3f7125b5 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1183,7 +1183,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 		mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
 
 		pp->duplex = phydev->duplex;
-		pp->speed  = phydev->speed;
+		pp->speed = phydev->speed;
 	}
 
 	if (phydev->link != pp->link) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (11 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:30   ` Ramon Fried
  2022-05-02  7:02   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS Marek Behún
                   ` (7 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Drop checking for CONFIG_PHYLIB in mvneta, this is already done in
Kconfig.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 5c3f7125b5..0ec9d2957c 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -40,10 +40,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if !defined(CONFIG_PHYLIB)
-# error Marvell mvneta requires PHYLIB
-#endif
-
 #define CONFIG_NR_CPUS		1
 #define ETH_HLEN		14	/* Total octets in header */
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (12 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:30   ` Ramon Fried
  2022-05-02  7:02   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link Marek Behún
                   ` (6 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

The CONFIG_* macros are reserved for Kconfig. This was probably done
when this driver was being imported from Linux. Rename the macro.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 0ec9d2957c..519e06ff01 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -40,7 +40,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define CONFIG_NR_CPUS		1
+#define MVNETA_NR_CPUS		1
 #define ETH_HLEN		14	/* Total octets in header */
 
 /* 2(HW hdr) 14(MAC hdr) 4(CRC) 32(extra for cache prefetch) */
@@ -770,7 +770,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
 	/* Set CPU queue access map - all CPUs have access to all RX
 	 * queues and to all TX queues
 	 */
-	for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++)
+	for (cpu = 0; cpu < MVNETA_NR_CPUS; cpu++)
 		mvreg_write(pp, MVNETA_CPU_MAP(cpu),
 			    (MVNETA_CPU_RXQ_ACCESS_ALL_MASK |
 			     MVNETA_CPU_TXQ_ACCESS_ALL_MASK));
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (13 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:31   ` Ramon Fried
  2022-05-02  7:02   ` Stefan Roese
  2022-04-27 10:41 ` [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling Marek Behún
                   ` (5 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Stop parsing fixed-link in the MAC driver. Instead support only PHY mode
and let the fixed PHY driver handle the fixed-link case.

Enable CONFIG_PHY_FIXED for mvneta boards that need it: Turris Omnia and
ESPRESSObin.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 configs/mvebu_espressobin-88f3720_defconfig |  1 +
 configs/turris_omnia_defconfig              |  1 +
 drivers/net/mvneta.c                        | 98 ++++++++-------------
 3 files changed, 39 insertions(+), 61 deletions(-)

diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
index 37e4fdc41e..8d7d57ff1b 100644
--- a/configs/mvebu_espressobin-88f3720_defconfig
+++ b/configs/mvebu_espressobin-88f3720_defconfig
@@ -74,6 +74,7 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MARVELL=y
+CONFIG_PHY_FIXED=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MVNETA=y
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 6b218bd7a7..bdd70f2ba7 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -79,6 +79,7 @@ CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MARVELL=y
+CONFIG_PHY_FIXED=y
 CONFIG_PHY_GIGE=y
 CONFIG_MVNETA=y
 CONFIG_MII=y
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 519e06ff01..5b1c4fe5fc 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1152,11 +1152,6 @@ static void mvneta_adjust_link(struct udevice *dev)
 	struct phy_device *phydev = pp->phydev;
 	bool status_change = false;
 
-	if (pp->fixed_link) {
-		debug("Using fixed link, skip link adjust\n");
-		return;
-	}
-
 	if (phydev->link &&
 	    (pp->speed != phydev->speed || pp->duplex != phydev->duplex)) {
 		u32 val;
@@ -1168,6 +1163,21 @@ static void mvneta_adjust_link(struct udevice *dev)
 			 MVNETA_GMAC_AN_SPEED_EN |
 			 MVNETA_GMAC_AN_DUPLEX_EN);
 
+		/* FIXME: For fixed-link case, these were the initial settings
+		 * used before the code was converted to use PHY_FIXED. Some of
+		 * these may look nonsensical (for example BYPASS_AN makes sense
+		 * for 1000base-x and 2500base-x modes, AFAIK), and in fact this
+		 * may be changed in the future (when support for inband AN will
+		 * be added). Also, why is ADVERT_FC enabled if we don't enable
+		 * inband AN at all?
+		 */
+		if (pp->fixed_link)
+			val = MVNETA_GMAC_FORCE_LINK_UP |
+			      MVNETA_GMAC_IB_BYPASS_AN_EN |
+			      MVNETA_GMAC_SET_FC_EN |
+			      MVNETA_GMAC_ADVERT_FC_EN |
+			      MVNETA_GMAC_SAMPLE_TX_CFG_EN;
+
 		if (phydev->duplex)
 			val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
 
@@ -1413,56 +1423,34 @@ static int mvneta_start(struct udevice *dev)
 	mvneta_port_power_up(pp, pp->phy_interface);
 
 	if (!pp->init || pp->link == 0) {
-		if (pp->fixed_link) {
-			u32 val;
-
-			pp->init = 1;
-			pp->link = 1;
-			mvneta_init(dev);
-
-			val = MVNETA_GMAC_FORCE_LINK_UP |
-			      MVNETA_GMAC_IB_BYPASS_AN_EN |
-			      MVNETA_GMAC_SET_FC_EN |
-			      MVNETA_GMAC_ADVERT_FC_EN |
-			      MVNETA_GMAC_SAMPLE_TX_CFG_EN;
-
-			if (pp->duplex)
-				val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
-
-			if (pp->speed == SPEED_1000)
-				val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
-			else if (pp->speed == SPEED_100)
-				val |= MVNETA_GMAC_CONFIG_MII_SPEED;
+		phydev = dm_eth_phy_connect(dev);
+		if (!phydev) {
+			printf("dm_eth_phy_connect failed\n");
+			return -ENODEV;
+		}
 
-			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
-		} else {
-			phydev = dm_eth_phy_connect(dev);
-			if (!phydev) {
-				printf("dm_eth_phy_connect failed\n");
-				return -ENODEV;
-			}
+		pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
 
-			/* Set PHY address in case we will enable HW polling */
+		/* Set PHY address in case we will enable HW polling */
+		if (!pp->fixed_link)
 			mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
 
-			pp->phydev = phydev;
-			phy_config(phydev);
-			phy_startup(phydev);
-			if (!phydev->link) {
-				printf("%s: No link.\n", phydev->dev->name);
-				return -1;
-			}
-
-			/* Full init on first call */
-			mvneta_init(dev);
-			pp->init = 1;
-			return 0;
+		pp->phydev = phydev;
+		phy_config(phydev);
+		phy_startup(phydev);
+		if (!phydev->link) {
+			printf("%s: No link.\n", phydev->dev->name);
+			return -1;
 		}
-	}
 
-	/* Upon all following calls, this is enough */
-	mvneta_port_up(pp);
-	mvneta_port_enable(pp);
+		/* Full init on first call */
+		mvneta_init(dev);
+		pp->init = 1;
+	} else {
+		/* Upon all following calls, this is enough */
+		mvneta_port_up(pp);
+		mvneta_port_enable(pp);
+	}
 
 	return 0;
 }
@@ -1560,10 +1548,7 @@ static int mvneta_probe(struct udevice *dev)
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	struct ofnode_phandle_args sfp_args;
 #endif
-	void *blob = (void *)gd->fdt_blob;
-	int node = dev_of_offset(dev);
 	void *bd_space;
-	int fl_node;
 
 	/*
 	 * Allocate buffer area for descs and rx_buffers. This is only
@@ -1600,15 +1585,6 @@ static int mvneta_probe(struct udevice *dev)
 	else
 		mvneta_conf_mbus_windows(pp);
 
-	/* fetch 'fixed-link' property from 'neta' node */
-	fl_node = fdt_subnode_offset(blob, node, "fixed-link");
-	if (fl_node != -FDT_ERR_NOTFOUND) {
-		/* set phy_addr to invalid value for fixed link */
-		pp->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex");
-		pp->speed = fdtdec_get_int(blob, fl_node, "speed", 0);
-		pp->fixed_link = true;
-	}
-
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	if (!dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args) &&
 	    ofnode_is_enabled(sfp_args.node))
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (14 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link Marek Behún
@ 2022-04-27 10:41 ` Marek Behún
  2022-04-30 23:31   ` Ramon Fried
  2022-05-02  7:03   ` Stefan Roese
  2022-04-27 10:42 ` [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct Marek Behún
                   ` (4 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:41 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Write PHY address just before enabling HW polling of the PHY.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 5b1c4fe5fc..4917857681 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -814,6 +814,8 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
 
 	/* Enable PHY polling in hardware if not in fixed-link mode */
 	if (!pp->fixed_link) {
+		mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
+
 		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
 		val |= MVNETA_PHY_POLLING_ENABLE;
 		mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
@@ -1431,10 +1433,6 @@ static int mvneta_start(struct udevice *dev)
 
 		pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
 
-		/* Set PHY address in case we will enable HW polling */
-		if (!pp->fixed_link)
-			mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
-
 		pp->phydev = phydev;
 		phy_config(phydev);
 		phy_startup(phydev);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (15 preceding siblings ...)
  2022-04-27 10:41 ` [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling Marek Behún
@ 2022-04-27 10:42 ` Marek Behún
  2022-04-30 23:31   ` Ramon Fried
  2022-05-02  7:03   ` Stefan Roese
  2022-04-27 10:42 ` [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in Marek Behún
                   ` (3 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:42 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Since this member is checked only at two places drop it and inline it's
usage.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 4917857681..378789b632 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -273,7 +273,6 @@ struct mvneta_port {
 	u16 rx_ring_size;
 
 	phy_interface_t phy_interface;
-	bool fixed_link;
 	unsigned int link;
 	unsigned int duplex;
 	unsigned int speed;
@@ -813,7 +812,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
 	mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
 
 	/* Enable PHY polling in hardware if not in fixed-link mode */
-	if (!pp->fixed_link) {
+	if (pp->phydev->phy_id != PHY_FIXED_ID) {
 		mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
 
 		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
@@ -1173,7 +1172,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 		 * be added). Also, why is ADVERT_FC enabled if we don't enable
 		 * inband AN at all?
 		 */
-		if (pp->fixed_link)
+		if (pp->phydev->phy_id == PHY_FIXED_ID)
 			val = MVNETA_GMAC_FORCE_LINK_UP |
 			      MVNETA_GMAC_IB_BYPASS_AN_EN |
 			      MVNETA_GMAC_SET_FC_EN |
@@ -1431,8 +1430,6 @@ static int mvneta_start(struct udevice *dev)
 			return -ENODEV;
 		}
 
-		pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
-
 		pp->phydev = phydev;
 		phy_config(phydev);
 		phy_startup(phydev);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (16 preceding siblings ...)
  2022-04-27 10:42 ` [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct Marek Behún
@ 2022-04-27 10:42 ` Marek Behún
  2022-04-30 23:32   ` Ramon Fried
  2022-05-02  7:03   ` Stefan Roese
  2022-04-27 10:42 ` [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro Marek Behún
                   ` (2 subsequent siblings)
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:42 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Guard the code handling the fixed PHY case by
CONFIG_IS_ENABLED(PHY_FIXED).

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 378789b632..292c364e5e 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -812,7 +812,8 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
 	mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
 
 	/* Enable PHY polling in hardware if not in fixed-link mode */
-	if (pp->phydev->phy_id != PHY_FIXED_ID) {
+	if (!CONFIG_IS_ENABLED(PHY_FIXED) ||
+	    pp->phydev->phy_id != PHY_FIXED_ID) {
 		mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
 
 		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
@@ -1172,7 +1173,8 @@ static void mvneta_adjust_link(struct udevice *dev)
 		 * be added). Also, why is ADVERT_FC enabled if we don't enable
 		 * inband AN at all?
 		 */
-		if (pp->phydev->phy_id == PHY_FIXED_ID)
+		if (CONFIG_IS_ENABLED(PHY_FIXED) &&
+		    pp->phydev->phy_id == PHY_FIXED_ID)
 			val = MVNETA_GMAC_FORCE_LINK_UP |
 			      MVNETA_GMAC_IB_BYPASS_AN_EN |
 			      MVNETA_GMAC_SET_FC_EN |
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (17 preceding siblings ...)
  2022-04-27 10:42 ` [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in Marek Behún
@ 2022-04-27 10:42 ` Marek Behún
  2022-04-30 23:32   ` Ramon Fried
  2022-05-02  7:03   ` Stefan Roese
  2022-05-02  5:39 ` [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Stefan Roese
  2022-05-04  9:25 ` Stefan Roese
  20 siblings, 2 replies; 58+ messages in thread
From: Marek Behún @ 2022-04-27 10:42 UTC (permalink / raw)
  To: Stefan Roese
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

From: Marek Behún <marek.behun@nic.cz>

Macro MVNETA_GMAC_FORCE_LINK_UP can be dropped from value assignment in
fixed link case, since it's value is written into the register later in
the function for link-down-to-link-up case. The value is written as
MVNETA_GMAC_FORCE_LINK_DOWN | MVNETA_GMAC_FORCE_LINK_PASS, and so the
macro definition can also be dropped.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 292c364e5e..d2c42c4396 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -188,7 +188,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define MVNETA_GMAC_AUTONEG_CONFIG               0x2c0c
 #define      MVNETA_GMAC_FORCE_LINK_DOWN         BIT(0)
 #define      MVNETA_GMAC_FORCE_LINK_PASS         BIT(1)
-#define      MVNETA_GMAC_FORCE_LINK_UP           (BIT(0) | BIT(1))
 #define      MVNETA_GMAC_IB_BYPASS_AN_EN         BIT(3)
 #define      MVNETA_GMAC_CONFIG_MII_SPEED        BIT(5)
 #define      MVNETA_GMAC_CONFIG_GMII_SPEED       BIT(6)
@@ -1175,8 +1174,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 		 */
 		if (CONFIG_IS_ENABLED(PHY_FIXED) &&
 		    pp->phydev->phy_id == PHY_FIXED_ID)
-			val = MVNETA_GMAC_FORCE_LINK_UP |
-			      MVNETA_GMAC_IB_BYPASS_AN_EN |
+			val = MVNETA_GMAC_IB_BYPASS_AN_EN |
 			      MVNETA_GMAC_SET_FC_EN |
 			      MVNETA_GMAC_ADVERT_FC_EN |
 			      MVNETA_GMAC_SAMPLE_TX_CFG_EN;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata
  2022-04-27 10:41 ` [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata Marek Behún
@ 2022-04-30 23:28   ` Ramon Fried
  2022-05-02  6:48   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:28 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Drop .of_to_plat() from the mvneta driver and parse the two properties
> in .probe().
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 24 ++++--------------------
>  1 file changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 15dc714058..d1c5f7930d 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1692,7 +1692,6 @@ static int mvneta_recv(struct udevice *dev, int flags, uchar **packetp)
>
>  static int mvneta_probe(struct udevice *dev)
>  {
> -       struct eth_pdata *pdata = dev_get_plat(dev);
>         struct mvneta_port *pp = dev_get_priv(dev);
>  #if CONFIG_IS_ENABLED(DM_GPIO)
>         struct ofnode_phandle_args sfp_args;
> @@ -1729,7 +1728,10 @@ static int mvneta_probe(struct udevice *dev)
>                 buffer_loc.rx_buffers = (phys_addr_t)(bd_space + size);
>         }
>
> -       pp->base = (void __iomem *)pdata->iobase;
> +       pp->base = dev_read_addr_ptr(dev);
> +       pp->phy_interface = dev_read_phy_mode(dev);
> +       if (pp->phy_interface == PHY_INTERFACE_MODE_NA)
> +               return -EINVAL;
>
>         /* Configure MBUS address windows */
>         if (device_is_compatible(dev, "marvell,armada-3700-neta"))
> @@ -1737,9 +1739,6 @@ static int mvneta_probe(struct udevice *dev)
>         else
>                 mvneta_conf_mbus_windows(pp);
>
> -       /* PHY interface is already decoded in mvneta_of_to_plat() */
> -       pp->phy_interface = pdata->phy_interface;
> -
>         /* fetch 'fixed-link' property from 'neta' node */
>         fl_node = fdt_subnode_offset(blob, node, "fixed-link");
>         if (fl_node != -FDT_ERR_NOTFOUND) {
> @@ -1808,20 +1807,6 @@ static const struct eth_ops mvneta_ops = {
>         .write_hwaddr   = mvneta_write_hwaddr,
>  };
>
> -static int mvneta_of_to_plat(struct udevice *dev)
> -{
> -       struct eth_pdata *pdata = dev_get_plat(dev);
> -
> -       pdata->iobase = dev_read_addr(dev);
> -
> -       /* Get phy-mode / phy_interface from DT */
> -       pdata->phy_interface = dev_read_phy_mode(dev);
> -       if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
> -               return -EINVAL;
> -
> -       return 0;
> -}
> -
>  static const struct udevice_id mvneta_ids[] = {
>         { .compatible = "marvell,armada-370-neta" },
>         { .compatible = "marvell,armada-xp-neta" },
> @@ -1833,7 +1818,6 @@ U_BOOT_DRIVER(mvneta) = {
>         .name   = "mvneta",
>         .id     = UCLASS_ETH,
>         .of_match = mvneta_ids,
> -       .of_to_plat = mvneta_of_to_plat,
>         .probe  = mvneta_probe,
>         .ops    = &mvneta_ops,
>         .priv_auto      = sizeof(struct mvneta_port),
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper
  2022-04-27 10:41 ` [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper Marek Behún
@ 2022-04-30 23:28   ` Ramon Fried
  2022-05-02  7:00   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:28 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún, Heinrich Schuchardt,
	Vladimir Oltean, Simon Glass

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Add helper to resolve PHY node from it's ofnode via DM MDIO subsystem.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  include/miiphy.h  |  9 +++++++++
>  net/mdio-uclass.c | 22 ++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/include/miiphy.h b/include/miiphy.h
> index 110921f20d..c66a1845b5 100644
> --- a/include/miiphy.h
> +++ b/include/miiphy.h
> @@ -188,6 +188,15 @@ int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, u16 va
>   */
>  int dm_mdio_reset(struct udevice *mdio_dev);
>
> +/**
> + * dm_phy_find_by_ofnode - Find PHY device by ofnode
> + *
> + * @phynode: PHY's ofnode
> + *
> + * Return: pointer to phy_device, or NULL on error
> + */
> +struct phy_device *dm_phy_find_by_ofnode(ofnode phynode);
> +
>  /**
>   * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO
>   *
> diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
> index 7593618d9a..4401492ca0 100644
> --- a/net/mdio-uclass.c
> +++ b/net/mdio-uclass.c
> @@ -129,6 +129,28 @@ static int dm_mdio_pre_remove(struct udevice *dev)
>         return 0;
>  }
>
> +struct phy_device *dm_phy_find_by_ofnode(ofnode phynode)
> +{
> +       struct mdio_perdev_priv *pdata;
> +       struct udevice *mdiodev;
> +       u32 phy_addr;
> +
> +       if (ofnode_read_u32(phynode, "reg", &phy_addr))
> +               return NULL;
> +
> +       if (uclass_get_device_by_ofnode(UCLASS_MDIO,
> +                                       ofnode_get_parent(phynode),
> +                                       &mdiodev))
> +               return NULL;
> +
> +       if (device_probe(mdiodev))
> +               return NULL;
> +
> +       pdata = dev_get_uclass_priv(mdiodev);
> +
> +       return phy_find_by_mask(pdata->mii_bus, BIT(phy_addr));
> +}
> +
>  struct phy_device *dm_mdio_phy_connect(struct udevice *mdiodev, int phyaddr,
>                                        struct udevice *ethdev,
>                                        phy_interface_t interface)
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed
  2022-04-27 10:41 ` [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed Marek Behún
@ 2022-04-30 23:28   ` Ramon Fried
  2022-05-02  6:48   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:28 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> In mvneta_adjust_link() we need to set MII_SPEED bit only if PHY reports
> the speed at 100Mbps.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index d1c5f7930d..79cdb93341 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1195,7 +1195,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>
>                         if (phydev->speed == SPEED_1000)
>                                 val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
> -                       else
> +                       else if (pp->speed == SPEED_100)
>                                 val |= MVNETA_GMAC_CONFIG_MII_SPEED;
>
>                         mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY
  2022-04-27 10:41 ` [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY Marek Behún
@ 2022-04-30 23:28   ` Ramon Fried
  2022-05-02  6:48   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:28 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún, Mario Six, Chris Packham,
	Phil Sutter, Konstantin Porotchkin, Vladimir Vid

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Use the modern DM MDIO API for connecting PHY in the mvneta driver.
>
> This requires enabling MVMDIO driver in several config files.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  configs/clearfog_defconfig                  |  1 +
>  configs/controlcenterdc_defconfig           |  1 +
>  configs/db-88f6820-amc_defconfig            |  1 +
>  configs/db-88f6820-gp_defconfig             |  1 +
>  configs/db-mv784mp-gp_defconfig             |  1 +
>  configs/ds414_defconfig                     |  1 +
>  configs/helios4_defconfig                   |  1 +
>  configs/maxbcm_defconfig                    |  1 +
>  configs/mvebu_espressobin-88f3720_defconfig |  1 +
>  configs/theadorable_debug_defconfig         |  1 +
>  configs/turris_mox_defconfig                |  1 +
>  configs/turris_omnia_defconfig              |  1 +
>  configs/uDPU_defconfig                      |  1 +
>  drivers/net/Kconfig                         |  1 +
>  drivers/net/mvneta.c                        | 11 +++++------
>  15 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig
> index 880f16a6e0..b8f59d2962 100644
> --- a/configs/clearfog_defconfig
> +++ b/configs/clearfog_defconfig
> @@ -63,6 +63,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_PCI_MVEBU=y
>  CONFIG_SCSI=y
> diff --git a/configs/controlcenterdc_defconfig b/configs/controlcenterdc_defconfig
> index d4b966b93f..df38b2c54f 100644
> --- a/configs/controlcenterdc_defconfig
> +++ b/configs/controlcenterdc_defconfig
> @@ -77,6 +77,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_DM_PCI_COMPAT=y
>  CONFIG_PCI_MVEBU=y
> diff --git a/configs/db-88f6820-amc_defconfig b/configs/db-88f6820-amc_defconfig
> index 46c822fccd..9b77b4a5f0 100644
> --- a/configs/db-88f6820-amc_defconfig
> +++ b/configs/db-88f6820-amc_defconfig
> @@ -67,6 +67,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_PCI_MVEBU=y
>  CONFIG_DEBUG_UART_SHIFT=2
> diff --git a/configs/db-88f6820-gp_defconfig b/configs/db-88f6820-gp_defconfig
> index 2dcbc2f29a..f56d1fbf25 100644
> --- a/configs/db-88f6820-gp_defconfig
> +++ b/configs/db-88f6820-gp_defconfig
> @@ -62,6 +62,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_PCI_MVEBU=y
>  CONFIG_SCSI=y
> diff --git a/configs/db-mv784mp-gp_defconfig b/configs/db-mv784mp-gp_defconfig
> index f19cc54975..5683f11836 100644
> --- a/configs/db-mv784mp-gp_defconfig
> +++ b/configs/db-mv784mp-gp_defconfig
> @@ -65,6 +65,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_PCI_MVEBU=y
>  CONFIG_DEBUG_UART_SHIFT=2
> diff --git a/configs/ds414_defconfig b/configs/ds414_defconfig
> index a3279c15c5..a83fe079b3 100644
> --- a/configs/ds414_defconfig
> +++ b/configs/ds414_defconfig
> @@ -65,6 +65,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_PCI_MVEBU=y
>  CONFIG_DEBUG_UART_SHIFT=2
> diff --git a/configs/helios4_defconfig b/configs/helios4_defconfig
> index 7d812e8fab..c2130bacb4 100644
> --- a/configs/helios4_defconfig
> +++ b/configs/helios4_defconfig
> @@ -63,6 +63,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_PCI_MVEBU=y
>  CONFIG_SCSI=y
> diff --git a/configs/maxbcm_defconfig b/configs/maxbcm_defconfig
> index 8dd6adf247..40f79d47ea 100644
> --- a/configs/maxbcm_defconfig
> +++ b/configs/maxbcm_defconfig
> @@ -47,6 +47,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_DEBUG_UART_SHIFT=2
>  CONFIG_SYS_NS16550=y
>  CONFIG_KIRKWOOD_SPI=y
> diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
> index ff05630d20..af30f1b363 100644
> --- a/configs/mvebu_espressobin-88f3720_defconfig
> +++ b/configs/mvebu_espressobin-88f3720_defconfig
> @@ -76,6 +76,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_E1000=y
>  CONFIG_MVNETA=y
> +CONFIG_MVMDIO=y
>  CONFIG_NVME_PCI=y
>  CONFIG_PCI=y
>  CONFIG_PCI_AARDVARK=y
> diff --git a/configs/theadorable_debug_defconfig b/configs/theadorable_debug_defconfig
> index 86129e7d2d..9a03a0a7a3 100644
> --- a/configs/theadorable_debug_defconfig
> +++ b/configs/theadorable_debug_defconfig
> @@ -70,6 +70,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_DM_PCI_COMPAT=y
>  CONFIG_PCI_MVEBU=y
> diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
> index 9a76a118c2..bcd3699a4f 100644
> --- a/configs/turris_mox_defconfig
> +++ b/configs/turris_mox_defconfig
> @@ -82,6 +82,7 @@ CONFIG_SPI_FLASH_MTD=y
>  CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
> +CONFIG_MVMDIO=y
>  CONFIG_NVME_PCI=y
>  CONFIG_PCI=y
>  CONFIG_PCI_AARDVARK=y
> diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
> index ad56d3824b..6b218bd7a7 100644
> --- a/configs/turris_omnia_defconfig
> +++ b/configs/turris_omnia_defconfig
> @@ -82,6 +82,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> +CONFIG_MVMDIO=y
>  CONFIG_NVME_PCI=y
>  CONFIG_PCI=y
>  CONFIG_PCI_MVEBU=y
> diff --git a/configs/uDPU_defconfig b/configs/uDPU_defconfig
> index c07bad5076..f2852ad29b 100644
> --- a/configs/uDPU_defconfig
> +++ b/configs/uDPU_defconfig
> @@ -73,6 +73,7 @@ CONFIG_PHY_MARVELL=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_E1000=y
>  CONFIG_MVNETA=y
> +CONFIG_MVMDIO=y
>  CONFIG_PCI=y
>  CONFIG_PCI_AARDVARK=y
>  CONFIG_PHY=y
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index 347fe8aa42..47f7a262f2 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -445,6 +445,7 @@ config MVNETA
>         bool "Marvell Armada XP/385/3700 network interface support"
>         depends on ARMADA_XP || ARMADA_38X || ARMADA_3700
>         select PHYLIB
> +       select DM_MDIO
>         help
>           This driver supports the network interface units in the
>           Marvell ARMADA XP, ARMADA 38X and ARMADA 3700 SoCs
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 79cdb93341..24a491dcde 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1571,16 +1571,15 @@ static int mvneta_start(struct udevice *dev)
>
>                         mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
>                 } else {
> -                       /* Set phy address of the port */
> -                       mvreg_write(pp, MVNETA_PHY_ADDR, pp->phyaddr);
> -
> -                       phydev = phy_connect(pp->bus, pp->phyaddr, dev,
> -                                            pp->phy_interface);
> +                       phydev = dm_eth_phy_connect(dev);
>                         if (!phydev) {
> -                               printf("phy_connect failed\n");
> +                               printf("dm_eth_phy_connect failed\n");
>                                 return -ENODEV;
>                         }
>
> +                       /* Set PHY address in case we will enable HW polling */
> +                       mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
> +
>                         pp->phydev = phydev;
>                         phy_config(phydev);
>                         phy_startup(phydev);
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data
  2022-04-27 10:41 ` [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data Marek Behún
@ 2022-04-30 23:28   ` Ramon Fried
  2022-05-02  6:48   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:28 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> We don't need to remember PHY address anymore, because since using DM
> MDIO for connecting PHY, the address is parsed by mdio-uclass from
> the ofnode.
>
> But the driver uses a special value of the address to signal fixed link
> usage.
>
> Drop phyaddr add fixed_link in driver private structure. This simplifies
> code a little.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 23 +++++------------------
>  1 file changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 24a491dcde..83e9629138 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -277,12 +277,12 @@ struct mvneta_port {
>         u16 rx_ring_size;
>
>         phy_interface_t phy_interface;
> +       bool fixed_link;
>         unsigned int link;
>         unsigned int duplex;
>         unsigned int speed;
>
>         int init;
> -       int phyaddr;
>         struct phy_device *phydev;
>  #if CONFIG_IS_ENABLED(DM_GPIO)
>         struct gpio_desc phy_reset_gpio;
> @@ -576,13 +576,6 @@ static void mvneta_rxq_buf_size_set(struct mvneta_port *pp,
>         mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), val);
>  }
>
> -static int mvneta_port_is_fixed_link(struct mvneta_port *pp)
> -{
> -       /* phy_addr is set to invalid value for fixed link */
> -       return pp->phyaddr > PHY_MAX_ADDR;
> -}
> -
> -
>  /* Start the Ethernet port RX and TX activity */
>  static void mvneta_port_up(struct mvneta_port *pp)
>  {
> @@ -834,7 +827,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>         mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
>
>         /* Enable PHY polling in hardware if not in fixed-link mode */
> -       if (!mvneta_port_is_fixed_link(pp)) {
> +       if (!pp->fixed_link) {
>                 val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
>                 val |= MVNETA_PHY_POLLING_ENABLE;
>                 mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
> @@ -1173,7 +1166,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>         struct phy_device *phydev = pp->phydev;
>         int status_change = 0;
>
> -       if (mvneta_port_is_fixed_link(pp)) {
> +       if (pp->fixed_link) {
>                 debug("Using fixed link, skip link adjust\n");
>                 return;
>         }
> @@ -1548,7 +1541,7 @@ static int mvneta_start(struct udevice *dev)
>         mvneta_port_power_up(pp, pp->phy_interface);
>
>         if (!pp->init || pp->link == 0) {
> -               if (mvneta_port_is_fixed_link(pp)) {
> +               if (pp->fixed_link) {
>                         u32 val;
>
>                         pp->init = 1;
> @@ -1698,7 +1691,6 @@ static int mvneta_probe(struct udevice *dev)
>         void *blob = (void *)gd->fdt_blob;
>         int node = dev_of_offset(dev);
>         struct mii_dev *bus;
> -       unsigned long addr;
>         void *bd_space;
>         int ret;
>         int fl_node;
> @@ -1742,14 +1734,9 @@ static int mvneta_probe(struct udevice *dev)
>         fl_node = fdt_subnode_offset(blob, node, "fixed-link");
>         if (fl_node != -FDT_ERR_NOTFOUND) {
>                 /* set phy_addr to invalid value for fixed link */
> -               pp->phyaddr = PHY_MAX_ADDR + 1;
>                 pp->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex");
>                 pp->speed = fdtdec_get_int(blob, fl_node, "speed", 0);
> -       } else {
> -               /* Now read phyaddr from DT */
> -               addr = fdtdec_get_int(blob, node, "phy", 0);
> -               addr = fdt_node_offset_by_phandle(blob, addr);
> -               pp->phyaddr = fdtdec_get_int(blob, addr, "reg", 0);
> +               pp->fixed_link = true;
>         }
>
>         bus = mdio_alloc();
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus
  2022-04-27 10:41 ` [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus Marek Behún
@ 2022-04-30 23:29   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:29 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> This MDIO bus is now handled by a proper mvmdio DM driver. Remove it
> from mvneta.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 143 +------------------------------------------
>  1 file changed, 2 insertions(+), 141 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 83e9629138..19f8145fc0 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -288,7 +288,6 @@ struct mvneta_port {
>         struct gpio_desc phy_reset_gpio;
>         struct gpio_desc sfp_tx_disable_gpio;
>  #endif
> -       struct mii_dev *bus;
>  };
>
>  /* The mvneta_tx_desc and mvneta_rx_desc structures describe the
> @@ -414,15 +413,6 @@ static struct buffer_location buffer_loc;
>   */
>  #define BD_SPACE       (1 << 20)
>
> -/*
> - * Dummy implementation that can be overwritten by a board
> - * specific function
> - */
> -__weak int board_network_enable(struct mii_dev *bus)
> -{
> -       return 0;
> -}
> -
>  /* Utility/helper methods */
>
>  /* Write helper method */
> @@ -1421,118 +1411,6 @@ static int mvneta_init(struct udevice *dev)
>
>  /* U-Boot only functions follow here */
>
> -/* SMI / MDIO functions */
> -
> -static int smi_wait_ready(struct mvneta_port *pp)
> -{
> -       u32 timeout = MVNETA_SMI_TIMEOUT;
> -       u32 smi_reg;
> -
> -       /* wait till the SMI is not busy */
> -       do {
> -               /* read smi register */
> -               smi_reg = mvreg_read(pp, MVNETA_SMI);
> -               if (timeout-- == 0) {
> -                       printf("Error: SMI busy timeout\n");
> -                       return -EFAULT;
> -               }
> -       } while (smi_reg & MVNETA_SMI_BUSY);
> -
> -       return 0;
> -}
> -
> -/*
> - * mvneta_mdio_read - miiphy_read callback function.
> - *
> - * Returns 16bit phy register value, or 0xffff on error
> - */
> -static int mvneta_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
> -{
> -       struct mvneta_port *pp = bus->priv;
> -       u32 smi_reg;
> -       u32 timeout;
> -
> -       /* check parameters */
> -       if (addr > MVNETA_PHY_ADDR_MASK) {
> -               printf("Error: Invalid PHY address %d\n", addr);
> -               return -EFAULT;
> -       }
> -
> -       if (reg > MVNETA_PHY_REG_MASK) {
> -               printf("Err: Invalid register offset %d\n", reg);
> -               return -EFAULT;
> -       }
> -
> -       /* wait till the SMI is not busy */
> -       if (smi_wait_ready(pp) < 0)
> -               return -EFAULT;
> -
> -       /* fill the phy address and regiser offset and read opcode */
> -       smi_reg = (addr << MVNETA_SMI_DEV_ADDR_OFFS)
> -               | (reg << MVNETA_SMI_REG_ADDR_OFFS)
> -               | MVNETA_SMI_OPCODE_READ;
> -
> -       /* write the smi register */
> -       mvreg_write(pp, MVNETA_SMI, smi_reg);
> -
> -       /* wait till read value is ready */
> -       timeout = MVNETA_SMI_TIMEOUT;
> -
> -       do {
> -               /* read smi register */
> -               smi_reg = mvreg_read(pp, MVNETA_SMI);
> -               if (timeout-- == 0) {
> -                       printf("Err: SMI read ready timeout\n");
> -                       return -EFAULT;
> -               }
> -       } while (!(smi_reg & MVNETA_SMI_READ_VALID));
> -
> -       /* Wait for the data to update in the SMI register */
> -       for (timeout = 0; timeout < MVNETA_SMI_TIMEOUT; timeout++)
> -               ;
> -
> -       return mvreg_read(pp, MVNETA_SMI) & MVNETA_SMI_DATA_MASK;
> -}
> -
> -/*
> - * mvneta_mdio_write - miiphy_write callback function.
> - *
> - * Returns 0 if write succeed, -EINVAL on bad parameters
> - * -ETIME on timeout
> - */
> -static int mvneta_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
> -                            u16 value)
> -{
> -       struct mvneta_port *pp = bus->priv;
> -       u32 smi_reg;
> -
> -       /* check parameters */
> -       if (addr > MVNETA_PHY_ADDR_MASK) {
> -               printf("Error: Invalid PHY address %d\n", addr);
> -               return -EFAULT;
> -       }
> -
> -       if (reg > MVNETA_PHY_REG_MASK) {
> -               printf("Err: Invalid register offset %d\n", reg);
> -               return -EFAULT;
> -       }
> -
> -       /* wait till the SMI is not busy */
> -       if (smi_wait_ready(pp) < 0)
> -               return -EFAULT;
> -
> -       /* fill the phy addr and reg offset and write opcode and data */
> -       smi_reg = value << MVNETA_SMI_DATA_OFFS;
> -       smi_reg |= (addr << MVNETA_SMI_DEV_ADDR_OFFS)
> -               | (reg << MVNETA_SMI_REG_ADDR_OFFS);
> -       smi_reg &= ~MVNETA_SMI_OPCODE_READ;
> -
> -       /* write the smi register */
> -       mvreg_write(pp, MVNETA_SMI, smi_reg);
> -
> -       return 0;
> -}
> -
>  static int mvneta_start(struct udevice *dev)
>  {
>         struct mvneta_port *pp = dev_get_priv(dev);
> @@ -1690,10 +1568,9 @@ static int mvneta_probe(struct udevice *dev)
>  #endif
>         void *blob = (void *)gd->fdt_blob;
>         int node = dev_of_offset(dev);
> -       struct mii_dev *bus;
>         void *bd_space;
> -       int ret;
>         int fl_node;
> +       int ret;
>
>         /*
>          * Allocate buffer area for descs and rx_buffers. This is only
> @@ -1739,22 +1616,6 @@ static int mvneta_probe(struct udevice *dev)
>                 pp->fixed_link = true;
>         }
>
> -       bus = mdio_alloc();
> -       if (!bus) {
> -               printf("Failed to allocate MDIO bus\n");
> -               return -ENOMEM;
> -       }
> -
> -       bus->read = mvneta_mdio_read;
> -       bus->write = mvneta_mdio_write;
> -       snprintf(bus->name, sizeof(bus->name), dev->name);
> -       bus->priv = (void *)pp;
> -       pp->bus = bus;
> -
> -       ret = mdio_register(bus);
> -       if (ret)
> -               return ret;
> -
>  #if CONFIG_IS_ENABLED(DM_GPIO)
>         ret = dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args);
>         if (!ret && ofnode_is_enabled(sfp_args.node))
> @@ -1774,7 +1635,7 @@ static int mvneta_probe(struct udevice *dev)
>                 dm_gpio_set_value(&pp->sfp_tx_disable_gpio, 0);
>  #endif
>
> -       return board_network_enable(bus);
> +       return 0;
>  }
>
>  static void mvneta_stop(struct udevice *dev)
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled
  2022-04-27 10:41 ` [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled Marek Behún
@ 2022-04-30 23:29   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:29 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> The `ret` variable in mvneta_probe() is unused if DM_GPIO is disabled.
>
> Since the variable is used only once after assigning value, we can
> inline the usage and drop the variable.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 19f8145fc0..72789fc5c6 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1570,7 +1570,6 @@ static int mvneta_probe(struct udevice *dev)
>         int node = dev_of_offset(dev);
>         void *bd_space;
>         int fl_node;
> -       int ret;
>
>         /*
>          * Allocate buffer area for descs and rx_buffers. This is only
> @@ -1617,8 +1616,8 @@ static int mvneta_probe(struct udevice *dev)
>         }
>
>  #if CONFIG_IS_ENABLED(DM_GPIO)
> -       ret = dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args);
> -       if (!ret && ofnode_is_enabled(sfp_args.node))
> +       if (!dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args) &&
> +           ofnode_is_enabled(sfp_args.node))
>                 gpio_request_by_name_nodev(sfp_args.node, "tx-disable-gpio", 0,
>                                            &pp->sfp_tx_disable_gpio, GPIOD_IS_OUT);
>
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link()
  2022-04-27 10:41 ` [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link() Marek Behún
@ 2022-04-30 23:29   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:29 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Drop one indentation level in the mvneta_adjust_link() function.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 38 ++++++++++++++++++--------------------
>  1 file changed, 18 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 72789fc5c6..66d5e10174 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1161,31 +1161,29 @@ static void mvneta_adjust_link(struct udevice *dev)
>                 return;
>         }
>
> -       if (phydev->link) {
> -               if ((pp->speed != phydev->speed) ||
> -                   (pp->duplex != phydev->duplex)) {
> -                       u32 val;
> +       if (phydev->link &&
> +           (pp->speed != phydev->speed || pp->duplex != phydev->duplex)) {
> +               u32 val;
>
> -                       val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
> -                       val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
> -                                MVNETA_GMAC_CONFIG_GMII_SPEED |
> -                                MVNETA_GMAC_CONFIG_FULL_DUPLEX |
> -                                MVNETA_GMAC_AN_SPEED_EN |
> -                                MVNETA_GMAC_AN_DUPLEX_EN);
> +               val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
> +               val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
> +                        MVNETA_GMAC_CONFIG_GMII_SPEED |
> +                        MVNETA_GMAC_CONFIG_FULL_DUPLEX |
> +                        MVNETA_GMAC_AN_SPEED_EN |
> +                        MVNETA_GMAC_AN_DUPLEX_EN);
>
> -                       if (phydev->duplex)
> -                               val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
> +               if (phydev->duplex)
> +                       val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
>
> -                       if (phydev->speed == SPEED_1000)
> -                               val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
> -                       else if (pp->speed == SPEED_100)
> -                               val |= MVNETA_GMAC_CONFIG_MII_SPEED;
> +               if (phydev->speed == SPEED_1000)
> +                       val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
> +               else if (pp->speed == SPEED_100)
> +                       val |= MVNETA_GMAC_CONFIG_MII_SPEED;
>
> -                       mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
> +               mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
>
> -                       pp->duplex = phydev->duplex;
> -                       pp->speed  = phydev->speed;
> -               }
> +               pp->duplex = phydev->duplex;
> +               pp->speed  = phydev->speed;
>         }
>
>         if (phydev->link != pp->link) {
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable
  2022-04-27 10:41 ` [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable Marek Behún
@ 2022-04-30 23:29   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:29 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Use the bool type instead of int for status_change variable.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 66d5e10174..7d582c1206 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1154,7 +1154,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>  {
>         struct mvneta_port *pp = dev_get_priv(dev);
>         struct phy_device *phydev = pp->phydev;
> -       int status_change = 0;
> +       bool status_change = false;
>
>         if (pp->fixed_link) {
>                 debug("Using fixed link, skip link adjust\n");
> @@ -1193,7 +1193,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>                 }
>
>                 pp->link = phydev->link;
> -               status_change = 1;
> +               status_change = true;
>         }
>
>         if (status_change) {
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space
  2022-04-27 10:41 ` [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space Marek Behún
@ 2022-04-30 23:30   ` Ramon Fried
  2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:30 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Drop unnecessary space in mvneta_adjust_link().
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 7d582c1206..5c3f7125b5 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1183,7 +1183,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>                 mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
>
>                 pp->duplex = phydev->duplex;
> -               pp->speed  = phydev->speed;
> +               pp->speed = phydev->speed;
>         }
>
>         if (phydev->link != pp->link) {
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB
  2022-04-27 10:41 ` [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB Marek Behún
@ 2022-04-30 23:30   ` Ramon Fried
  2022-05-02  7:02   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:30 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Drop checking for CONFIG_PHYLIB in mvneta, this is already done in
> Kconfig.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 5c3f7125b5..0ec9d2957c 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -40,10 +40,6 @@
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> -#if !defined(CONFIG_PHYLIB)
> -# error Marvell mvneta requires PHYLIB
> -#endif
> -
>  #define CONFIG_NR_CPUS         1
>  #define ETH_HLEN               14      /* Total octets in header */
>
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS
  2022-04-27 10:41 ` [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS Marek Behún
@ 2022-04-30 23:30   ` Ramon Fried
  2022-05-02  7:02   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:30 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> The CONFIG_* macros are reserved for Kconfig. This was probably done
> when this driver was being imported from Linux. Rename the macro.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 0ec9d2957c..519e06ff01 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -40,7 +40,7 @@
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> -#define CONFIG_NR_CPUS         1
> +#define MVNETA_NR_CPUS         1
>  #define ETH_HLEN               14      /* Total octets in header */
>
>  /* 2(HW hdr) 14(MAC hdr) 4(CRC) 32(extra for cache prefetch) */
> @@ -770,7 +770,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>         /* Set CPU queue access map - all CPUs have access to all RX
>          * queues and to all TX queues
>          */
> -       for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++)
> +       for (cpu = 0; cpu < MVNETA_NR_CPUS; cpu++)
>                 mvreg_write(pp, MVNETA_CPU_MAP(cpu),
>                             (MVNETA_CPU_RXQ_ACCESS_ALL_MASK |
>                              MVNETA_CPU_TXQ_ACCESS_ALL_MASK));
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link
  2022-04-27 10:41 ` [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link Marek Behún
@ 2022-04-30 23:31   ` Ramon Fried
  2022-05-02  7:02   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:31 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Stop parsing fixed-link in the MAC driver. Instead support only PHY mode
> and let the fixed PHY driver handle the fixed-link case.
>
> Enable CONFIG_PHY_FIXED for mvneta boards that need it: Turris Omnia and
> ESPRESSObin.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  configs/mvebu_espressobin-88f3720_defconfig |  1 +
>  configs/turris_omnia_defconfig              |  1 +
>  drivers/net/mvneta.c                        | 98 ++++++++-------------
>  3 files changed, 39 insertions(+), 61 deletions(-)
>
> diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
> index 37e4fdc41e..8d7d57ff1b 100644
> --- a/configs/mvebu_espressobin-88f3720_defconfig
> +++ b/configs/mvebu_espressobin-88f3720_defconfig
> @@ -74,6 +74,7 @@ CONFIG_SPI_FLASH_STMICRO=y
>  CONFIG_SPI_FLASH_WINBOND=y
>  CONFIG_SPI_FLASH_MTD=y
>  CONFIG_PHY_MARVELL=y
> +CONFIG_PHY_FIXED=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_E1000=y
>  CONFIG_MVNETA=y
> diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
> index 6b218bd7a7..bdd70f2ba7 100644
> --- a/configs/turris_omnia_defconfig
> +++ b/configs/turris_omnia_defconfig
> @@ -79,6 +79,7 @@ CONFIG_SPI_FLASH_MACRONIX=y
>  CONFIG_SPI_FLASH_SPANSION=y
>  CONFIG_SPI_FLASH_MTD=y
>  CONFIG_PHY_MARVELL=y
> +CONFIG_PHY_FIXED=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_MVNETA=y
>  CONFIG_MII=y
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 519e06ff01..5b1c4fe5fc 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1152,11 +1152,6 @@ static void mvneta_adjust_link(struct udevice *dev)
>         struct phy_device *phydev = pp->phydev;
>         bool status_change = false;
>
> -       if (pp->fixed_link) {
> -               debug("Using fixed link, skip link adjust\n");
> -               return;
> -       }
> -
>         if (phydev->link &&
>             (pp->speed != phydev->speed || pp->duplex != phydev->duplex)) {
>                 u32 val;
> @@ -1168,6 +1163,21 @@ static void mvneta_adjust_link(struct udevice *dev)
>                          MVNETA_GMAC_AN_SPEED_EN |
>                          MVNETA_GMAC_AN_DUPLEX_EN);
>
> +               /* FIXME: For fixed-link case, these were the initial settings
> +                * used before the code was converted to use PHY_FIXED. Some of
> +                * these may look nonsensical (for example BYPASS_AN makes sense
> +                * for 1000base-x and 2500base-x modes, AFAIK), and in fact this
> +                * may be changed in the future (when support for inband AN will
> +                * be added). Also, why is ADVERT_FC enabled if we don't enable
> +                * inband AN at all?
> +                */
> +               if (pp->fixed_link)
> +                       val = MVNETA_GMAC_FORCE_LINK_UP |
> +                             MVNETA_GMAC_IB_BYPASS_AN_EN |
> +                             MVNETA_GMAC_SET_FC_EN |
> +                             MVNETA_GMAC_ADVERT_FC_EN |
> +                             MVNETA_GMAC_SAMPLE_TX_CFG_EN;
> +
>                 if (phydev->duplex)
>                         val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
>
> @@ -1413,56 +1423,34 @@ static int mvneta_start(struct udevice *dev)
>         mvneta_port_power_up(pp, pp->phy_interface);
>
>         if (!pp->init || pp->link == 0) {
> -               if (pp->fixed_link) {
> -                       u32 val;
> -
> -                       pp->init = 1;
> -                       pp->link = 1;
> -                       mvneta_init(dev);
> -
> -                       val = MVNETA_GMAC_FORCE_LINK_UP |
> -                             MVNETA_GMAC_IB_BYPASS_AN_EN |
> -                             MVNETA_GMAC_SET_FC_EN |
> -                             MVNETA_GMAC_ADVERT_FC_EN |
> -                             MVNETA_GMAC_SAMPLE_TX_CFG_EN;
> -
> -                       if (pp->duplex)
> -                               val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
> -
> -                       if (pp->speed == SPEED_1000)
> -                               val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
> -                       else if (pp->speed == SPEED_100)
> -                               val |= MVNETA_GMAC_CONFIG_MII_SPEED;
> +               phydev = dm_eth_phy_connect(dev);
> +               if (!phydev) {
> +                       printf("dm_eth_phy_connect failed\n");
> +                       return -ENODEV;
> +               }
>
> -                       mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
> -               } else {
> -                       phydev = dm_eth_phy_connect(dev);
> -                       if (!phydev) {
> -                               printf("dm_eth_phy_connect failed\n");
> -                               return -ENODEV;
> -                       }
> +               pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
>
> -                       /* Set PHY address in case we will enable HW polling */
> +               /* Set PHY address in case we will enable HW polling */
> +               if (!pp->fixed_link)
>                         mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
>
> -                       pp->phydev = phydev;
> -                       phy_config(phydev);
> -                       phy_startup(phydev);
> -                       if (!phydev->link) {
> -                               printf("%s: No link.\n", phydev->dev->name);
> -                               return -1;
> -                       }
> -
> -                       /* Full init on first call */
> -                       mvneta_init(dev);
> -                       pp->init = 1;
> -                       return 0;
> +               pp->phydev = phydev;
> +               phy_config(phydev);
> +               phy_startup(phydev);
> +               if (!phydev->link) {
> +                       printf("%s: No link.\n", phydev->dev->name);
> +                       return -1;
>                 }
> -       }
>
> -       /* Upon all following calls, this is enough */
> -       mvneta_port_up(pp);
> -       mvneta_port_enable(pp);
> +               /* Full init on first call */
> +               mvneta_init(dev);
> +               pp->init = 1;
> +       } else {
> +               /* Upon all following calls, this is enough */
> +               mvneta_port_up(pp);
> +               mvneta_port_enable(pp);
> +       }
>
>         return 0;
>  }
> @@ -1560,10 +1548,7 @@ static int mvneta_probe(struct udevice *dev)
>  #if CONFIG_IS_ENABLED(DM_GPIO)
>         struct ofnode_phandle_args sfp_args;
>  #endif
> -       void *blob = (void *)gd->fdt_blob;
> -       int node = dev_of_offset(dev);
>         void *bd_space;
> -       int fl_node;
>
>         /*
>          * Allocate buffer area for descs and rx_buffers. This is only
> @@ -1600,15 +1585,6 @@ static int mvneta_probe(struct udevice *dev)
>         else
>                 mvneta_conf_mbus_windows(pp);
>
> -       /* fetch 'fixed-link' property from 'neta' node */
> -       fl_node = fdt_subnode_offset(blob, node, "fixed-link");
> -       if (fl_node != -FDT_ERR_NOTFOUND) {
> -               /* set phy_addr to invalid value for fixed link */
> -               pp->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex");
> -               pp->speed = fdtdec_get_int(blob, fl_node, "speed", 0);
> -               pp->fixed_link = true;
> -       }
> -
>  #if CONFIG_IS_ENABLED(DM_GPIO)
>         if (!dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args) &&
>             ofnode_is_enabled(sfp_args.node))
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling
  2022-04-27 10:41 ` [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling Marek Behún
@ 2022-04-30 23:31   ` Ramon Fried
  2022-05-02  7:03   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:31 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Write PHY address just before enabling HW polling of the PHY.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 5b1c4fe5fc..4917857681 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -814,6 +814,8 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>
>         /* Enable PHY polling in hardware if not in fixed-link mode */
>         if (!pp->fixed_link) {
> +               mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
> +
>                 val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
>                 val |= MVNETA_PHY_POLLING_ENABLE;
>                 mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
> @@ -1431,10 +1433,6 @@ static int mvneta_start(struct udevice *dev)
>
>                 pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
>
> -               /* Set PHY address in case we will enable HW polling */
> -               if (!pp->fixed_link)
> -                       mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
> -
>                 pp->phydev = phydev;
>                 phy_config(phydev);
>                 phy_startup(phydev);
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct
  2022-04-27 10:42 ` [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct Marek Behún
@ 2022-04-30 23:31   ` Ramon Fried
  2022-05-02  7:03   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:31 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Since this member is checked only at two places drop it and inline it's
> usage.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 4917857681..378789b632 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -273,7 +273,6 @@ struct mvneta_port {
>         u16 rx_ring_size;
>
>         phy_interface_t phy_interface;
> -       bool fixed_link;
>         unsigned int link;
>         unsigned int duplex;
>         unsigned int speed;
> @@ -813,7 +812,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>         mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
>
>         /* Enable PHY polling in hardware if not in fixed-link mode */
> -       if (!pp->fixed_link) {
> +       if (pp->phydev->phy_id != PHY_FIXED_ID) {
>                 mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
>
>                 val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
> @@ -1173,7 +1172,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>                  * be added). Also, why is ADVERT_FC enabled if we don't enable
>                  * inband AN at all?
>                  */
> -               if (pp->fixed_link)
> +               if (pp->phydev->phy_id == PHY_FIXED_ID)
>                         val = MVNETA_GMAC_FORCE_LINK_UP |
>                               MVNETA_GMAC_IB_BYPASS_AN_EN |
>                               MVNETA_GMAC_SET_FC_EN |
> @@ -1431,8 +1430,6 @@ static int mvneta_start(struct udevice *dev)
>                         return -ENODEV;
>                 }
>
> -               pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
> -
>                 pp->phydev = phydev;
>                 phy_config(phydev);
>                 phy_startup(phydev);
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in
  2022-04-27 10:42 ` [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in Marek Behún
@ 2022-04-30 23:32   ` Ramon Fried
  2022-05-02  7:03   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:32 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Guard the code handling the fixed PHY case by
> CONFIG_IS_ENABLED(PHY_FIXED).
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 378789b632..292c364e5e 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -812,7 +812,8 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>         mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
>
>         /* Enable PHY polling in hardware if not in fixed-link mode */
> -       if (pp->phydev->phy_id != PHY_FIXED_ID) {
> +       if (!CONFIG_IS_ENABLED(PHY_FIXED) ||
> +           pp->phydev->phy_id != PHY_FIXED_ID) {
>                 mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
>
>                 val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
> @@ -1172,7 +1173,8 @@ static void mvneta_adjust_link(struct udevice *dev)
>                  * be added). Also, why is ADVERT_FC enabled if we don't enable
>                  * inband AN at all?
>                  */
> -               if (pp->phydev->phy_id == PHY_FIXED_ID)
> +               if (CONFIG_IS_ENABLED(PHY_FIXED) &&
> +                   pp->phydev->phy_id == PHY_FIXED_ID)
>                         val = MVNETA_GMAC_FORCE_LINK_UP |
>                               MVNETA_GMAC_IB_BYPASS_AN_EN |
>                               MVNETA_GMAC_SET_FC_EN |
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro
  2022-04-27 10:42 ` [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro Marek Behún
@ 2022-04-30 23:32   ` Ramon Fried
  2022-05-02  7:03   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Ramon Fried @ 2022-04-30 23:32 UTC (permalink / raw)
  To: Marek Behún
  Cc: Stefan Roese, Robert Marko, Pali Rohár, U-Boot-Denx,
	Joe Hershberger, Marek Behún

On Wed, Apr 27, 2022 at 1:42 PM Marek Behún <kabel@kernel.org> wrote:
>
> From: Marek Behún <marek.behun@nic.cz>
>
> Macro MVNETA_GMAC_FORCE_LINK_UP can be dropped from value assignment in
> fixed link case, since it's value is written into the register later in
> the function for link-down-to-link-up case. The value is written as
> MVNETA_GMAC_FORCE_LINK_DOWN | MVNETA_GMAC_FORCE_LINK_PASS, and so the
> macro definition can also be dropped.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  drivers/net/mvneta.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 292c364e5e..d2c42c4396 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -188,7 +188,6 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define MVNETA_GMAC_AUTONEG_CONFIG               0x2c0c
>  #define      MVNETA_GMAC_FORCE_LINK_DOWN         BIT(0)
>  #define      MVNETA_GMAC_FORCE_LINK_PASS         BIT(1)
> -#define      MVNETA_GMAC_FORCE_LINK_UP           (BIT(0) | BIT(1))
>  #define      MVNETA_GMAC_IB_BYPASS_AN_EN         BIT(3)
>  #define      MVNETA_GMAC_CONFIG_MII_SPEED        BIT(5)
>  #define      MVNETA_GMAC_CONFIG_GMII_SPEED       BIT(6)
> @@ -1175,8 +1174,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>                  */
>                 if (CONFIG_IS_ENABLED(PHY_FIXED) &&
>                     pp->phydev->phy_id == PHY_FIXED_ID)
> -                       val = MVNETA_GMAC_FORCE_LINK_UP |
> -                             MVNETA_GMAC_IB_BYPASS_AN_EN |
> +                       val = MVNETA_GMAC_IB_BYPASS_AN_EN |
>                               MVNETA_GMAC_SET_FC_EN |
>                               MVNETA_GMAC_ADVERT_FC_EN |
>                               MVNETA_GMAC_SAMPLE_TX_CFG_EN;
> --
> 2.35.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (18 preceding siblings ...)
  2022-04-27 10:42 ` [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro Marek Behún
@ 2022-05-02  5:39 ` Stefan Roese
  2022-05-04  9:25 ` Stefan Roese
  20 siblings, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  5:39 UTC (permalink / raw)
  To: Marek Behún, Ramon Fried
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Joe Hershberger,
	Marek Behún, Chris Packham, Heinrich Schuchardt,
	Konstantin Porotchkin, Mario Six, Mark Kettenis, Phil Sutter,
	Rogier Stam, Simon Glass, Vladimir Oltean, Vladimir Vid

Hi Ramon,

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Hello Stefan,
> 
> here come some refactors, cleanups and fixed for the mvneta driver.

Ramon, you've already reviewed those patches. Thanks for this. The
patches are assigned to me in patchwork, which makes perhaps sense,
as some touch the ARM related files. Are you okay with me pulling
these patches via the marvell tree?

Thanks,
Stefan

> Marek Behún (19):
>    net: mvneta: Get rid of platdata
>    net: mvneta: Fix 10Mbps speed
>    net: mvneta: Use DM MDIO API for connecting PHY
>    net: mvneta: Remember fixed link instead of PHY address in priv data
>    arm: mvebu: Espressobin: Use DM registered MDIO to configure switch
>    net: mdio-uclass: add dm_phy_find_by_ofnode() helper
>    arm: mvebu: turris_mox: Use DM registered MDIO
>    net: mvneta: Don't register MDIO bus
>    net: mvneta: Fix unused variable warning if DM_GPIO is disabled
>    net: mvneta: Drop one indentation level in mvneta_adjust_link()
>    net: mvneta: Use bool instead of int for boolean variable
>    net: mvneta: Drop unnecessary space
>    net: mventa: Don't check for CONFIG_PHYLIB
>    net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS
>    net: mvneta: Convert to use PHY_FIXED for fixed-link
>    net: mvneta: Write PHY address just before enabling HW polling
>    net: mvneta: Drop fixed_link member from private struct
>    net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in
>    net: mvneta: Drop unneeded macro
> 
>   .../dts/armada-3720-turris-mox-u-boot.dtsi    |  19 -
>   board/CZ.NIC/turris_mox/turris_mox.c          |  88 ++---
>   board/Marvell/mvebu_armada-37xx/board.c       |  26 +-
>   configs/clearfog_defconfig                    |   1 +
>   configs/controlcenterdc_defconfig             |   1 +
>   configs/db-88f6820-amc_defconfig              |   1 +
>   configs/db-88f6820-gp_defconfig               |   1 +
>   configs/db-mv784mp-gp_defconfig               |   1 +
>   configs/ds414_defconfig                       |   1 +
>   configs/helios4_defconfig                     |   1 +
>   configs/maxbcm_defconfig                      |   1 +
>   configs/mvebu_espressobin-88f3720_defconfig   |   3 +
>   configs/theadorable_debug_defconfig           |   1 +
>   configs/turris_mox_defconfig                  |   1 +
>   configs/turris_omnia_defconfig                |   2 +
>   configs/uDPU_defconfig                        |   1 +
>   drivers/net/Kconfig                           |   1 +
>   drivers/net/mvneta.c                          | 343 ++++--------------
>   include/miiphy.h                              |   9 +
>   net/mdio-uclass.c                             |  22 ++
>   20 files changed, 181 insertions(+), 343 deletions(-)
> 

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata
  2022-04-27 10:41 ` [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata Marek Behún
  2022-04-30 23:28   ` Ramon Fried
@ 2022-05-02  6:48   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  6:48 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Drop .of_to_plat() from the mvneta driver and parse the two properties
> in .probe().
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   drivers/net/mvneta.c | 24 ++++--------------------
>   1 file changed, 4 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 15dc714058..d1c5f7930d 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1692,7 +1692,6 @@ static int mvneta_recv(struct udevice *dev, int flags, uchar **packetp)
>   
>   static int mvneta_probe(struct udevice *dev)
>   {
> -	struct eth_pdata *pdata = dev_get_plat(dev);
>   	struct mvneta_port *pp = dev_get_priv(dev);
>   #if CONFIG_IS_ENABLED(DM_GPIO)
>   	struct ofnode_phandle_args sfp_args;
> @@ -1729,7 +1728,10 @@ static int mvneta_probe(struct udevice *dev)
>   		buffer_loc.rx_buffers = (phys_addr_t)(bd_space + size);
>   	}
>   
> -	pp->base = (void __iomem *)pdata->iobase;
> +	pp->base = dev_read_addr_ptr(dev);
> +	pp->phy_interface = dev_read_phy_mode(dev);
> +	if (pp->phy_interface == PHY_INTERFACE_MODE_NA)
> +		return -EINVAL;
>   
>   	/* Configure MBUS address windows */
>   	if (device_is_compatible(dev, "marvell,armada-3700-neta"))
> @@ -1737,9 +1739,6 @@ static int mvneta_probe(struct udevice *dev)
>   	else
>   		mvneta_conf_mbus_windows(pp);
>   
> -	/* PHY interface is already decoded in mvneta_of_to_plat() */
> -	pp->phy_interface = pdata->phy_interface;
> -
>   	/* fetch 'fixed-link' property from 'neta' node */
>   	fl_node = fdt_subnode_offset(blob, node, "fixed-link");
>   	if (fl_node != -FDT_ERR_NOTFOUND) {
> @@ -1808,20 +1807,6 @@ static const struct eth_ops mvneta_ops = {
>   	.write_hwaddr	= mvneta_write_hwaddr,
>   };
>   
> -static int mvneta_of_to_plat(struct udevice *dev)
> -{
> -	struct eth_pdata *pdata = dev_get_plat(dev);
> -
> -	pdata->iobase = dev_read_addr(dev);
> -
> -	/* Get phy-mode / phy_interface from DT */
> -	pdata->phy_interface = dev_read_phy_mode(dev);
> -	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
> -		return -EINVAL;
> -
> -	return 0;
> -}
> -
>   static const struct udevice_id mvneta_ids[] = {
>   	{ .compatible = "marvell,armada-370-neta" },
>   	{ .compatible = "marvell,armada-xp-neta" },
> @@ -1833,7 +1818,6 @@ U_BOOT_DRIVER(mvneta) = {
>   	.name	= "mvneta",
>   	.id	= UCLASS_ETH,
>   	.of_match = mvneta_ids,
> -	.of_to_plat = mvneta_of_to_plat,
>   	.probe	= mvneta_probe,
>   	.ops	= &mvneta_ops,
>   	.priv_auto	= sizeof(struct mvneta_port),

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed
  2022-04-27 10:41 ` [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed Marek Behún
  2022-04-30 23:28   ` Ramon Fried
@ 2022-05-02  6:48   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  6:48 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> In mvneta_adjust_link() we need to set MII_SPEED bit only if PHY reports
> the speed at 100Mbps.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index d1c5f7930d..79cdb93341 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1195,7 +1195,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>   
>   			if (phydev->speed == SPEED_1000)
>   				val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
> -			else
> +			else if (pp->speed == SPEED_100)
>   				val |= MVNETA_GMAC_CONFIG_MII_SPEED;
>   
>   			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY
  2022-04-27 10:41 ` [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY Marek Behún
  2022-04-30 23:28   ` Ramon Fried
@ 2022-05-02  6:48   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  6:48 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún, Mario Six, Chris Packham,
	Phil Sutter, Konstantin Porotchkin, Vladimir Vid

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Use the modern DM MDIO API for connecting PHY in the mvneta driver.
> 
> This requires enabling MVMDIO driver in several config files.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   configs/clearfog_defconfig                  |  1 +
>   configs/controlcenterdc_defconfig           |  1 +
>   configs/db-88f6820-amc_defconfig            |  1 +
>   configs/db-88f6820-gp_defconfig             |  1 +
>   configs/db-mv784mp-gp_defconfig             |  1 +
>   configs/ds414_defconfig                     |  1 +
>   configs/helios4_defconfig                   |  1 +
>   configs/maxbcm_defconfig                    |  1 +
>   configs/mvebu_espressobin-88f3720_defconfig |  1 +
>   configs/theadorable_debug_defconfig         |  1 +
>   configs/turris_mox_defconfig                |  1 +
>   configs/turris_omnia_defconfig              |  1 +
>   configs/uDPU_defconfig                      |  1 +
>   drivers/net/Kconfig                         |  1 +
>   drivers/net/mvneta.c                        | 11 +++++------
>   15 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig
> index 880f16a6e0..b8f59d2962 100644
> --- a/configs/clearfog_defconfig
> +++ b/configs/clearfog_defconfig
> @@ -63,6 +63,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_PCI_MVEBU=y
>   CONFIG_SCSI=y
> diff --git a/configs/controlcenterdc_defconfig b/configs/controlcenterdc_defconfig
> index d4b966b93f..df38b2c54f 100644
> --- a/configs/controlcenterdc_defconfig
> +++ b/configs/controlcenterdc_defconfig
> @@ -77,6 +77,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_DM_PCI_COMPAT=y
>   CONFIG_PCI_MVEBU=y
> diff --git a/configs/db-88f6820-amc_defconfig b/configs/db-88f6820-amc_defconfig
> index 46c822fccd..9b77b4a5f0 100644
> --- a/configs/db-88f6820-amc_defconfig
> +++ b/configs/db-88f6820-amc_defconfig
> @@ -67,6 +67,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_PCI_MVEBU=y
>   CONFIG_DEBUG_UART_SHIFT=2
> diff --git a/configs/db-88f6820-gp_defconfig b/configs/db-88f6820-gp_defconfig
> index 2dcbc2f29a..f56d1fbf25 100644
> --- a/configs/db-88f6820-gp_defconfig
> +++ b/configs/db-88f6820-gp_defconfig
> @@ -62,6 +62,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_PCI_MVEBU=y
>   CONFIG_SCSI=y
> diff --git a/configs/db-mv784mp-gp_defconfig b/configs/db-mv784mp-gp_defconfig
> index f19cc54975..5683f11836 100644
> --- a/configs/db-mv784mp-gp_defconfig
> +++ b/configs/db-mv784mp-gp_defconfig
> @@ -65,6 +65,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_PCI_MVEBU=y
>   CONFIG_DEBUG_UART_SHIFT=2
> diff --git a/configs/ds414_defconfig b/configs/ds414_defconfig
> index a3279c15c5..a83fe079b3 100644
> --- a/configs/ds414_defconfig
> +++ b/configs/ds414_defconfig
> @@ -65,6 +65,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_PCI_MVEBU=y
>   CONFIG_DEBUG_UART_SHIFT=2
> diff --git a/configs/helios4_defconfig b/configs/helios4_defconfig
> index 7d812e8fab..c2130bacb4 100644
> --- a/configs/helios4_defconfig
> +++ b/configs/helios4_defconfig
> @@ -63,6 +63,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_PCI_MVEBU=y
>   CONFIG_SCSI=y
> diff --git a/configs/maxbcm_defconfig b/configs/maxbcm_defconfig
> index 8dd6adf247..40f79d47ea 100644
> --- a/configs/maxbcm_defconfig
> +++ b/configs/maxbcm_defconfig
> @@ -47,6 +47,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_DEBUG_UART_SHIFT=2
>   CONFIG_SYS_NS16550=y
>   CONFIG_KIRKWOOD_SPI=y
> diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
> index ff05630d20..af30f1b363 100644
> --- a/configs/mvebu_espressobin-88f3720_defconfig
> +++ b/configs/mvebu_espressobin-88f3720_defconfig
> @@ -76,6 +76,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_E1000=y
>   CONFIG_MVNETA=y
> +CONFIG_MVMDIO=y
>   CONFIG_NVME_PCI=y
>   CONFIG_PCI=y
>   CONFIG_PCI_AARDVARK=y
> diff --git a/configs/theadorable_debug_defconfig b/configs/theadorable_debug_defconfig
> index 86129e7d2d..9a03a0a7a3 100644
> --- a/configs/theadorable_debug_defconfig
> +++ b/configs/theadorable_debug_defconfig
> @@ -70,6 +70,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_DM_PCI_COMPAT=y
>   CONFIG_PCI_MVEBU=y
> diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
> index 9a76a118c2..bcd3699a4f 100644
> --- a/configs/turris_mox_defconfig
> +++ b/configs/turris_mox_defconfig
> @@ -82,6 +82,7 @@ CONFIG_SPI_FLASH_MTD=y
>   CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
> +CONFIG_MVMDIO=y
>   CONFIG_NVME_PCI=y
>   CONFIG_PCI=y
>   CONFIG_PCI_AARDVARK=y
> diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
> index ad56d3824b..6b218bd7a7 100644
> --- a/configs/turris_omnia_defconfig
> +++ b/configs/turris_omnia_defconfig
> @@ -82,6 +82,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> +CONFIG_MVMDIO=y
>   CONFIG_NVME_PCI=y
>   CONFIG_PCI=y
>   CONFIG_PCI_MVEBU=y
> diff --git a/configs/uDPU_defconfig b/configs/uDPU_defconfig
> index c07bad5076..f2852ad29b 100644
> --- a/configs/uDPU_defconfig
> +++ b/configs/uDPU_defconfig
> @@ -73,6 +73,7 @@ CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_E1000=y
>   CONFIG_MVNETA=y
> +CONFIG_MVMDIO=y
>   CONFIG_PCI=y
>   CONFIG_PCI_AARDVARK=y
>   CONFIG_PHY=y
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index 347fe8aa42..47f7a262f2 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -445,6 +445,7 @@ config MVNETA
>   	bool "Marvell Armada XP/385/3700 network interface support"
>   	depends on ARMADA_XP || ARMADA_38X || ARMADA_3700
>   	select PHYLIB
> +	select DM_MDIO
>   	help
>   	  This driver supports the network interface units in the
>   	  Marvell ARMADA XP, ARMADA 38X and ARMADA 3700 SoCs
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 79cdb93341..24a491dcde 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1571,16 +1571,15 @@ static int mvneta_start(struct udevice *dev)
>   
>   			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
>   		} else {
> -			/* Set phy address of the port */
> -			mvreg_write(pp, MVNETA_PHY_ADDR, pp->phyaddr);
> -
> -			phydev = phy_connect(pp->bus, pp->phyaddr, dev,
> -					     pp->phy_interface);
> +			phydev = dm_eth_phy_connect(dev);
>   			if (!phydev) {
> -				printf("phy_connect failed\n");
> +				printf("dm_eth_phy_connect failed\n");
>   				return -ENODEV;
>   			}
>   
> +			/* Set PHY address in case we will enable HW polling */
> +			mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
> +
>   			pp->phydev = phydev;
>   			phy_config(phydev);
>   			phy_startup(phydev);

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data
  2022-04-27 10:41 ` [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data Marek Behún
  2022-04-30 23:28   ` Ramon Fried
@ 2022-05-02  6:48   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  6:48 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> We don't need to remember PHY address anymore, because since using DM
> MDIO for connecting PHY, the address is parsed by mdio-uclass from
> the ofnode.
> 
> But the driver uses a special value of the address to signal fixed link
> usage.
> 
> Drop phyaddr add fixed_link in driver private structure. This simplifies
> code a little.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 23 +++++------------------
>   1 file changed, 5 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 24a491dcde..83e9629138 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -277,12 +277,12 @@ struct mvneta_port {
>   	u16 rx_ring_size;
>   
>   	phy_interface_t phy_interface;
> +	bool fixed_link;
>   	unsigned int link;
>   	unsigned int duplex;
>   	unsigned int speed;
>   
>   	int init;
> -	int phyaddr;
>   	struct phy_device *phydev;
>   #if CONFIG_IS_ENABLED(DM_GPIO)
>   	struct gpio_desc phy_reset_gpio;
> @@ -576,13 +576,6 @@ static void mvneta_rxq_buf_size_set(struct mvneta_port *pp,
>   	mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), val);
>   }
>   
> -static int mvneta_port_is_fixed_link(struct mvneta_port *pp)
> -{
> -	/* phy_addr is set to invalid value for fixed link */
> -	return pp->phyaddr > PHY_MAX_ADDR;
> -}
> -
> -
>   /* Start the Ethernet port RX and TX activity */
>   static void mvneta_port_up(struct mvneta_port *pp)
>   {
> @@ -834,7 +827,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>   	mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
>   
>   	/* Enable PHY polling in hardware if not in fixed-link mode */
> -	if (!mvneta_port_is_fixed_link(pp)) {
> +	if (!pp->fixed_link) {
>   		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
>   		val |= MVNETA_PHY_POLLING_ENABLE;
>   		mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
> @@ -1173,7 +1166,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>   	struct phy_device *phydev = pp->phydev;
>   	int status_change = 0;
>   
> -	if (mvneta_port_is_fixed_link(pp)) {
> +	if (pp->fixed_link) {
>   		debug("Using fixed link, skip link adjust\n");
>   		return;
>   	}
> @@ -1548,7 +1541,7 @@ static int mvneta_start(struct udevice *dev)
>   	mvneta_port_power_up(pp, pp->phy_interface);
>   
>   	if (!pp->init || pp->link == 0) {
> -		if (mvneta_port_is_fixed_link(pp)) {
> +		if (pp->fixed_link) {
>   			u32 val;
>   
>   			pp->init = 1;
> @@ -1698,7 +1691,6 @@ static int mvneta_probe(struct udevice *dev)
>   	void *blob = (void *)gd->fdt_blob;
>   	int node = dev_of_offset(dev);
>   	struct mii_dev *bus;
> -	unsigned long addr;
>   	void *bd_space;
>   	int ret;
>   	int fl_node;
> @@ -1742,14 +1734,9 @@ static int mvneta_probe(struct udevice *dev)
>   	fl_node = fdt_subnode_offset(blob, node, "fixed-link");
>   	if (fl_node != -FDT_ERR_NOTFOUND) {
>   		/* set phy_addr to invalid value for fixed link */
> -		pp->phyaddr = PHY_MAX_ADDR + 1;
>   		pp->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex");
>   		pp->speed = fdtdec_get_int(blob, fl_node, "speed", 0);
> -	} else {
> -		/* Now read phyaddr from DT */
> -		addr = fdtdec_get_int(blob, node, "phy", 0);
> -		addr = fdt_node_offset_by_phandle(blob, addr);
> -		pp->phyaddr = fdtdec_get_int(blob, addr, "reg", 0);
> +		pp->fixed_link = true;
>   	}
>   
>   	bus = mdio_alloc();

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 05/19] arm: mvebu: Espressobin: Use DM registered MDIO to configure switch
  2022-04-27 10:41 ` [PATCH u-boot-marvell 05/19] arm: mvebu: Espressobin: Use DM registered MDIO to configure switch Marek Behún
@ 2022-05-02  6:48   ` Stefan Roese
  0 siblings, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  6:48 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún, Konstantin Porotchkin,
	Rogier Stam, Mark Kettenis

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> In order to be able to get rid of the non-DM MDIO bus registered in
> mvneta driver, we need to stop using board_network_enable() and instead
> use the DM registered MDIO device to configure switch in
> last_stage_init().
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   board/Marvell/mvebu_armada-37xx/board.c     | 26 ++++++++++++++++-----
>   configs/mvebu_espressobin-88f3720_defconfig |  1 +
>   2 files changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c
> index 98e1b36d11..3e5e0a0b5c 100644
> --- a/board/Marvell/mvebu_armada-37xx/board.c
> +++ b/board/Marvell/mvebu_armada-37xx/board.c
> @@ -11,6 +11,7 @@
>   #include <i2c.h>
>   #include <init.h>
>   #include <mmc.h>
> +#include <miiphy.h>
>   #include <phy.h>
>   #include <asm/global_data.h>
>   #include <asm/io.h>
> @@ -254,14 +255,15 @@ int board_xhci_enable(fdt_addr_t base)
>   	return 0;
>   }
>   
> +#ifdef CONFIG_LAST_STAGE_INIT
>   /* Helper function for accessing switch devices in multi-chip connection mode */
> -static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
> +static int mii_multi_chip_mode_write(struct udevice *bus, int dev_smi_addr,
>   				     int smi_addr, int reg, u16 value)
>   {
>   	u16 smi_cmd = 0;
>   
> -	if (bus->write(bus, dev_smi_addr, 0,
> -		       MVEBU_SW_SMI_DATA_REG, value) != 0) {
> +	if (dm_mdio_write(bus, dev_smi_addr, MDIO_DEVAD_NONE,
> +			  MVEBU_SW_SMI_DATA_REG, value) != 0) {
>   		printf("Error writing to the PHY addr=%02x reg=%02x\n",
>   		       smi_addr, reg);
>   		return -EFAULT;
> @@ -272,8 +274,8 @@ static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
>   		  (1 << SW_SMI_CMD_SMI_OP_OFF) |
>   		  (smi_addr << SW_SMI_CMD_DEV_ADDR_OFF) |
>   		  (reg << SW_SMI_CMD_REG_ADDR_OFF);
> -	if (bus->write(bus, dev_smi_addr, 0,
> -		       MVEBU_SW_SMI_CMD_REG, smi_cmd) != 0) {
> +	if (dm_mdio_write(bus, dev_smi_addr, MDIO_DEVAD_NONE,
> +			  MVEBU_SW_SMI_CMD_REG, smi_cmd) != 0) {
>   		printf("Error writing to the PHY addr=%02x reg=%02x\n",
>   		       smi_addr, reg);
>   		return -EFAULT;
> @@ -283,11 +285,22 @@ static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
>   }
>   
>   /* Bring-up board-specific network stuff */
> -int board_network_enable(struct mii_dev *bus)
> +int last_stage_init(void)
>   {
> +	struct udevice *bus;
> +	ofnode node;
> +
>   	if (!of_machine_is_compatible("globalscale,espressobin"))
>   		return 0;
>   
> +	node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
> +	if (!ofnode_valid(node) ||
> +	    uclass_get_device_by_ofnode(UCLASS_MDIO, node, &bus) ||
> +	    device_probe(bus)) {
> +		printf("Cannot find MDIO bus\n");
> +		return 0;
> +	}
> +
>   	/*
>   	 * FIXME: remove this code once Topaz driver gets available
>   	 * A3720 Community Board Only
> @@ -327,6 +340,7 @@ int board_network_enable(struct mii_dev *bus)
>   
>   	return 0;
>   }
> +#endif
>   
>   #ifdef CONFIG_OF_BOARD_SETUP
>   int ft_board_setup(void *blob, struct bd_info *bd)
> diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
> index af30f1b363..37e4fdc41e 100644
> --- a/configs/mvebu_espressobin-88f3720_defconfig
> +++ b/configs/mvebu_espressobin-88f3720_defconfig
> @@ -25,6 +25,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
>   CONFIG_ARCH_EARLY_INIT_R=y
>   CONFIG_BOARD_EARLY_INIT_F=y
>   CONFIG_BOARD_LATE_INIT=y
> +CONFIG_LAST_STAGE_INIT=y
>   # CONFIG_CMD_FLASH is not set
>   CONFIG_CMD_FUSE=y
>   CONFIG_CMD_GPIO=y

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper
  2022-04-27 10:41 ` [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper Marek Behún
  2022-04-30 23:28   ` Ramon Fried
@ 2022-05-02  7:00   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:00 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún, Heinrich Schuchardt,
	Vladimir Oltean, Simon Glass

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Add helper to resolve PHY node from it's ofnode via DM MDIO subsystem.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   include/miiphy.h  |  9 +++++++++
>   net/mdio-uclass.c | 22 ++++++++++++++++++++++
>   2 files changed, 31 insertions(+)
> 
> diff --git a/include/miiphy.h b/include/miiphy.h
> index 110921f20d..c66a1845b5 100644
> --- a/include/miiphy.h
> +++ b/include/miiphy.h
> @@ -188,6 +188,15 @@ int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, u16 va
>    */
>   int dm_mdio_reset(struct udevice *mdio_dev);
>   
> +/**
> + * dm_phy_find_by_ofnode - Find PHY device by ofnode
> + *
> + * @phynode: PHY's ofnode
> + *
> + * Return: pointer to phy_device, or NULL on error
> + */
> +struct phy_device *dm_phy_find_by_ofnode(ofnode phynode);
> +
>   /**
>    * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO
>    *
> diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
> index 7593618d9a..4401492ca0 100644
> --- a/net/mdio-uclass.c
> +++ b/net/mdio-uclass.c
> @@ -129,6 +129,28 @@ static int dm_mdio_pre_remove(struct udevice *dev)
>   	return 0;
>   }
>   
> +struct phy_device *dm_phy_find_by_ofnode(ofnode phynode)
> +{
> +	struct mdio_perdev_priv *pdata;
> +	struct udevice *mdiodev;
> +	u32 phy_addr;
> +
> +	if (ofnode_read_u32(phynode, "reg", &phy_addr))
> +		return NULL;
> +
> +	if (uclass_get_device_by_ofnode(UCLASS_MDIO,
> +					ofnode_get_parent(phynode),
> +					&mdiodev))
> +		return NULL;
> +
> +	if (device_probe(mdiodev))
> +		return NULL;
> +
> +	pdata = dev_get_uclass_priv(mdiodev);
> +
> +	return phy_find_by_mask(pdata->mii_bus, BIT(phy_addr));
> +}
> +
>   struct phy_device *dm_mdio_phy_connect(struct udevice *mdiodev, int phyaddr,
>   				       struct udevice *ethdev,
>   				       phy_interface_t interface)

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 07/19] arm: mvebu: turris_mox: Use DM registered MDIO
  2022-04-27 10:41 ` [PATCH u-boot-marvell 07/19] arm: mvebu: turris_mox: Use DM registered MDIO Marek Behún
@ 2022-05-02  7:00   ` Stefan Roese
  0 siblings, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:00 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> In order to be able to get rid of the non-DM MDIO bus registered in
> mvneta driver, start using the DM registered one in Turris MOX board
> code.
> 
> This also allows us to drop the hack introduced in MOX' -u-boot.dtsi
> file.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   .../dts/armada-3720-turris-mox-u-boot.dtsi    | 19 ----
>   board/CZ.NIC/turris_mox/turris_mox.c          | 88 +++++++++----------
>   2 files changed, 44 insertions(+), 63 deletions(-)
> 
> diff --git a/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi b/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi
> index 28a36a6103..71d5e70ca4 100644
> --- a/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi
> +++ b/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi
> @@ -3,25 +3,6 @@
>    * 2022 by Marek Behún <kabel@kernel.org>
>    */
>   
> -/ {
> -	mdio {
> -		#address-cells = <1>;
> -		#size-cells = <0>;
> -
> -		old_binding_phy1: ethernet-phy@1 {
> -			reg = <1>;
> -		};
> -	};
> -};
> -
> -&eth0 {
> -	pinctrl-0 = <&rgmii_pins>, <&smi_pins>;
> -	/delete-property/ phy-handle;
> -	phy = <&old_binding_phy1>;
> -};
> -
> -/delete-node/ &mdio;
> -
>   &usb3 {
>   	vbus-supply = <&exp_usb3_vbus>;
>   };
> diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
> index 9702d1fc78..a4738b3a3c 100644
> --- a/board/CZ.NIC/turris_mox/turris_mox.c
> +++ b/board/CZ.NIC/turris_mox/turris_mox.c
> @@ -13,6 +13,7 @@
>   #include <button.h>
>   #include <clk.h>
>   #include <dm.h>
> +#include <dm/of_extra.h>
>   #include <env.h>
>   #include <fdt_support.h>
>   #include <init.h>
> @@ -216,35 +217,35 @@ static int mox_get_topology(const u8 **ptopology, int *psize, int *pis_sd)
>   #define SW_SMI_CMD_R(d, r)	(0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
>   #define SW_SMI_CMD_W(d, r)	(0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
>   
> -static int sw_multi_read(struct mii_dev *bus, int sw, int dev, int reg)
> +static int sw_multi_read(struct udevice *bus, int sw, int dev, int reg)
>   {
> -	bus->write(bus, sw, 0, 0, SW_SMI_CMD_R(dev, reg));
> +	dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 0, SW_SMI_CMD_R(dev, reg));
>   	mdelay(5);
> -	return bus->read(bus, sw, 0, 1);
> +	return dm_mdio_read(bus, sw, MDIO_DEVAD_NONE, 1);
>   }
>   
> -static void sw_multi_write(struct mii_dev *bus, int sw, int dev, int reg,
> +static void sw_multi_write(struct udevice *bus, int sw, int dev, int reg,
>   			   u16 val)
>   {
> -	bus->write(bus, sw, 0, 1, val);
> -	bus->write(bus, sw, 0, 0, SW_SMI_CMD_W(dev, reg));
> +	dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 1, val);
> +	dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 0, SW_SMI_CMD_W(dev, reg));
>   	mdelay(5);
>   }
>   
> -static int sw_scratch_read(struct mii_dev *bus, int sw, int reg)
> +static int sw_scratch_read(struct udevice *bus, int sw, int reg)
>   {
>   	sw_multi_write(bus, sw, 0x1c, 0x1a, (reg & 0x7f) << 8);
>   	return sw_multi_read(bus, sw, 0x1c, 0x1a) & 0xff;
>   }
>   
> -static void sw_led_write(struct mii_dev *bus, int sw, int port, int reg,
> +static void sw_led_write(struct udevice *bus, int sw, int port, int reg,
>   			 u16 val)
>   {
>   	sw_multi_write(bus, sw, port, 0x16, 0x8000 | ((reg & 7) << 12)
>   					    | (val & 0x7ff));
>   }
>   
> -static void sw_blink_leds(struct mii_dev *bus, int peridot, int topaz)
> +static void sw_blink_leds(struct udevice *bus, int peridot, int topaz)
>   {
>   	int i, p;
>   	struct {
> @@ -275,7 +276,7 @@ static void sw_blink_leds(struct mii_dev *bus, int peridot, int topaz)
>   	}
>   }
>   
> -static void check_switch_address(struct mii_dev *bus, int addr)
> +static void check_switch_address(struct udevice *bus, int addr)
>   {
>   	if (sw_scratch_read(bus, addr, 0x70) >> 3 != addr)
>   		printf("Check of switch MDIO address failed for 0x%02x\n",
> @@ -374,36 +375,22 @@ static void mox_phy_modify(struct phy_device *phydev, int page, int reg,
>   static void mox_phy_leds_start_blinking(void)
>   {
>   	struct phy_device *phydev;
> -	struct mii_dev *bus;
> -	const char *node_name;
> -	int node;
> +	ofnode phy_node;
>   
> -	node = fdt_path_offset(gd->fdt_blob, "ethernet0");
> -	if (node < 0) {
> -		printf("Cannot get eth0!\n");
> -		return;
> -	}
> +	phy_node = ofnode_get_phy_node(ofnode_path("ethernet0"));
> +	if (!ofnode_valid(phy_node))
> +		goto err;
>   
> -	node_name = fdt_get_name(gd->fdt_blob, node, NULL);
> -	if (!node_name) {
> -		printf("Cannot get eth0 node name!\n");
> -		return;
> -	}
> -
> -	bus = miiphy_get_dev_by_name(node_name);
> -	if (!bus) {
> -		printf("Cannot get MDIO bus device!\n");
> -		return;
> -	}
> -
> -	phydev = phy_find_by_mask(bus, BIT(1));
> -	if (!phydev) {
> -		printf("Cannot get ethernet PHY!\n");
> -		return;
> -	}
> +	phydev = dm_phy_find_by_ofnode(phy_node);
> +	if (!phydev)
> +		goto err;
>   
>   	mox_phy_modify(phydev, 3, 0x12, 0x700, 0x400);
>   	mox_phy_modify(phydev, 3, 0x10, 0xff, 0xbb);
> +
> +	return;
> +err:
> +	printf("Cannot get ethernet PHY!\n");
>   }
>   
>   static bool read_reset_button(void)
> @@ -611,6 +598,26 @@ int show_board_info(void)
>   	return 0;
>   }
>   
> +static struct udevice *mox_mdio_bus(void)
> +{
> +	struct udevice *bus;
> +	ofnode node;
> +
> +	node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
> +	if (!ofnode_valid(node))
> +		goto err;
> +
> +	dm_mdio_probe_devices();
> +
> +	if (uclass_get_device_by_ofnode(UCLASS_MDIO, node, &bus))
> +		goto err;
> +
> +	return bus;
> +err:
> +	printf("Cannot get MDIO bus device!\n");
> +	return NULL;
> +}
> +
>   int last_stage_init(void)
>   {
>   	struct gpio_desc reset_gpio = {};
> @@ -636,16 +643,9 @@ int last_stage_init(void)
>   	 * 0x70 of Peridot (and potentially Topaz) modules
>   	 */
>   	if (peridot || topaz) {
> -		struct mii_dev *bus;
> -		const char *node_name;
> -		int node;
> +		struct udevice *bus = mox_mdio_bus();
>   
> -		node = fdt_path_offset(gd->fdt_blob, "ethernet0");
> -		node_name = (node >= 0) ? fdt_get_name(gd->fdt_blob, node, NULL) : NULL;
> -		bus = node_name ? miiphy_get_dev_by_name(node_name) : NULL;
> -		if (!bus) {
> -			printf("Cannot get MDIO bus device!\n");
> -		} else {
> +		if (bus) {
>   			int i;
>   
>   			for (i = 0; i < peridot; ++i)

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus
  2022-04-27 10:41 ` [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus Marek Behún
  2022-04-30 23:29   ` Ramon Fried
@ 2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:01 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> This MDIO bus is now handled by a proper mvmdio DM driver. Remove it
> from mvneta.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 143 +------------------------------------------
>   1 file changed, 2 insertions(+), 141 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 83e9629138..19f8145fc0 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -288,7 +288,6 @@ struct mvneta_port {
>   	struct gpio_desc phy_reset_gpio;
>   	struct gpio_desc sfp_tx_disable_gpio;
>   #endif
> -	struct mii_dev *bus;
>   };
>   
>   /* The mvneta_tx_desc and mvneta_rx_desc structures describe the
> @@ -414,15 +413,6 @@ static struct buffer_location buffer_loc;
>    */
>   #define BD_SPACE	(1 << 20)
>   
> -/*
> - * Dummy implementation that can be overwritten by a board
> - * specific function
> - */
> -__weak int board_network_enable(struct mii_dev *bus)
> -{
> -	return 0;
> -}
> -
>   /* Utility/helper methods */
>   
>   /* Write helper method */
> @@ -1421,118 +1411,6 @@ static int mvneta_init(struct udevice *dev)
>   
>   /* U-Boot only functions follow here */
>   
> -/* SMI / MDIO functions */
> -
> -static int smi_wait_ready(struct mvneta_port *pp)
> -{
> -	u32 timeout = MVNETA_SMI_TIMEOUT;
> -	u32 smi_reg;
> -
> -	/* wait till the SMI is not busy */
> -	do {
> -		/* read smi register */
> -		smi_reg = mvreg_read(pp, MVNETA_SMI);
> -		if (timeout-- == 0) {
> -			printf("Error: SMI busy timeout\n");
> -			return -EFAULT;
> -		}
> -	} while (smi_reg & MVNETA_SMI_BUSY);
> -
> -	return 0;
> -}
> -
> -/*
> - * mvneta_mdio_read - miiphy_read callback function.
> - *
> - * Returns 16bit phy register value, or 0xffff on error
> - */
> -static int mvneta_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
> -{
> -	struct mvneta_port *pp = bus->priv;
> -	u32 smi_reg;
> -	u32 timeout;
> -
> -	/* check parameters */
> -	if (addr > MVNETA_PHY_ADDR_MASK) {
> -		printf("Error: Invalid PHY address %d\n", addr);
> -		return -EFAULT;
> -	}
> -
> -	if (reg > MVNETA_PHY_REG_MASK) {
> -		printf("Err: Invalid register offset %d\n", reg);
> -		return -EFAULT;
> -	}
> -
> -	/* wait till the SMI is not busy */
> -	if (smi_wait_ready(pp) < 0)
> -		return -EFAULT;
> -
> -	/* fill the phy address and regiser offset and read opcode */
> -	smi_reg = (addr << MVNETA_SMI_DEV_ADDR_OFFS)
> -		| (reg << MVNETA_SMI_REG_ADDR_OFFS)
> -		| MVNETA_SMI_OPCODE_READ;
> -
> -	/* write the smi register */
> -	mvreg_write(pp, MVNETA_SMI, smi_reg);
> -
> -	/* wait till read value is ready */
> -	timeout = MVNETA_SMI_TIMEOUT;
> -
> -	do {
> -		/* read smi register */
> -		smi_reg = mvreg_read(pp, MVNETA_SMI);
> -		if (timeout-- == 0) {
> -			printf("Err: SMI read ready timeout\n");
> -			return -EFAULT;
> -		}
> -	} while (!(smi_reg & MVNETA_SMI_READ_VALID));
> -
> -	/* Wait for the data to update in the SMI register */
> -	for (timeout = 0; timeout < MVNETA_SMI_TIMEOUT; timeout++)
> -		;
> -
> -	return mvreg_read(pp, MVNETA_SMI) & MVNETA_SMI_DATA_MASK;
> -}
> -
> -/*
> - * mvneta_mdio_write - miiphy_write callback function.
> - *
> - * Returns 0 if write succeed, -EINVAL on bad parameters
> - * -ETIME on timeout
> - */
> -static int mvneta_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
> -			     u16 value)
> -{
> -	struct mvneta_port *pp = bus->priv;
> -	u32 smi_reg;
> -
> -	/* check parameters */
> -	if (addr > MVNETA_PHY_ADDR_MASK) {
> -		printf("Error: Invalid PHY address %d\n", addr);
> -		return -EFAULT;
> -	}
> -
> -	if (reg > MVNETA_PHY_REG_MASK) {
> -		printf("Err: Invalid register offset %d\n", reg);
> -		return -EFAULT;
> -	}
> -
> -	/* wait till the SMI is not busy */
> -	if (smi_wait_ready(pp) < 0)
> -		return -EFAULT;
> -
> -	/* fill the phy addr and reg offset and write opcode and data */
> -	smi_reg = value << MVNETA_SMI_DATA_OFFS;
> -	smi_reg |= (addr << MVNETA_SMI_DEV_ADDR_OFFS)
> -		| (reg << MVNETA_SMI_REG_ADDR_OFFS);
> -	smi_reg &= ~MVNETA_SMI_OPCODE_READ;
> -
> -	/* write the smi register */
> -	mvreg_write(pp, MVNETA_SMI, smi_reg);
> -
> -	return 0;
> -}
> -
>   static int mvneta_start(struct udevice *dev)
>   {
>   	struct mvneta_port *pp = dev_get_priv(dev);
> @@ -1690,10 +1568,9 @@ static int mvneta_probe(struct udevice *dev)
>   #endif
>   	void *blob = (void *)gd->fdt_blob;
>   	int node = dev_of_offset(dev);
> -	struct mii_dev *bus;
>   	void *bd_space;
> -	int ret;
>   	int fl_node;
> +	int ret;
>   
>   	/*
>   	 * Allocate buffer area for descs and rx_buffers. This is only
> @@ -1739,22 +1616,6 @@ static int mvneta_probe(struct udevice *dev)
>   		pp->fixed_link = true;
>   	}
>   
> -	bus = mdio_alloc();
> -	if (!bus) {
> -		printf("Failed to allocate MDIO bus\n");
> -		return -ENOMEM;
> -	}
> -
> -	bus->read = mvneta_mdio_read;
> -	bus->write = mvneta_mdio_write;
> -	snprintf(bus->name, sizeof(bus->name), dev->name);
> -	bus->priv = (void *)pp;
> -	pp->bus = bus;
> -
> -	ret = mdio_register(bus);
> -	if (ret)
> -		return ret;
> -
>   #if CONFIG_IS_ENABLED(DM_GPIO)
>   	ret = dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args);
>   	if (!ret && ofnode_is_enabled(sfp_args.node))
> @@ -1774,7 +1635,7 @@ static int mvneta_probe(struct udevice *dev)
>   		dm_gpio_set_value(&pp->sfp_tx_disable_gpio, 0);
>   #endif
>   
> -	return board_network_enable(bus);
> +	return 0;
>   }
>   
>   static void mvneta_stop(struct udevice *dev)

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled
  2022-04-27 10:41 ` [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled Marek Behún
  2022-04-30 23:29   ` Ramon Fried
@ 2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:01 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> The `ret` variable in mvneta_probe() is unused if DM_GPIO is disabled.
> 
> Since the variable is used only once after assigning value, we can
> inline the usage and drop the variable.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 19f8145fc0..72789fc5c6 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1570,7 +1570,6 @@ static int mvneta_probe(struct udevice *dev)
>   	int node = dev_of_offset(dev);
>   	void *bd_space;
>   	int fl_node;
> -	int ret;
>   
>   	/*
>   	 * Allocate buffer area for descs and rx_buffers. This is only
> @@ -1617,8 +1616,8 @@ static int mvneta_probe(struct udevice *dev)
>   	}
>   
>   #if CONFIG_IS_ENABLED(DM_GPIO)
> -	ret = dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args);
> -	if (!ret && ofnode_is_enabled(sfp_args.node))
> +	if (!dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args) &&
> +	    ofnode_is_enabled(sfp_args.node))
>   		gpio_request_by_name_nodev(sfp_args.node, "tx-disable-gpio", 0,
>   					   &pp->sfp_tx_disable_gpio, GPIOD_IS_OUT);
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link()
  2022-04-27 10:41 ` [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link() Marek Behún
  2022-04-30 23:29   ` Ramon Fried
@ 2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:01 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Drop one indentation level in the mvneta_adjust_link() function.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 38 ++++++++++++++++++--------------------
>   1 file changed, 18 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 72789fc5c6..66d5e10174 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1161,31 +1161,29 @@ static void mvneta_adjust_link(struct udevice *dev)
>   		return;
>   	}
>   
> -	if (phydev->link) {
> -		if ((pp->speed != phydev->speed) ||
> -		    (pp->duplex != phydev->duplex)) {
> -			u32 val;
> +	if (phydev->link &&
> +	    (pp->speed != phydev->speed || pp->duplex != phydev->duplex)) {
> +		u32 val;
>   
> -			val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
> -			val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
> -				 MVNETA_GMAC_CONFIG_GMII_SPEED |
> -				 MVNETA_GMAC_CONFIG_FULL_DUPLEX |
> -				 MVNETA_GMAC_AN_SPEED_EN |
> -				 MVNETA_GMAC_AN_DUPLEX_EN);
> +		val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
> +		val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
> +			 MVNETA_GMAC_CONFIG_GMII_SPEED |
> +			 MVNETA_GMAC_CONFIG_FULL_DUPLEX |
> +			 MVNETA_GMAC_AN_SPEED_EN |
> +			 MVNETA_GMAC_AN_DUPLEX_EN);
>   
> -			if (phydev->duplex)
> -				val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
> +		if (phydev->duplex)
> +			val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
>   
> -			if (phydev->speed == SPEED_1000)
> -				val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
> -			else if (pp->speed == SPEED_100)
> -				val |= MVNETA_GMAC_CONFIG_MII_SPEED;
> +		if (phydev->speed == SPEED_1000)
> +			val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
> +		else if (pp->speed == SPEED_100)
> +			val |= MVNETA_GMAC_CONFIG_MII_SPEED;
>   
> -			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
> +		mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
>   
> -			pp->duplex = phydev->duplex;
> -			pp->speed  = phydev->speed;
> -		}
> +		pp->duplex = phydev->duplex;
> +		pp->speed  = phydev->speed;
>   	}
>   
>   	if (phydev->link != pp->link) {

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable
  2022-04-27 10:41 ` [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable Marek Behún
  2022-04-30 23:29   ` Ramon Fried
@ 2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:01 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Use the bool type instead of int for status_change variable.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 66d5e10174..7d582c1206 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1154,7 +1154,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>   {
>   	struct mvneta_port *pp = dev_get_priv(dev);
>   	struct phy_device *phydev = pp->phydev;
> -	int status_change = 0;
> +	bool status_change = false;
>   
>   	if (pp->fixed_link) {
>   		debug("Using fixed link, skip link adjust\n");
> @@ -1193,7 +1193,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>   		}
>   
>   		pp->link = phydev->link;
> -		status_change = 1;
> +		status_change = true;
>   	}
>   
>   	if (status_change) {

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space
  2022-04-27 10:41 ` [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space Marek Behún
  2022-04-30 23:30   ` Ramon Fried
@ 2022-05-02  7:01   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:01 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Drop unnecessary space in mvneta_adjust_link().
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 7d582c1206..5c3f7125b5 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1183,7 +1183,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>   		mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
>   
>   		pp->duplex = phydev->duplex;
> -		pp->speed  = phydev->speed;
> +		pp->speed = phydev->speed;
>   	}
>   
>   	if (phydev->link != pp->link) {

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB
  2022-04-27 10:41 ` [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB Marek Behún
  2022-04-30 23:30   ` Ramon Fried
@ 2022-05-02  7:02   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:02 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Drop checking for CONFIG_PHYLIB in mvneta, this is already done in
> Kconfig.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 5c3f7125b5..0ec9d2957c 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -40,10 +40,6 @@
>   
>   DECLARE_GLOBAL_DATA_PTR;
>   
> -#if !defined(CONFIG_PHYLIB)
> -# error Marvell mvneta requires PHYLIB
> -#endif
> -
>   #define CONFIG_NR_CPUS		1
>   #define ETH_HLEN		14	/* Total octets in header */
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS
  2022-04-27 10:41 ` [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS Marek Behún
  2022-04-30 23:30   ` Ramon Fried
@ 2022-05-02  7:02   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:02 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> The CONFIG_* macros are reserved for Kconfig. This was probably done
> when this driver was being imported from Linux. Rename the macro.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 0ec9d2957c..519e06ff01 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -40,7 +40,7 @@
>   
>   DECLARE_GLOBAL_DATA_PTR;
>   
> -#define CONFIG_NR_CPUS		1
> +#define MVNETA_NR_CPUS		1
>   #define ETH_HLEN		14	/* Total octets in header */
>   
>   /* 2(HW hdr) 14(MAC hdr) 4(CRC) 32(extra for cache prefetch) */
> @@ -770,7 +770,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>   	/* Set CPU queue access map - all CPUs have access to all RX
>   	 * queues and to all TX queues
>   	 */
> -	for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++)
> +	for (cpu = 0; cpu < MVNETA_NR_CPUS; cpu++)
>   		mvreg_write(pp, MVNETA_CPU_MAP(cpu),
>   			    (MVNETA_CPU_RXQ_ACCESS_ALL_MASK |
>   			     MVNETA_CPU_TXQ_ACCESS_ALL_MASK));

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link
  2022-04-27 10:41 ` [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link Marek Behún
  2022-04-30 23:31   ` Ramon Fried
@ 2022-05-02  7:02   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:02 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Stop parsing fixed-link in the MAC driver. Instead support only PHY mode
> and let the fixed PHY driver handle the fixed-link case.
> 
> Enable CONFIG_PHY_FIXED for mvneta boards that need it: Turris Omnia and
> ESPRESSObin.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   configs/mvebu_espressobin-88f3720_defconfig |  1 +
>   configs/turris_omnia_defconfig              |  1 +
>   drivers/net/mvneta.c                        | 98 ++++++++-------------
>   3 files changed, 39 insertions(+), 61 deletions(-)
> 
> diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig
> index 37e4fdc41e..8d7d57ff1b 100644
> --- a/configs/mvebu_espressobin-88f3720_defconfig
> +++ b/configs/mvebu_espressobin-88f3720_defconfig
> @@ -74,6 +74,7 @@ CONFIG_SPI_FLASH_STMICRO=y
>   CONFIG_SPI_FLASH_WINBOND=y
>   CONFIG_SPI_FLASH_MTD=y
>   CONFIG_PHY_MARVELL=y
> +CONFIG_PHY_FIXED=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_E1000=y
>   CONFIG_MVNETA=y
> diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
> index 6b218bd7a7..bdd70f2ba7 100644
> --- a/configs/turris_omnia_defconfig
> +++ b/configs/turris_omnia_defconfig
> @@ -79,6 +79,7 @@ CONFIG_SPI_FLASH_MACRONIX=y
>   CONFIG_SPI_FLASH_SPANSION=y
>   CONFIG_SPI_FLASH_MTD=y
>   CONFIG_PHY_MARVELL=y
> +CONFIG_PHY_FIXED=y
>   CONFIG_PHY_GIGE=y
>   CONFIG_MVNETA=y
>   CONFIG_MII=y
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 519e06ff01..5b1c4fe5fc 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -1152,11 +1152,6 @@ static void mvneta_adjust_link(struct udevice *dev)
>   	struct phy_device *phydev = pp->phydev;
>   	bool status_change = false;
>   
> -	if (pp->fixed_link) {
> -		debug("Using fixed link, skip link adjust\n");
> -		return;
> -	}
> -
>   	if (phydev->link &&
>   	    (pp->speed != phydev->speed || pp->duplex != phydev->duplex)) {
>   		u32 val;
> @@ -1168,6 +1163,21 @@ static void mvneta_adjust_link(struct udevice *dev)
>   			 MVNETA_GMAC_AN_SPEED_EN |
>   			 MVNETA_GMAC_AN_DUPLEX_EN);
>   
> +		/* FIXME: For fixed-link case, these were the initial settings
> +		 * used before the code was converted to use PHY_FIXED. Some of
> +		 * these may look nonsensical (for example BYPASS_AN makes sense
> +		 * for 1000base-x and 2500base-x modes, AFAIK), and in fact this
> +		 * may be changed in the future (when support for inband AN will
> +		 * be added). Also, why is ADVERT_FC enabled if we don't enable
> +		 * inband AN at all?
> +		 */
> +		if (pp->fixed_link)
> +			val = MVNETA_GMAC_FORCE_LINK_UP |
> +			      MVNETA_GMAC_IB_BYPASS_AN_EN |
> +			      MVNETA_GMAC_SET_FC_EN |
> +			      MVNETA_GMAC_ADVERT_FC_EN |
> +			      MVNETA_GMAC_SAMPLE_TX_CFG_EN;
> +
>   		if (phydev->duplex)
>   			val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
>   
> @@ -1413,56 +1423,34 @@ static int mvneta_start(struct udevice *dev)
>   	mvneta_port_power_up(pp, pp->phy_interface);
>   
>   	if (!pp->init || pp->link == 0) {
> -		if (pp->fixed_link) {
> -			u32 val;
> -
> -			pp->init = 1;
> -			pp->link = 1;
> -			mvneta_init(dev);
> -
> -			val = MVNETA_GMAC_FORCE_LINK_UP |
> -			      MVNETA_GMAC_IB_BYPASS_AN_EN |
> -			      MVNETA_GMAC_SET_FC_EN |
> -			      MVNETA_GMAC_ADVERT_FC_EN |
> -			      MVNETA_GMAC_SAMPLE_TX_CFG_EN;
> -
> -			if (pp->duplex)
> -				val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
> -
> -			if (pp->speed == SPEED_1000)
> -				val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
> -			else if (pp->speed == SPEED_100)
> -				val |= MVNETA_GMAC_CONFIG_MII_SPEED;
> +		phydev = dm_eth_phy_connect(dev);
> +		if (!phydev) {
> +			printf("dm_eth_phy_connect failed\n");
> +			return -ENODEV;
> +		}
>   
> -			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
> -		} else {
> -			phydev = dm_eth_phy_connect(dev);
> -			if (!phydev) {
> -				printf("dm_eth_phy_connect failed\n");
> -				return -ENODEV;
> -			}
> +		pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
>   
> -			/* Set PHY address in case we will enable HW polling */
> +		/* Set PHY address in case we will enable HW polling */
> +		if (!pp->fixed_link)
>   			mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
>   
> -			pp->phydev = phydev;
> -			phy_config(phydev);
> -			phy_startup(phydev);
> -			if (!phydev->link) {
> -				printf("%s: No link.\n", phydev->dev->name);
> -				return -1;
> -			}
> -
> -			/* Full init on first call */
> -			mvneta_init(dev);
> -			pp->init = 1;
> -			return 0;
> +		pp->phydev = phydev;
> +		phy_config(phydev);
> +		phy_startup(phydev);
> +		if (!phydev->link) {
> +			printf("%s: No link.\n", phydev->dev->name);
> +			return -1;
>   		}
> -	}
>   
> -	/* Upon all following calls, this is enough */
> -	mvneta_port_up(pp);
> -	mvneta_port_enable(pp);
> +		/* Full init on first call */
> +		mvneta_init(dev);
> +		pp->init = 1;
> +	} else {
> +		/* Upon all following calls, this is enough */
> +		mvneta_port_up(pp);
> +		mvneta_port_enable(pp);
> +	}
>   
>   	return 0;
>   }
> @@ -1560,10 +1548,7 @@ static int mvneta_probe(struct udevice *dev)
>   #if CONFIG_IS_ENABLED(DM_GPIO)
>   	struct ofnode_phandle_args sfp_args;
>   #endif
> -	void *blob = (void *)gd->fdt_blob;
> -	int node = dev_of_offset(dev);
>   	void *bd_space;
> -	int fl_node;
>   
>   	/*
>   	 * Allocate buffer area for descs and rx_buffers. This is only
> @@ -1600,15 +1585,6 @@ static int mvneta_probe(struct udevice *dev)
>   	else
>   		mvneta_conf_mbus_windows(pp);
>   
> -	/* fetch 'fixed-link' property from 'neta' node */
> -	fl_node = fdt_subnode_offset(blob, node, "fixed-link");
> -	if (fl_node != -FDT_ERR_NOTFOUND) {
> -		/* set phy_addr to invalid value for fixed link */
> -		pp->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex");
> -		pp->speed = fdtdec_get_int(blob, fl_node, "speed", 0);
> -		pp->fixed_link = true;
> -	}
> -
>   #if CONFIG_IS_ENABLED(DM_GPIO)
>   	if (!dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args) &&
>   	    ofnode_is_enabled(sfp_args.node))

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling
  2022-04-27 10:41 ` [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling Marek Behún
  2022-04-30 23:31   ` Ramon Fried
@ 2022-05-02  7:03   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:03 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Write PHY address just before enabling HW polling of the PHY.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 5b1c4fe5fc..4917857681 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -814,6 +814,8 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>   
>   	/* Enable PHY polling in hardware if not in fixed-link mode */
>   	if (!pp->fixed_link) {
> +		mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
> +
>   		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
>   		val |= MVNETA_PHY_POLLING_ENABLE;
>   		mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
> @@ -1431,10 +1433,6 @@ static int mvneta_start(struct udevice *dev)
>   
>   		pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
>   
> -		/* Set PHY address in case we will enable HW polling */
> -		if (!pp->fixed_link)
> -			mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr);
> -
>   		pp->phydev = phydev;
>   		phy_config(phydev);
>   		phy_startup(phydev);

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct
  2022-04-27 10:42 ` [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct Marek Behún
  2022-04-30 23:31   ` Ramon Fried
@ 2022-05-02  7:03   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:03 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:42, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Since this member is checked only at two places drop it and inline it's
> usage.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 4917857681..378789b632 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -273,7 +273,6 @@ struct mvneta_port {
>   	u16 rx_ring_size;
>   
>   	phy_interface_t phy_interface;
> -	bool fixed_link;
>   	unsigned int link;
>   	unsigned int duplex;
>   	unsigned int speed;
> @@ -813,7 +812,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>   	mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
>   
>   	/* Enable PHY polling in hardware if not in fixed-link mode */
> -	if (!pp->fixed_link) {
> +	if (pp->phydev->phy_id != PHY_FIXED_ID) {
>   		mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
>   
>   		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
> @@ -1173,7 +1172,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>   		 * be added). Also, why is ADVERT_FC enabled if we don't enable
>   		 * inband AN at all?
>   		 */
> -		if (pp->fixed_link)
> +		if (pp->phydev->phy_id == PHY_FIXED_ID)
>   			val = MVNETA_GMAC_FORCE_LINK_UP |
>   			      MVNETA_GMAC_IB_BYPASS_AN_EN |
>   			      MVNETA_GMAC_SET_FC_EN |
> @@ -1431,8 +1430,6 @@ static int mvneta_start(struct udevice *dev)
>   			return -ENODEV;
>   		}
>   
> -		pp->fixed_link = phydev->phy_id == PHY_FIXED_ID;
> -
>   		pp->phydev = phydev;
>   		phy_config(phydev);
>   		phy_startup(phydev);

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in
  2022-04-27 10:42 ` [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in Marek Behún
  2022-04-30 23:32   ` Ramon Fried
@ 2022-05-02  7:03   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:03 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:42, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Guard the code handling the fixed PHY case by
> CONFIG_IS_ENABLED(PHY_FIXED).
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 378789b632..292c364e5e 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -812,7 +812,8 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
>   	mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
>   
>   	/* Enable PHY polling in hardware if not in fixed-link mode */
> -	if (pp->phydev->phy_id != PHY_FIXED_ID) {
> +	if (!CONFIG_IS_ENABLED(PHY_FIXED) ||
> +	    pp->phydev->phy_id != PHY_FIXED_ID) {
>   		mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
>   
>   		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
> @@ -1172,7 +1173,8 @@ static void mvneta_adjust_link(struct udevice *dev)
>   		 * be added). Also, why is ADVERT_FC enabled if we don't enable
>   		 * inband AN at all?
>   		 */
> -		if (pp->phydev->phy_id == PHY_FIXED_ID)
> +		if (CONFIG_IS_ENABLED(PHY_FIXED) &&
> +		    pp->phydev->phy_id == PHY_FIXED_ID)
>   			val = MVNETA_GMAC_FORCE_LINK_UP |
>   			      MVNETA_GMAC_IB_BYPASS_AN_EN |
>   			      MVNETA_GMAC_SET_FC_EN |

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro
  2022-04-27 10:42 ` [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro Marek Behún
  2022-04-30 23:32   ` Ramon Fried
@ 2022-05-02  7:03   ` Stefan Roese
  1 sibling, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-02  7:03 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún

On 27.04.22 12:42, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Macro MVNETA_GMAC_FORCE_LINK_UP can be dropped from value assignment in
> fixed link case, since it's value is written into the register later in
> the function for link-down-to-link-up case. The value is written as
> MVNETA_GMAC_FORCE_LINK_DOWN | MVNETA_GMAC_FORCE_LINK_PASS, and so the
> macro definition can also be dropped.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan


> ---
>   drivers/net/mvneta.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
> index 292c364e5e..d2c42c4396 100644
> --- a/drivers/net/mvneta.c
> +++ b/drivers/net/mvneta.c
> @@ -188,7 +188,6 @@ DECLARE_GLOBAL_DATA_PTR;
>   #define MVNETA_GMAC_AUTONEG_CONFIG               0x2c0c
>   #define      MVNETA_GMAC_FORCE_LINK_DOWN         BIT(0)
>   #define      MVNETA_GMAC_FORCE_LINK_PASS         BIT(1)
> -#define      MVNETA_GMAC_FORCE_LINK_UP           (BIT(0) | BIT(1))
>   #define      MVNETA_GMAC_IB_BYPASS_AN_EN         BIT(3)
>   #define      MVNETA_GMAC_CONFIG_MII_SPEED        BIT(5)
>   #define      MVNETA_GMAC_CONFIG_GMII_SPEED       BIT(6)
> @@ -1175,8 +1174,7 @@ static void mvneta_adjust_link(struct udevice *dev)
>   		 */
>   		if (CONFIG_IS_ENABLED(PHY_FIXED) &&
>   		    pp->phydev->phy_id == PHY_FIXED_ID)
> -			val = MVNETA_GMAC_FORCE_LINK_UP |
> -			      MVNETA_GMAC_IB_BYPASS_AN_EN |
> +			val = MVNETA_GMAC_IB_BYPASS_AN_EN |
>   			      MVNETA_GMAC_SET_FC_EN |
>   			      MVNETA_GMAC_ADVERT_FC_EN |
>   			      MVNETA_GMAC_SAMPLE_TX_CFG_EN;

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes
  2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
                   ` (19 preceding siblings ...)
  2022-05-02  5:39 ` [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Stefan Roese
@ 2022-05-04  9:25 ` Stefan Roese
  20 siblings, 0 replies; 58+ messages in thread
From: Stefan Roese @ 2022-05-04  9:25 UTC (permalink / raw)
  To: Marek Behún
  Cc: Robert Marko, Pali Rohár, U-Boot-Denx, Ramon Fried,
	Joe Hershberger, Marek Behún, Chris Packham,
	Heinrich Schuchardt, Konstantin Porotchkin, Mario Six,
	Mark Kettenis, Phil Sutter, Rogier Stam, Simon Glass,
	Vladimir Oltean, Vladimir Vid

On 27.04.22 12:41, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Hello Stefan,
> 
> here come some refactors, cleanups and fixed for the mvneta driver.
> 
> Marek Behún (19):
>    net: mvneta: Get rid of platdata
>    net: mvneta: Fix 10Mbps speed
>    net: mvneta: Use DM MDIO API for connecting PHY
>    net: mvneta: Remember fixed link instead of PHY address in priv data
>    arm: mvebu: Espressobin: Use DM registered MDIO to configure switch
>    net: mdio-uclass: add dm_phy_find_by_ofnode() helper
>    arm: mvebu: turris_mox: Use DM registered MDIO
>    net: mvneta: Don't register MDIO bus
>    net: mvneta: Fix unused variable warning if DM_GPIO is disabled
>    net: mvneta: Drop one indentation level in mvneta_adjust_link()
>    net: mvneta: Use bool instead of int for boolean variable
>    net: mvneta: Drop unnecessary space
>    net: mventa: Don't check for CONFIG_PHYLIB
>    net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS
>    net: mvneta: Convert to use PHY_FIXED for fixed-link
>    net: mvneta: Write PHY address just before enabling HW polling
>    net: mvneta: Drop fixed_link member from private struct
>    net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in
>    net: mvneta: Drop unneeded macro
> 
>   .../dts/armada-3720-turris-mox-u-boot.dtsi    |  19 -
>   board/CZ.NIC/turris_mox/turris_mox.c          |  88 ++---
>   board/Marvell/mvebu_armada-37xx/board.c       |  26 +-
>   configs/clearfog_defconfig                    |   1 +
>   configs/controlcenterdc_defconfig             |   1 +
>   configs/db-88f6820-amc_defconfig              |   1 +
>   configs/db-88f6820-gp_defconfig               |   1 +
>   configs/db-mv784mp-gp_defconfig               |   1 +
>   configs/ds414_defconfig                       |   1 +
>   configs/helios4_defconfig                     |   1 +
>   configs/maxbcm_defconfig                      |   1 +
>   configs/mvebu_espressobin-88f3720_defconfig   |   3 +
>   configs/theadorable_debug_defconfig           |   1 +
>   configs/turris_mox_defconfig                  |   1 +
>   configs/turris_omnia_defconfig                |   2 +
>   configs/uDPU_defconfig                        |   1 +
>   drivers/net/Kconfig                           |   1 +
>   drivers/net/mvneta.c                          | 343 ++++--------------
>   include/miiphy.h                              |   9 +
>   net/mdio-uclass.c                             |  22 ++
>   20 files changed, 181 insertions(+), 343 deletions(-)
> 

Applied to u-boot-marvell/master

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2022-05-04  9:25 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
2022-04-27 10:41 ` [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 05/19] arm: mvebu: Espressobin: Use DM registered MDIO to configure switch Marek Behún
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  7:00   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 07/19] arm: mvebu: turris_mox: Use DM registered MDIO Marek Behún
2022-05-02  7:00   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus Marek Behún
2022-04-30 23:29   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled Marek Behún
2022-04-30 23:29   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link() Marek Behún
2022-04-30 23:29   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable Marek Behún
2022-04-30 23:29   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space Marek Behún
2022-04-30 23:30   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB Marek Behún
2022-04-30 23:30   ` Ramon Fried
2022-05-02  7:02   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS Marek Behún
2022-04-30 23:30   ` Ramon Fried
2022-05-02  7:02   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link Marek Behún
2022-04-30 23:31   ` Ramon Fried
2022-05-02  7:02   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling Marek Behún
2022-04-30 23:31   ` Ramon Fried
2022-05-02  7:03   ` Stefan Roese
2022-04-27 10:42 ` [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct Marek Behún
2022-04-30 23:31   ` Ramon Fried
2022-05-02  7:03   ` Stefan Roese
2022-04-27 10:42 ` [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in Marek Behún
2022-04-30 23:32   ` Ramon Fried
2022-05-02  7:03   ` Stefan Roese
2022-04-27 10:42 ` [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro Marek Behún
2022-04-30 23:32   ` Ramon Fried
2022-05-02  7:03   ` Stefan Roese
2022-05-02  5:39 ` [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Stefan Roese
2022-05-04  9:25 ` Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.