All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe
@ 2020-09-10 11:43 Vikas Singh
  2020-09-10 13:12 ` Andrew Lunn
  2020-09-10 14:44 ` Jakub Kicinski
  0 siblings, 2 replies; 4+ messages in thread
From: Vikas Singh @ 2020-09-10 11:43 UTC (permalink / raw)
  To: andrew, f.fainelli, hkallweit1, linux, netdev
  Cc: calvin.johnson, kuldip.dwivedi, madalin.bucur, vikas.singh, Vikas Singh

The function referred to (of_mdiobus_link_mdiodev()) is only built when
CONFIG_OF_MDIO is enabled, which is again, a DT specific thing, and would
not work in case of ACPI.
Given that it is a static function so renamed of_mdiobus_link_mdiodev()
as mdiobus_link_mdiodev() and did necessary changes, finally moved it out
of the #ifdef(CONFIG_OF_MDIO) therefore make it work for both DT & ACPI.

Signed-off-by: Vikas Singh <vikas.singh@puresoftware.com>
---

Notes:
    - Add generic handling for "fwnode" and "of_node".
    - Remove duplicate loops.

 drivers/net/phy/mdio_bus.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 46b3370..b0faa95 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -434,6 +434,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
 	return d ? to_mii_bus(d) : NULL;
 }
 EXPORT_SYMBOL(of_mdio_find_bus);
+#endif
 
 /* Walk the list of subnodes of a mdio bus and look for a node that
  * matches the mdio device's address with its 'reg' property. If
@@ -441,35 +442,37 @@ EXPORT_SYMBOL(of_mdio_find_bus);
  * auto-probed phy devices to be supplied with information passed in
  * via DT.
  */
-static void of_mdiobus_link_mdiodev(struct mii_bus *bus,
-				    struct mdio_device *mdiodev)
+static void mdiobus_link_mdiodev(struct mii_bus *bus,
+				 struct mdio_device *mdiodev)
 {
 	struct device *dev = &mdiodev->dev;
-	struct device_node *child;
+	struct fwnode_handle *child;
+	int addr;
 
-	if (dev->of_node || !bus->dev.of_node)
+	if (dev->fwnode || !bus->dev.fwnode) {
+		pr_err("PHY fwnode is not available on bus for registration\n");
 		return;
+	}
 
-	for_each_available_child_of_node(bus->dev.of_node, child) {
-		int addr;
+	device_for_each_child_node(&bus->dev, child) {
+		if (!fwnode_device_is_available(child))
+			continue;
 
-		addr = of_mdio_parse_addr(dev, child);
-		if (addr < 0)
+		if (is_of_node(child)) {
+			addr = of_mdio_parse_addr(dev, to_of_node(child));
+			if (addr < 0)
+				continue;
+		} else if (fwnode_property_read_u32(child, "reg", &addr))
 			continue;
 
 		if (addr == mdiodev->addr) {
-			dev->of_node = child;
-			dev->fwnode = of_fwnode_handle(child);
-			return;
+			dev->of_node = to_of_node(child);
+			dev->fwnode = child;
+			break;
 		}
 	}
+	return;
 }
-#else /* !IS_ENABLED(CONFIG_OF_MDIO) */
-static inline void of_mdiobus_link_mdiodev(struct mii_bus *mdio,
-					   struct mdio_device *mdiodev)
-{
-}
-#endif
 
 /**
  * mdiobus_create_device_from_board_info - create a full MDIO device given
@@ -688,10 +691,10 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
 		return phydev;
 
 	/*
-	 * For DT, see if the auto-probed phy has a correspoding child
-	 * in the bus node, and set the of_node pointer in this case.
+	 * See if the auto-probed phy has a corresponding child
+	 * in the bus node, and set the of_node & fwnode pointers.
 	 */
-	of_mdiobus_link_mdiodev(bus, &phydev->mdio);
+	mdiobus_link_mdiodev(bus, &phydev->mdio);
 
 	err = phy_device_register(phydev);
 	if (err) {
-- 
2.7.4


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

* Re: [PATCH v2] net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe
  2020-09-10 11:43 [PATCH v2] net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe Vikas Singh
@ 2020-09-10 13:12 ` Andrew Lunn
  2020-09-16 15:08   ` Vikas Singh
  2020-09-10 14:44 ` Jakub Kicinski
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2020-09-10 13:12 UTC (permalink / raw)
  To: Vikas Singh
  Cc: f.fainelli, hkallweit1, linux, netdev, calvin.johnson,
	kuldip.dwivedi, madalin.bucur, vikas.singh

On Thu, Sep 10, 2020 at 05:13:03PM +0530, Vikas Singh wrote:
> The function referred to (of_mdiobus_link_mdiodev()) is only built when
> CONFIG_OF_MDIO is enabled, which is again, a DT specific thing, and would
> not work in case of ACPI.

Vikas

How are you describing the MDIO bus in ACPI? Do you have a proposed
standard document for submission to UEFI?

	 Andrew

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

* Re: [PATCH v2] net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe
  2020-09-10 11:43 [PATCH v2] net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe Vikas Singh
  2020-09-10 13:12 ` Andrew Lunn
@ 2020-09-10 14:44 ` Jakub Kicinski
  1 sibling, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2020-09-10 14:44 UTC (permalink / raw)
  To: Vikas Singh
  Cc: andrew, f.fainelli, hkallweit1, linux, netdev, calvin.johnson,
	kuldip.dwivedi, madalin.bucur, vikas.singh

On Thu, 10 Sep 2020 17:13:03 +0530 Vikas Singh wrote:
> The function referred to (of_mdiobus_link_mdiodev()) is only built when
> CONFIG_OF_MDIO is enabled, which is again, a DT specific thing, and would
> not work in case of ACPI.
> Given that it is a static function so renamed of_mdiobus_link_mdiodev()
> as mdiobus_link_mdiodev() and did necessary changes, finally moved it out
> of the #ifdef(CONFIG_OF_MDIO) therefore make it work for both DT & ACPI.
> 
> Signed-off-by: Vikas Singh <vikas.singh@puresoftware.com>

nit:

CHECK: braces {} should be used on all arms of this statement
#60: FILE: drivers/net/phy/mdio_bus.c:461:
+		if (is_of_node(child)) {
[...]
+		} else if (fwnode_property_read_u32(child, "reg", &addr))
[...]

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

* Re: [PATCH v2] net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe
  2020-09-10 13:12 ` Andrew Lunn
@ 2020-09-16 15:08   ` Vikas Singh
  0 siblings, 0 replies; 4+ messages in thread
From: Vikas Singh @ 2020-09-16 15:08 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: f.fainelli, hkallweit1, Russell King - ARM Linux admin, netdev,
	Calvin Johnson (OSS), Kuldip Dwivedi, Madalin Bucur (OSS),
	Vikas Singh, Arokia Samy, Varun Sethi

On Thu, Sep 10, 2020 at 6:42 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Thu, Sep 10, 2020 at 05:13:03PM +0530, Vikas Singh wrote:
> > The function referred to (of_mdiobus_link_mdiodev()) is only built when
> > CONFIG_OF_MDIO is enabled, which is again, a DT specific thing, and would
> > not work in case of ACPI.
>
> Vikas
>
> How are you describing the MDIO bus in ACPI? Do you have a proposed
> standard document for submission to UEFI?
>
>          Andrew

Hi Andrew,

We are evaluating this internally with NXP stakeholders.
Once finalised, I will share the plan & documentation accordingly.

Thnx !!
Vikas Singh

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

end of thread, other threads:[~2020-09-16 19:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 11:43 [PATCH v2] net: Phy: Add PHY lookup support on MDIO bus in case of ACPI probe Vikas Singh
2020-09-10 13:12 ` Andrew Lunn
2020-09-16 15:08   ` Vikas Singh
2020-09-10 14:44 ` Jakub Kicinski

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.