All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] net: sun8i_emac: Test the correct phy
@ 2019-07-19 20:26 Emmanuel Vadot
  2019-07-23  0:02 ` Joe Hershberger
  2019-07-25 18:43 ` [U-Boot] " Joe Hershberger
  0 siblings, 2 replies; 3+ messages in thread
From: Emmanuel Vadot @ 2019-07-19 20:26 UTC (permalink / raw)
  To: u-boot

H3/H5 can either use the internal phy or an external one.
Before getting clock and resets for the internal phy,
test that we are using it because otherwise it break emac
when using an external phy.

Tested-on: OrangePi PC2 (H5)
Fixes: 2348453c41 (net: sun8i_emac: Add EPHY CLK and RESET support)
Signed-off-by: Emmanuel Vadot <manu@freebsd.org>
---
 drivers/net/sun8i_emac.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index c0a440886e..0629b16e57 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -846,31 +846,44 @@ static const struct eth_ops sun8i_emac_eth_ops = {
 
 static int sun8i_get_ephy_nodes(struct emac_eth_dev *priv)
 {
-	int node, ret;
+	int emac_node, ephy_node, ret, ephy_handle;
+
+	emac_node = fdt_path_offset(gd->fdt_blob,
+				    "/soc/ethernet at 1c30000");
+	if (emac_node < 0) {
+		debug("failed to get emac node\n");
+		return emac_node;
+	}
+	ephy_handle = fdtdec_lookup_phandle(gd->fdt_blob,
+					    emac_node, "phy-handle");
 
 	/* look for mdio-mux node for internal PHY node */
-	node = fdt_path_offset(gd->fdt_blob,
-			"/soc/ethernet at 1c30000/mdio-mux/mdio at 1/ethernet-phy at 1");
-	if (node < 0) {
+	ephy_node = fdt_path_offset(gd->fdt_blob,
+				    "/soc/ethernet at 1c30000/mdio-mux/mdio at 1/ethernet-phy at 1");
+	if (ephy_node < 0) {
 		debug("failed to get mdio-mux with internal PHY\n");
-		return node;
+		return ephy_node;
 	}
 
-	ret = fdt_node_check_compatible(gd->fdt_blob, node,
+	/* This is not the phy we are looking for */
+	if (ephy_node != ephy_handle)
+		return 0;
+
+	ret = fdt_node_check_compatible(gd->fdt_blob, ephy_node,
 					"allwinner,sun8i-h3-mdio-internal");
 	if (ret < 0) {
 		debug("failed to find mdio-internal node\n");
 		return ret;
 	}
 
-	ret = clk_get_by_index_nodev(offset_to_ofnode(node), 0,
+	ret = clk_get_by_index_nodev(offset_to_ofnode(ephy_node), 0,
 				     &priv->ephy_clk);
 	if (ret) {
 		dev_err(dev, "failed to get EPHY TX clock\n");
 		return ret;
 	}
 
-	ret = reset_get_by_index_nodev(offset_to_ofnode(node), 0,
+	ret = reset_get_by_index_nodev(offset_to_ofnode(ephy_node), 0,
 				       &priv->ephy_rst);
 	if (ret) {
 		dev_err(dev, "failed to get EPHY TX reset\n");
-- 
2.22.0

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

* [U-Boot] [PATCH] net: sun8i_emac: Test the correct phy
  2019-07-19 20:26 [U-Boot] [PATCH] net: sun8i_emac: Test the correct phy Emmanuel Vadot
@ 2019-07-23  0:02 ` Joe Hershberger
  2019-07-25 18:43 ` [U-Boot] " Joe Hershberger
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Hershberger @ 2019-07-23  0:02 UTC (permalink / raw)
  To: u-boot

On Fri, Jul 19, 2019 at 3:27 PM Emmanuel Vadot <manu@freebsd.org> wrote:
>
> H3/H5 can either use the internal phy or an external one.
> Before getting clock and resets for the internal phy,
> test that we are using it because otherwise it break emac
> when using an external phy.
>
> Tested-on: OrangePi PC2 (H5)
> Fixes: 2348453c41 (net: sun8i_emac: Add EPHY CLK and RESET support)
> Signed-off-by: Emmanuel Vadot <manu@freebsd.org>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

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

* [U-Boot] net: sun8i_emac: Test the correct phy
  2019-07-19 20:26 [U-Boot] [PATCH] net: sun8i_emac: Test the correct phy Emmanuel Vadot
  2019-07-23  0:02 ` Joe Hershberger
@ 2019-07-25 18:43 ` Joe Hershberger
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Hershberger @ 2019-07-25 18:43 UTC (permalink / raw)
  To: u-boot

Hi Emmanuel,

https://patchwork.ozlabs.org/patch/1134275/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe

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

end of thread, other threads:[~2019-07-25 18:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 20:26 [U-Boot] [PATCH] net: sun8i_emac: Test the correct phy Emmanuel Vadot
2019-07-23  0:02 ` Joe Hershberger
2019-07-25 18:43 ` [U-Boot] " Joe Hershberger

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.