All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: mdiobus: add fwnode_phy_is_fixed_link()
@ 2022-10-09 16:20 Soha Jin
  2022-10-10 15:03 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Soha Jin @ 2022-10-09 16:20 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Russell King, netdev, linux-kernel, Soha Jin

A helper function to check if PHY is fixed link with fwnode properties.
This is similar to of_phy_is_fixed_link.

Signed-off-by: Soha Jin <soha@lohu.info>
---
 drivers/net/mdio/fwnode_mdio.c | 30 +++++++++++++++++++++++++++++-
 include/linux/fwnode_mdio.h    |  2 ++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index 689e728345ce..8e1773e4d304 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -6,8 +6,9 @@
  * out of the fwnode and using it to populate an mii_bus.
  */
 
-#include <linux/acpi.h>
 #include <linux/fwnode_mdio.h>
+#include <linux/property.h>
+#include <linux/acpi.h>
 #include <linux/of.h>
 #include <linux/phy.h>
 #include <linux/pse-pd/pse.h>
@@ -183,3 +184,30 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 	return rc;
 }
 EXPORT_SYMBOL(fwnode_mdiobus_register_phy);
+
+bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode)
+{
+	struct fwnode_handle *dn;
+	int err;
+	const char *managed;
+
+	/* New binding: 'fixed-link' is a sub-node of the Ethernet device. */
+	dn = fwnode_get_named_child_node(fwnode, "fixed-link");
+	if (dn) {
+		fwnode_handle_put(dn);
+		return true;
+	}
+
+	err = fwnode_property_read_string(fwnode, "managed", &managed);
+	if (err == 0 && strcmp(managed, "auto") != 0)
+		return true;
+
+	/* Old binding: 'fixed-link' was a property with 5 cells encoding
+	 * various information about the fixed PHY.
+	 */
+	if (fwnode_property_count_u32(fwnode, "fixed-link") == 5)
+		return true;
+
+	return false;
+}
+EXPORT_SYMBOL(fwnode_phy_is_fixed_link);
diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
index faf603c48c86..f35e447e524a 100644
--- a/include/linux/fwnode_mdio.h
+++ b/include/linux/fwnode_mdio.h
@@ -32,4 +32,6 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 }
 #endif
 
+bool fwnode_phy_is_fixed_link(struct fwnode_handle *fwnode);
+
 #endif /* __LINUX_FWNODE_MDIO_H */
-- 
2.30.2


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

* Re: [PATCH] net: mdiobus: add fwnode_phy_is_fixed_link()
  2022-10-09 16:20 [PATCH] net: mdiobus: add fwnode_phy_is_fixed_link() Soha Jin
@ 2022-10-10 15:03 ` Andrew Lunn
  2022-10-10 15:44   ` Soha Jin
  2022-10-10 16:43   ` Russell King (Oracle)
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Lunn @ 2022-10-10 15:03 UTC (permalink / raw)
  To: Soha Jin
  Cc: Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Russell King, netdev, linux-kernel

On Mon, Oct 10, 2022 at 12:20:06AM +0800, Soha Jin wrote:
> A helper function to check if PHY is fixed link with fwnode properties.
> This is similar to of_phy_is_fixed_link.

You need to include a user of this new function.

Also, not that ACPI only defines the 'new binding' for fixed-link.  If
this is being called on a device which is ACPI underneath, it should
only return true for the 'new binding', not the old binding.

     Andrew

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

* RE: [PATCH] net: mdiobus: add fwnode_phy_is_fixed_link()
  2022-10-10 15:03 ` Andrew Lunn
@ 2022-10-10 15:44   ` Soha Jin
  2022-10-10 16:43   ` Russell King (Oracle)
  1 sibling, 0 replies; 5+ messages in thread
From: Soha Jin @ 2022-10-10 15:44 UTC (permalink / raw)
  To: 'Andrew Lunn'
  Cc: 'Heiner Kallweit', 'David S. Miller',
	'Eric Dumazet', 'Jakub Kicinski',
	'Paolo Abeni', 'Russell King',
	netdev, linux-kernel

Hello Andrew,

> From: Andrew Lunn <andrew@lunn.ch>
> Sent: Monday, October 10, 2022 11:03 PM
> 
> On Mon, Oct 10, 2022 at 12:20:06AM +0800, Soha Jin wrote:
> > A helper function to check if PHY is fixed link with fwnode properties.
> > This is similar to of_phy_is_fixed_link.
> 
> You need to include a user of this new function.

Greg already notified me about this. I was thinking this patch and my
driver patches are on different trees, so I split the patches into
different parts. I will include this patch in my driver patch's v2 later
and ask you to review then. Sorry for the mistake.

> Also, not that ACPI only defines the 'new binding' for fixed-link.  If this is
> being called on a device which is ACPI underneath, it should only return true
> for the 'new binding', not the old binding.

Thanks for the information, I will correct this.

Regards,
Soha


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

* Re: [PATCH] net: mdiobus: add fwnode_phy_is_fixed_link()
  2022-10-10 15:03 ` Andrew Lunn
  2022-10-10 15:44   ` Soha Jin
@ 2022-10-10 16:43   ` Russell King (Oracle)
  2022-10-10 16:52     ` Andrew Lunn
  1 sibling, 1 reply; 5+ messages in thread
From: Russell King (Oracle) @ 2022-10-10 16:43 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Soha Jin, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel

On Mon, Oct 10, 2022 at 05:03:27PM +0200, Andrew Lunn wrote:
> On Mon, Oct 10, 2022 at 12:20:06AM +0800, Soha Jin wrote:
> > A helper function to check if PHY is fixed link with fwnode properties.
> > This is similar to of_phy_is_fixed_link.
> 
> You need to include a user of this new function.
> 
> Also, not that ACPI only defines the 'new binding' for fixed-link.  If
> this is being called on a device which is ACPI underneath, it should
> only return true for the 'new binding', not the old binding.

Do we want to support the "managed" property in the fwnode variant,
or persuade people to switch to phylink if they want that?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH] net: mdiobus: add fwnode_phy_is_fixed_link()
  2022-10-10 16:43   ` Russell King (Oracle)
@ 2022-10-10 16:52     ` Andrew Lunn
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2022-10-10 16:52 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Soha Jin, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel

On Mon, Oct 10, 2022 at 05:43:07PM +0100, Russell King (Oracle) wrote:
> On Mon, Oct 10, 2022 at 05:03:27PM +0200, Andrew Lunn wrote:
> > On Mon, Oct 10, 2022 at 12:20:06AM +0800, Soha Jin wrote:
> > > A helper function to check if PHY is fixed link with fwnode properties.
> > > This is similar to of_phy_is_fixed_link.
> > 
> > You need to include a user of this new function.
> > 
> > Also, not that ACPI only defines the 'new binding' for fixed-link.  If
> > this is being called on a device which is ACPI underneath, it should
> > only return true for the 'new binding', not the old binding.
> 
> Do we want to support the "managed" property in the fwnode variant,
> or persuade people to switch to phylink if they want that?

managed has been documented in
Documentation/firmware-guide/acpi/dsd/phy.rst so i think we need to
support it.

	Andrew

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

end of thread, other threads:[~2022-10-10 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-09 16:20 [PATCH] net: mdiobus: add fwnode_phy_is_fixed_link() Soha Jin
2022-10-10 15:03 ` Andrew Lunn
2022-10-10 15:44   ` Soha Jin
2022-10-10 16:43   ` Russell King (Oracle)
2022-10-10 16:52     ` Andrew Lunn

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.