From c62b74652a330b09e2157b6ebc1f4d9ea3cec254 Mon Sep 17 00:00:00 2001
From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Date: Thu, 12 May 2022 09:33:07 +0200
Subject: [PATCH] net: dwc_eth_qos: remove use of DWC_NET_PHYADDR

Only two boards in the tree set the macro DWC_NET_PHYADDR. Both have
CONFIG_DM_ETH_PHY=y, so should set the phy address in DT if necessary.

The imx8mp_evk does set the correct address in device tree.

The other board seems to be a copy-paste-adapt from an old
version of the imx8mp_evk config header, given the "#ifdef
CONFIG_DWC_ETH_QOS" block that has been removed from imx8mp_evk header
in commit 127fb454955. Its device tree doesn't even enable (i.e., set
'status = "okay"') the &eqos node. But the other ethernet device,
&fec, does get enabled, and does have a phy sitting at address 4 (and
it also has a corresponding legacy #define CONFIG_FEC_MXC_PHYADDR
4). So I believe it should be completely safe to remove it from there
as well.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
[trini: Re-apply to top of tree, update imx93_evk.h]
Signed-off-by: Tom Rini <trini@konsulko.com>
---
 drivers/net/dwc_eth_qos.c        | 3 ---
 include/configs/imx8mp_evk.h     | 2 --
 include/configs/imx8mp_rsb3720.h | 1 -
 include/configs/imx93_evk.h      | 1 -
 4 files changed, 7 deletions(-)

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 4f3ea4f629..43af7d91f8 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -789,9 +789,6 @@ static int eqos_start(struct udevice *dev)
 	if (!eqos->phy) {
 		int addr = -1;
 		addr = eqos_get_phy_addr(eqos, dev);
-#ifdef DWC_NET_PHYADDR
-		addr = DWC_NET_PHYADDR;
-#endif
 		eqos->phy = phy_connect(eqos->mii, addr, dev,
 					eqos->config->interface(dev));
 		if (!eqos->phy) {
diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h
index 5581c0fac0..388f3bc9ff 100644
--- a/include/configs/imx8mp_evk.h
+++ b/include/configs/imx8mp_evk.h
@@ -24,8 +24,6 @@
 #if defined(CONFIG_CMD_NET)
 #define CONFIG_FEC_MXC_PHYADDR          1
 
-#define DWC_NET_PHYADDR			1
-
 #define PHY_ANEG_TIMEOUT 20000
 
 #endif
diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h
index 17e00f958b..ddc035ae22 100644
--- a/include/configs/imx8mp_rsb3720.h
+++ b/include/configs/imx8mp_rsb3720.h
@@ -42,7 +42,6 @@
 #if defined(CONFIG_CMD_NET)
 #define CONFIG_FEC_MXC_PHYADDR          4
 
-#define DWC_NET_PHYADDR			4
 #ifdef CONFIG_DWC_ETH_QOS
 #define CONFIG_SYS_NONCACHED_MEMORY     (1 * SZ_1M)     /* 1M */
 #endif
diff --git a/include/configs/imx93_evk.h b/include/configs/imx93_evk.h
index 21f85f59b2..f9750da580 100644
--- a/include/configs/imx93_evk.h
+++ b/include/configs/imx93_evk.h
@@ -138,7 +138,6 @@
 #define WDOG_BASE_ADDR          WDG3_BASE_ADDR
 
 #if defined(CONFIG_CMD_NET)
-#define DWC_NET_PHYADDR			1
 #define PHY_ANEG_TIMEOUT 20000
 #endif
 
-- 
2.39.5