public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix bridge gmii2rgmii
@ 2025-01-22  9:22 Tapio Reijonen
  2025-01-22  9:22 ` [PATCH v2 1/2] net: phy: Let gmiitorgmii converter create additional PHY Tapio Reijonen
  2025-01-22  9:22 ` [PATCH v2 2/2] net: phy: gmii2rgmii: Add support for phy ethernet id configuration Tapio Reijonen
  0 siblings, 2 replies; 4+ messages in thread
From: Tapio Reijonen @ 2025-01-22  9:22 UTC (permalink / raw)
  To: u-boot
  Cc: Tapio Reijonen, Eugeniu Rosca, Heinrich Schuchardt, Jacky Chou,
	Joe Hershberger, Marek Vasut, Michal Simek, Ramon Fried,
	T Karthik Reddy, Tom Rini


When taken in use U-Boot v2023.04 one our board's ethernet stop to work in U-Boot,
which was working in v2022.01.

In v2022.01 the gmii2rgmii was called before PHY was created.

This patch change back the order and fix the problem. Also the ethernet-phy-id
driver is taken in use in gmii2rgmii driver.

(no changes since v1)

Tapio Reijonen (2):
  net: phy: Let gmiitorgmii converter create additional PHY
  net: phy: gmii2rgmii: Add support for phy ethernet id configuration

 drivers/net/phy/phy.c               |  8 ++++----
 drivers/net/phy/xilinx_gmii2rgmii.c | 12 +++++++++---
 2 files changed, 13 insertions(+), 7 deletions(-)

-- 
2.39.5


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

* [PATCH v2 1/2] net: phy: Let gmiitorgmii converter create additional PHY
  2025-01-22  9:22 [PATCH v2 0/2] Fix bridge gmii2rgmii Tapio Reijonen
@ 2025-01-22  9:22 ` Tapio Reijonen
  2025-01-22 13:57   ` Michal Simek
  2025-01-22  9:22 ` [PATCH v2 2/2] net: phy: gmii2rgmii: Add support for phy ethernet id configuration Tapio Reijonen
  1 sibling, 1 reply; 4+ messages in thread
From: Tapio Reijonen @ 2025-01-22  9:22 UTC (permalink / raw)
  To: u-boot
  Cc: Tapio Reijonen, Eugeniu Rosca, Heinrich Schuchardt, Jacky Chou,
	Joe Hershberger, Marek Vasut, Michal Simek, Ramon Fried,
	T Karthik Reddy, Tom Rini

Change the order to connect gmiitorgmii before PHY creation.
The gmiitorgmii create additional in DTS configured PHY during
it's configuration. This ensures, that converter sits between the
MAC and the external phy
MAC <==> GMII2RGMII <==> RGMII_PHY.

Fixes: a744a284e354 ("net: phy: Add support for ethernet-phy-id with gpio reset")
Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>

---

(no changes since v1)

---
 drivers/net/phy/phy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 716a1d461115..740533adecac 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -939,14 +939,14 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
 		phydev = phy_device_create(bus, 0, PHY_NCSI_ID, false);
 #endif
 
-#ifdef CONFIG_PHY_ETHERNET_ID
+#ifdef CONFIG_PHY_XILINX_GMII2RGMII
 	if (!phydev)
-		phydev = phy_connect_phy_id(bus, dev, addr);
+		phydev = phy_connect_gmii2rgmii(bus, dev);
 #endif
 
-#ifdef CONFIG_PHY_XILINX_GMII2RGMII
+#ifdef CONFIG_PHY_ETHERNET_ID
 	if (!phydev)
-		phydev = phy_connect_gmii2rgmii(bus, dev);
+		phydev = phy_connect_phy_id(bus, dev, addr);
 #endif
 
 	if (!phydev)
-- 
2.39.5


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

* [PATCH v2 2/2] net: phy: gmii2rgmii: Add support for phy ethernet id configuration
  2025-01-22  9:22 [PATCH v2 0/2] Fix bridge gmii2rgmii Tapio Reijonen
  2025-01-22  9:22 ` [PATCH v2 1/2] net: phy: Let gmiitorgmii converter create additional PHY Tapio Reijonen
@ 2025-01-22  9:22 ` Tapio Reijonen
  1 sibling, 0 replies; 4+ messages in thread
From: Tapio Reijonen @ 2025-01-22  9:22 UTC (permalink / raw)
  To: u-boot
  Cc: Tapio Reijonen, Joe Hershberger, Michal Simek, Ramon Fried,
	T Karthik Reddy, Tom Rini

When Kconfig PHY_ETHERNET_ID is set, create external PHY using via
ethernet-phy-id driver to support using strapping resistors
of the external PHY.

Fixes: a744a284e354 ("net: phy: Add support for ethernet-phy-id with gpio reset")
Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
---

Changes in v2:
  - Fixing inside 80 chars per line

---
 drivers/net/phy/xilinx_gmii2rgmii.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
index e44b7b75bd58..d860f4c37856 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -18,7 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static int xilinxgmiitorgmii_config(struct phy_device *phydev)
 {
 	ofnode node = phy_get_ofnode(phydev);
-	struct phy_device *ext_phydev;
+	struct phy_device *ext_phydev = NULL;
 	struct ofnode_phandle_args phandle;
 	int ext_phyaddr = -1;
 	int ret;
@@ -40,8 +40,14 @@ static int xilinxgmiitorgmii_config(struct phy_device *phydev)
 		return ret;
 
 	ext_phyaddr = ofnode_read_u32_default(phandle.node, "reg", -1);
-	ext_phydev = phy_find_by_mask(phydev->bus,
-				      1 << ext_phyaddr);
+
+	if (IS_ENABLED(CONFIG_PHY_ETHERNET_ID))
+		ext_phydev = phy_connect_phy_id(phydev->bus, phydev->dev,
+						ext_phyaddr);
+
+	if (!ext_phydev)
+		ext_phydev = phy_find_by_mask(phydev->bus,
+					      1 << ext_phyaddr);
 	if (!ext_phydev) {
 		printf("%s, No external phy device found\n", __func__);
 		return -EINVAL;
-- 
2.39.5


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

* Re: [PATCH v2 1/2] net: phy: Let gmiitorgmii converter create additional PHY
  2025-01-22  9:22 ` [PATCH v2 1/2] net: phy: Let gmiitorgmii converter create additional PHY Tapio Reijonen
@ 2025-01-22 13:57   ` Michal Simek
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2025-01-22 13:57 UTC (permalink / raw)
  To: Tapio Reijonen, u-boot
  Cc: Eugeniu Rosca, Heinrich Schuchardt, Jacky Chou, Joe Hershberger,
	Marek Vasut, Ramon Fried, T Karthik Reddy, Tom Rini



On 1/22/25 10:22, Tapio Reijonen wrote:
> Change the order to connect gmiitorgmii before PHY creation.
> The gmiitorgmii create additional in DTS configured PHY during
> it's configuration. This ensures, that converter sits between the
> MAC and the external phy
> MAC <==> GMII2RGMII <==> RGMII_PHY.

as I said please extend commit message to describe reasons behind this and using 
that dt config as you use.

> 
> Fixes: a744a284e354 ("net: phy: Add support for ethernet-phy-id with gpio reset")

And we can discuss if this is a fix of this commit. It is more or less 
workaround for Linux kernel limitation and not actual fix. Because with correct 
DT binding existing code should work.
Obviously correct way to handle it would be to fix Linux kernel driver not to 
convince U-Boot to use Linux kernel dt binding.

M

> Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
> 
> ---
> 
> (no changes since v1)
> 
> ---
>   drivers/net/phy/phy.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 716a1d461115..740533adecac 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -939,14 +939,14 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
>   		phydev = phy_device_create(bus, 0, PHY_NCSI_ID, false);
>   #endif
>   
> -#ifdef CONFIG_PHY_ETHERNET_ID
> +#ifdef CONFIG_PHY_XILINX_GMII2RGMII
>   	if (!phydev)
> -		phydev = phy_connect_phy_id(bus, dev, addr);
> +		phydev = phy_connect_gmii2rgmii(bus, dev);
>   #endif
>   
> -#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> +#ifdef CONFIG_PHY_ETHERNET_ID
>   	if (!phydev)
> -		phydev = phy_connect_gmii2rgmii(bus, dev);
> +		phydev = phy_connect_phy_id(bus, dev, addr);
>   #endif
>   
>   	if (!phydev)


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

end of thread, other threads:[~2025-01-22 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22  9:22 [PATCH v2 0/2] Fix bridge gmii2rgmii Tapio Reijonen
2025-01-22  9:22 ` [PATCH v2 1/2] net: phy: Let gmiitorgmii converter create additional PHY Tapio Reijonen
2025-01-22 13:57   ` Michal Simek
2025-01-22  9:22 ` [PATCH v2 2/2] net: phy: gmii2rgmii: Add support for phy ethernet id configuration Tapio Reijonen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox