diff mbox series

[v1,2/2] net: arc: rockchip: fix emac mdio node support

Message ID f04c2cfd-d2d6-4dc6-91a5-0ed1d1155171@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v1,1/2] ethernet: arc: fix the device for dma_map_single/dma_unmap_single | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: andrew+netdev@lunn.ch
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 4 this patch: 4
netdev/source_inline success Was 0 now: 0

Commit Message

Johan Jonker Oct. 27, 2024, 9:42 a.m. UTC
The binding emac_rockchip.txt is converted to YAML.
Changed against the original binding is an added MDIO subnode.
Fix emac_mdio.c so that it can handle both old and new
device trees.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/net/ethernet/arc/emac_mdio.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--
2.39.2

Comments

Andy Yan Oct. 27, 2024, 9:58 a.m. UTC | #1
Hello Johan,
    Thanks for your patch.  Maybe we need a Fixes tag here?
    And for the patch itself:
  
   Tested-by: Andy Yan <andyshrk@163.com>

At 2024-10-27 17:42:45, "Johan Jonker" <jbx6244@gmail.com> wrote:
>The binding emac_rockchip.txt is converted to YAML.
>Changed against the original binding is an added MDIO subnode.
>Fix emac_mdio.c so that it can handle both old and new
>device trees.
>
>Signed-off-by: Johan Jonker <jbx6244@gmail.com>
>---
> drivers/net/ethernet/arc/emac_mdio.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/ethernet/arc/emac_mdio.c b/drivers/net/ethernet/arc/emac_mdio.c
>index 87f40c2ba904..078b1a72c161 100644
>--- a/drivers/net/ethernet/arc/emac_mdio.c
>+++ b/drivers/net/ethernet/arc/emac_mdio.c
>@@ -133,6 +133,7 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
> 	struct arc_emac_mdio_bus_data *data = &priv->bus_data;
> 	struct device_node *np = priv->dev->of_node;
> 	const char *name = "Synopsys MII Bus";
>+	struct device_node *mdio_node;
> 	struct mii_bus *bus;
> 	int error;
>
>@@ -164,7 +165,13 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
>
> 	snprintf(bus->id, MII_BUS_ID_SIZE, "%s", bus->name);
>
>-	error = of_mdiobus_register(bus, priv->dev->of_node);
>+	/* Backwards compatibility for EMAC nodes without MDIO subnode. */
>+	mdio_node = of_get_child_by_name(np, "mdio");
>+	if (!mdio_node)
>+		mdio_node = of_node_get(np);
>+
>+	error = of_mdiobus_register(bus, mdio_node);
>+	of_node_put(mdio_node);
> 	if (error) {
> 		mdiobus_free(bus);
> 		return dev_err_probe(priv->dev, error,
>--
>2.39.2
>
>
>_______________________________________________
>Linux-rockchip mailing list
>Linux-rockchip@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-rockchip
Andrew Lunn Oct. 28, 2024, 12:59 p.m. UTC | #2
> Hello Johan,
>     Thanks for your patch.  Maybe we need a Fixes tag here?

What is actually broken?

	Andrew
Andy Yan Oct. 29, 2024, 8:22 a.m. UTC | #3
Hi Andrew,

At 2024-10-28 20:59:18, "Andrew Lunn" <andrew@lunn.ch> wrote:
>> Hello Johan,
>>     Thanks for your patch.  Maybe we need a Fixes tag here?
>
>What is actually broken?

The emac failed to probe after bellow patch merged.

 [    2.324583] loop: module loaded
    [    2.328435] SPI driver spidev has no spi_device_id for rockchip,spidev
    [    2.338688] tun: Universal TUN/TAP device driver, 1.6
    [    2.345397] rockchip_emac 10200000.ethernet: no regulator found
    [    2.351892] rockchip_emac 10200000.ethernet: ARC EMAC detected with id: 0x7fd02
    [    2.359331] rockchip_emac 10200000.ethernet: IRQ is 43
    [    2.364719] rockchip_emac 10200000.ethernet: MAC address is now e6:58:d6:ec:d9:7c
    [    2.396993] mdio_bus Synopsys MII Bus: mdio has invalid PHY address
    [    2.403306] mdio_bus Synopsys MII Bus: scan phy mdio at address 0
    [    2.508656] rockchip_emac 10200000.ethernet: of_phy_connect() failed
    [    2.516334] rockchip_emac 10200000.ethernet: failed to probe arc emac (-19)


commit 1dabb74971b38d966ecef566bafddc4a34f4db9d
Author: Johan Jonker <jbx6244@gmail.com>
Date:   Fri Jun 3 18:35:39 2022 +0200

    ARM: dts: rockchip: restyle emac nodes
    
    The emac_rockchip.txt file is converted to YAML.
    Phy nodes are now a subnode of mdio, so restyle
    the emac nodes of rk3036/rk3066/rk3188.
    
    Signed-off-by: Johan Jonker <jbx6244@gmail.com>
    Link: https://lore.kernel.org/r/20220603163539.537-3-jbx6244@gmail.com
    Signed-off-by: Heiko Stuebner <heiko@sntech.de>

>
>	Andrew
>
>_______________________________________________
>Linux-rockchip mailing list
>Linux-rockchip@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-rockchip
Andrew Lunn Oct. 29, 2024, 12:46 p.m. UTC | #4
On Tue, Oct 29, 2024 at 04:22:16PM +0800, Andy Yan wrote:
> 
> Hi Andrew,
> 
> At 2024-10-28 20:59:18, "Andrew Lunn" <andrew@lunn.ch> wrote:
> >> Hello Johan,
> >>     Thanks for your patch.  Maybe we need a Fixes tag here?
> >
> >What is actually broken?
> 
> The emac failed to probe after bellow patch merged.
> 
>  [    2.324583] loop: module loaded
>     [    2.328435] SPI driver spidev has no spi_device_id for rockchip,spidev
>     [    2.338688] tun: Universal TUN/TAP device driver, 1.6
>     [    2.345397] rockchip_emac 10200000.ethernet: no regulator found
>     [    2.351892] rockchip_emac 10200000.ethernet: ARC EMAC detected with id: 0x7fd02
>     [    2.359331] rockchip_emac 10200000.ethernet: IRQ is 43
>     [    2.364719] rockchip_emac 10200000.ethernet: MAC address is now e6:58:d6:ec:d9:7c
>     [    2.396993] mdio_bus Synopsys MII Bus: mdio has invalid PHY address
>     [    2.403306] mdio_bus Synopsys MII Bus: scan phy mdio at address 0
>     [    2.508656] rockchip_emac 10200000.ethernet: of_phy_connect() failed
>     [    2.516334] rockchip_emac 10200000.ethernet: failed to probe arc emac (-19)

So it is failing to find the PHY, and given the 'mdio has invalid PHY
address' it is probably looking in the wrong node.

The commit message should explain this.

	Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/arc/emac_mdio.c b/drivers/net/ethernet/arc/emac_mdio.c
index 87f40c2ba904..078b1a72c161 100644
--- a/drivers/net/ethernet/arc/emac_mdio.c
+++ b/drivers/net/ethernet/arc/emac_mdio.c
@@ -133,6 +133,7 @@  int arc_mdio_probe(struct arc_emac_priv *priv)
 	struct arc_emac_mdio_bus_data *data = &priv->bus_data;
 	struct device_node *np = priv->dev->of_node;
 	const char *name = "Synopsys MII Bus";
+	struct device_node *mdio_node;
 	struct mii_bus *bus;
 	int error;

@@ -164,7 +165,13 @@  int arc_mdio_probe(struct arc_emac_priv *priv)

 	snprintf(bus->id, MII_BUS_ID_SIZE, "%s", bus->name);

-	error = of_mdiobus_register(bus, priv->dev->of_node);
+	/* Backwards compatibility for EMAC nodes without MDIO subnode. */
+	mdio_node = of_get_child_by_name(np, "mdio");
+	if (!mdio_node)
+		mdio_node = of_node_get(np);
+
+	error = of_mdiobus_register(bus, mdio_node);
+	of_node_put(mdio_node);
 	if (error) {
 		mdiobus_free(bus);
 		return dev_err_probe(priv->dev, error,