Skip to contentSkip to conversation

net: dwc_eth_qos_rockchip: Fix use of mii/mdio commands

PATCH In review Jonas Karlman 2 participants 4 messages Oct 4 – Oct 9

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

cover net: dwc_eth_qos_rockchip: Fix use of mii/mdio commands

This series fixes two reset control related issues with of the Rockchip variant of the dwc_eth_qos.

First patch relaxes dependency on DM_RESET being enabled, reset driver being fully implemented or resets being defined in DT, e.g. during SoC bringup.

Second patch changes how reset controls are asserted/deasserted to allow use of mii/mdio commands when network stack is in stopped state.

This has been tested on a few different Rockchip SoCs using dwc_eth_eos driver without any noticeable effect, beside mii/mdio commands working.

Jonas Karlman (2):
net: dwc_eth_qos_rockchip: Relax dependency on reset controls
net: dwc_eth_qos_rockchip: Do not keep reset controls asserted

 drivers/net/dwc_eth_qos_rockchip.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/2 net: dwc_eth_qos_rockchip: Relax dependency on reset controls

The GMAC typically does not need to be reset prior to being operational.

Remove the strict dependency on reset controls and DM_RESET being enabled to and allow GMAC to probe without any reset controls being defined in DT or the existence of a fully functional reset driver during SoC bringup.

---
 drivers/net/dwc_eth_qos_rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dwc_eth_qos_rockchip.c +1 -1
index 4ccefda0ef5e..04bc6006bc3c 100644
@@ -744,7 +744,7 @@ static int eqos_probe_resources_rk(struct udevice *dev)
 	}
 
 	ret = reset_get_bulk(dev, &data->resets);
-	if (ret < 0)
+	if (ret && ret != -ENOENT && ret != -ENOTSUPP)
 		goto err_free;
 
 	reset_assert_bulk(&data->resets);
Signature · 1 line
2.55.0
#2 lore raw

PATCH 2/2 net: dwc_eth_qos_rockchip: Do not keep reset controls asserted

In reply to Jonas Karlman

Communication with Ethernet PHYs over MDIO does not work when reset controls are held in asserted state. This prevents i.e. the mdio/mii commands from working, unless the network stack is in running state.

Change to only assert the reset controls for a short period when the network stack is starting to allow for the mdio/mii commands to work.

With reset controls held asserted (before):

=> mdio read 1
PHY at address 1:
1 - 0x0

=> mii info
PHY 0x00: OUI = 0x0000, Model = 0x00, Rev = 0x00, 10baseT, HDX [...]
PHY 0x1F: OUI = 0x0000, Model = 0x00, Rev = 0x00, 10baseT, HDX

With reset controls not helt asserted (after):

=> mdio read 1
PHY at address 1:
1 - 0x7989

=> mii info
PHY 0x00: OUI = 0x0732, Model = 0x11, Rev = 0x06, 10baseT, HDX PHY 0x01: OUI = 0x0732, Model = 0x11, Rev = 0x06, 10baseT, HDX

---
 drivers/net/dwc_eth_qos_rockchip.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/net/dwc_eth_qos_rockchip.c +7 -10
index 04bc6006bc3c..78623ed78fb0 100644
@@ -747,8 +747,6 @@ static int eqos_probe_resources_rk(struct udevice *dev)
 	if (ret && ret != -ENOENT && ret != -ENOTSUPP)
 		goto err_free;
 
-	reset_assert_bulk(&data->resets);
-
 	ret = clk_get_by_name(dev, "stmmaceth", &eqos->clk_master_bus);
 	if (ret) {
 		dev_dbg(dev, "clk_get_by_name(stmmaceth) failed: %d", ret);
@@ -803,18 +801,17 @@ static int eqos_remove_resources_rk(struct udevice *dev)
 	return 0;
 }
 
-static int eqos_stop_resets_rk(struct udevice *dev)
+static int eqos_start_resets_rk(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct rockchip_platform_data *data = pdata->priv_pdata;
+	int ret;
 
-	return reset_assert_bulk(&data->resets);
-}
+	ret = reset_assert_bulk(&data->resets);
+	if (ret)
+		return ret;
 
-static int eqos_start_resets_rk(struct udevice *dev)
-{
-	struct eth_pdata *pdata = dev_get_plat(dev);
-	struct rockchip_platform_data *data = pdata->priv_pdata;
+	udelay(10);
 
 	return reset_deassert_bulk(&data->resets);
 }
@@ -891,7 +888,7 @@ static struct eqos_ops eqos_rockchip_ops = {
 	.eqos_flush_buffer = eqos_flush_buffer_generic,
 	.eqos_probe_resources = eqos_probe_resources_rk,
 	.eqos_remove_resources = eqos_remove_resources_rk,
-	.eqos_stop_resets = eqos_stop_resets_rk,
+	.eqos_stop_resets = eqos_null_ops,
 	.eqos_start_resets = eqos_start_resets_rk,
 	.eqos_stop_clks = eqos_stop_clks_rk,
 	.eqos_start_clks = eqos_start_clks_rk,
Signature · 1 line
2.55.0
#3 lore raw
In reply to Jonas Karlman
Quoted 8 lines · Jonas Karlman

This series fixes two reset control related issues with of the Rockchip variant of the dwc_eth_qos.

First patch relaxes dependency on DM_RESET being enabled, reset driver being fully implemented or resets being defined in DT, e.g. during SoC bringup.

[...]

Applied to u-boot-net branch for-next, thanks!

[1/2] net: dwc_eth_qos_rockchip: Relax dependency on reset controls

      commit: f45285fdc8634c554713d2e22efb036d00f0581a
[2/2] net: dwc_eth_qos_rockchip: Do not keep reset controls asserted
      commit: 61e9a2abbf1364dfe0205edfa1be0e9e676eb4a4

Best regards,

Signature · 1 line
Jerome Forissier <[email protected]>