public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 1/3] mdio-uclass.c: support fixed-link subnodes
Date: Tue, 6 Oct 2020 08:02:31 +0200	[thread overview]
Message-ID: <d24f577b-bd8a-2c53-ffa1-c03a0cd20773@denx.de> (raw)
In-Reply-To: <20201005131518.10289-2-rasmus.villemoes@prevas.dk>

Hello Rasmus,

Am 05.10.2020 um 15:15 schrieb Rasmus Villemoes:
> When trying to port our mpc8309-based board to DM_ETH, on top of
> Heiko's patches, I found that nothing in mdio-uclass.c seems to
> support the use of a fixed-link subnode of the ethernet DT node. That
> is, the ethernet node looks like
> 
> 		enet0: ethernet at 2000 {
> 			device_type = "network";
> 			compatible = "ucc_geth";
> 			...
> 			fixed-link {
> 				reg = <0xffffffff>;
> 				speed = <100>;
> 				full-duplex;
> 			};
> 
> but the current code expects there to be phy-handle property. Adding
> that, i.e.
> 
> 			phy-handle = <&enet0phy>;
> 			enet0phy: fixed-link {
> 
> just makes the code break a few lines later since a fixed-link node
> doesn't have a reg property. Ignoring the dtc complaint and adding a
> dummy reg property, we of course hit "can't find MDIO bus for node
> ethernet at 2000" since indeed, the parent node of the phy node does not
> represent an MDIO bus. So that's obviously the wrong path.
> 
> Now, in linux, it seems that the fixed link case is treated specially;
> in the of_phy_get_and_connect() which roughly corresponds to
> dm_eth_connect_phy_handle() we have
> 
>      if (of_phy_is_fixed_link(np)) {
>          ret = of_phy_register_fixed_link(np);
>          ...
>      } else {
>          phy_np = of_parse_phandle(np, "phy-handle", 0);
> 	...
>      }
> 
>      phy = of_phy_connect(dev, phy_np, hndlr, 0, iface);
> 
> And U-Boot's phy_connect() does have support for fixed-link
> subnodes. Calling phy_connect() directly with NULL bus and a dummy
> address does seem to make the ethernet work.
> 
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
>   net/mdio-uclass.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
> index 66ee2e1976..2f932b77df 100644
> --- a/net/mdio-uclass.c
> +++ b/net/mdio-uclass.c
> @@ -139,6 +139,12 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
>   	struct ofnode_phandle_args phandle = {.node = ofnode_null()};
>   	int i;
>   
> +	if (CONFIG_IS_ENABLED(PHY_FIXED) &&
> +	    ofnode_valid(dev_read_subnode(ethdev, "fixed-link"))) {
> +		phy = phy_connect(NULL, -1, ethdev, interface);
> +		goto out;
> +	}
> +
>   	for (i = 0; i < PHY_HANDLE_STR_CNT; i++)
>   		if (!dev_read_phandle_with_args(ethdev, phy_handle_str[i], NULL,
>   						0, 0, &phandle))
> @@ -168,6 +174,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
>   
>   	phy = dm_mdio_phy_connect(mdiodev, phy_addr, ethdev, interface);
>   
> +out:
>   	if (phy)
>   		phy->node = phandle.node;

Looks good to me... but I am not an expert in net subsystem...
nevertheless:

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

  reply	other threads:[~2020-10-06  6:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05 13:15 [PATCH 0/3] DM_ETH v mpc83xx fixups Rasmus Villemoes
2020-10-05 13:15 ` [PATCH 1/3] mdio-uclass.c: support fixed-link subnodes Rasmus Villemoes
2020-10-06  6:02   ` Heiko Schocher [this message]
2020-10-06  6:21     ` Rasmus Villemoes
2021-02-22 17:32   ` Tom Rini
2020-10-05 13:15 ` [PATCH 2/3] dm_qe_uec.c: fix indentation in uec_set_mac_if_mode() Rasmus Villemoes
2020-10-06  6:03   ` Heiko Schocher
2021-02-22 17:32   ` Tom Rini
2020-10-05 13:15 ` [PATCH 3/3] uec.h: fix COFIG_DM typo Rasmus Villemoes
2020-10-06  6:03   ` Heiko Schocher
2021-02-22 17:32   ` Tom Rini
2020-10-06  6:14 ` [PATCH 0/3] DM_ETH v mpc83xx fixups Heiko Schocher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d24f577b-bd8a-2c53-ffa1-c03a0cd20773@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox