diff mbox series

[3/3] net: dwc_eth_qos: set proper DT node for phy device

Message ID 20220512073309.2073608-4-rasmus.villemoes@prevas.dk
State Changes Requested
Delegated to: Tom Rini
Headers show
Series dwc_eth_qos PHY dt node fixups | expand

Commit Message

Rasmus Villemoes May 12, 2022, 7:33 a.m. UTC
Similar to what was done for the FEC driver in commit
89b5bd54c1a4 (net: fec: Allow the PHY node to be retrieved), make sure
the PHY is associated with the right device tree node, so that phy
specific DT properties is accessible by the phy driver.

This is required on a custom iMX8MP board with a ti,dp83867 phy
sitting in front of the eqos interface.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/net/dwc_eth_qos.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Ramon Fried May 16, 2022, 12:31 a.m. UTC | #1
On Thu, May 12, 2022 at 10:35 AM Rasmus Villemoes
<rasmus.villemoes@prevas.dk> wrote:
>
> Similar to what was done for the FEC driver in commit
> 89b5bd54c1a4 (net: fec: Allow the PHY node to be retrieved), make sure
> the PHY is associated with the right device tree node, so that phy
> specific DT properties is accessible by the phy driver.
>
> This is required on a custom iMX8MP board with a ti,dp83867 phy
> sitting in front of the eqos interface.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
>  drivers/net/dwc_eth_qos.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
> index 27b3f98e0e..af35960b42 100644
> --- a/drivers/net/dwc_eth_qos.c
> +++ b/drivers/net/dwc_eth_qos.c
> @@ -1078,9 +1078,11 @@ static int eqos_start(struct udevice *dev)
>          * don't need to reconnect/reconfigure again
>          */
>         if (!eqos->phy) {
> +               ofnode phy_node = ofnode_null();
>                 int addr = -1;
> +
>  #ifdef CONFIG_DM_ETH_PHY
> -               addr = eth_phy_get_addr(dev);
> +               addr = eth_phy_get_node_and_addr(dev, &phy_node);
>  #endif
>                 eqos->phy = phy_connect(eqos->mii, addr, dev,
>                                         eqos->config->interface(dev));
> @@ -1088,6 +1090,8 @@ static int eqos_start(struct udevice *dev)
>                         pr_err("phy_connect() failed");
>                         goto err_stop_resets;
>                 }
> +               if (ofnode_valid(phy_node))
> +                       eqos->phy->node = phy_node;
>
>                 if (eqos->max_speed) {
>                         ret = phy_set_supported(eqos->phy, eqos->max_speed);
> --
> 2.31.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Tom Rini Aug. 8, 2022, 7:07 p.m. UTC | #2
On Thu, May 12, 2022 at 09:33:09AM +0200, Rasmus Villemoes wrote:

> Similar to what was done for the FEC driver in commit
> 89b5bd54c1a4 (net: fec: Allow the PHY node to be retrieved), make sure
> the PHY is associated with the right device tree node, so that phy
> specific DT properties is accessible by the phy driver.
> 
> This is required on a custom iMX8MP board with a ti,dp83867 phy
> sitting in front of the eqos interface.
> 
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
> ---
>  drivers/net/dwc_eth_qos.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
> index 27b3f98e0e..af35960b42 100644
> --- a/drivers/net/dwc_eth_qos.c
> +++ b/drivers/net/dwc_eth_qos.c
> @@ -1078,9 +1078,11 @@ static int eqos_start(struct udevice *dev)
>  	 * don't need to reconnect/reconfigure again
>  	 */
>  	if (!eqos->phy) {
> +		ofnode phy_node = ofnode_null();
>  		int addr = -1;
> +
>  #ifdef CONFIG_DM_ETH_PHY
> -		addr = eth_phy_get_addr(dev);
> +		addr = eth_phy_get_node_and_addr(dev, &phy_node);
>  #endif
>  		eqos->phy = phy_connect(eqos->mii, addr, dev,
>  					eqos->config->interface(dev));
> @@ -1088,6 +1090,8 @@ static int eqos_start(struct udevice *dev)
>  			pr_err("phy_connect() failed");
>  			goto err_stop_resets;
>  		}
> +		if (ofnode_valid(phy_node))
> +			eqos->phy->node = phy_node;
>  
>  		if (eqos->max_speed) {
>  			ret = phy_set_supported(eqos->phy, eqos->max_speed);

I'm deferring 2/3 and now for 3/3, given a6acf95508e2 ("net: eqos: add
function to get phy node and address") (which yes, sigh, came after your
series but has been applied already, sorry) I don't see the obvious way
to migrate the changes in without testing. If needed still, can you
please rebase and resend? Thanks.
Rasmus Villemoes Aug. 9, 2022, 10:50 a.m. UTC | #3
On 08/08/2022 21.07, Tom Rini wrote:
> On Thu, May 12, 2022 at 09:33:09AM +0200, Rasmus Villemoes wrote:
> 
>> Similar to what was done for the FEC driver in commit
>> 89b5bd54c1a4 (net: fec: Allow the PHY node to be retrieved), make sure
>> the PHY is associated with the right device tree node, so that phy
>> specific DT properties is accessible by the phy driver.
>>
>> This is required on a custom iMX8MP board with a ti,dp83867 phy
>> sitting in front of the eqos interface.
>>
>> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
>> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

> 
> I'm deferring 2/3 and now for 3/3, given a6acf95508e2 ("net: eqos: add
> function to get phy node and address") (which yes, sigh, came after your
> series but has been applied already, sorry) I don't see the obvious way
> to migrate the changes in without testing. If needed still, can you
> please rebase and resend? Thanks.
> 
Well, I have/had other changes on top that I didn't want to send before
this series went in, and those were a bit annoying to rebase. But
a6acf95508e2 does seem to achieve what 2/3+3/3 did, so those can be
dropped. Thanks for applying the other patches.

<moderate grumpiness>

However, we now have one more copy of more or less the exact same code,
so there's certainly an opportunity for somebody to do something like
2/3 and make both fec_mxc.c, dwc_eth_qos.c and probably others use such
a helper.

And on the subject of duplicate functionality with perhaps ever so
slightly different semantics, it's impressive that we have at least

  reset-delay-us/reset-post-delay-us
  reset-assert-us/reset-deassert-us
  phy-reset-duration/phy-reset-post-delay

making it hard to figure out what setting is honored in which contexts.

Oh well.

</moderate grumpiness>

Rasmus
diff mbox series

Patch

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 27b3f98e0e..af35960b42 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -1078,9 +1078,11 @@  static int eqos_start(struct udevice *dev)
 	 * don't need to reconnect/reconfigure again
 	 */
 	if (!eqos->phy) {
+		ofnode phy_node = ofnode_null();
 		int addr = -1;
+
 #ifdef CONFIG_DM_ETH_PHY
-		addr = eth_phy_get_addr(dev);
+		addr = eth_phy_get_node_and_addr(dev, &phy_node);
 #endif
 		eqos->phy = phy_connect(eqos->mii, addr, dev,
 					eqos->config->interface(dev));
@@ -1088,6 +1090,8 @@  static int eqos_start(struct udevice *dev)
 			pr_err("phy_connect() failed");
 			goto err_stop_resets;
 		}
+		if (ofnode_valid(phy_node))
+			eqos->phy->node = phy_node;
 
 		if (eqos->max_speed) {
 			ret = phy_set_supported(eqos->phy, eqos->max_speed);