* [net-next PATCH v3 0/5] ACPI support for dpaa2 MAC driver.
@ 2020-07-08 17:34 Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 1/5] Documentation: ACPI: DSD: Document MDIO PHY Calvin Johnson
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Calvin Johnson @ 2020-07-08 17:34 UTC (permalink / raw)
To: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andrew Lunn, Andy Shevchenko,
Florian Fainelli, Madalin Bucur
Cc: linux.cj, linux-acpi, netdev, Calvin Johnson
This patch series provides ACPI support for dpaa2 MAC driver.
This also introduces ACPI mechanism to get PHYs registered on a
MDIO bus and provide them to be connected to MAC.
This patchset is dependent on the review patches available on:
https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/linux.git/log/?h=for-review/acpi-iort-id-rework
Device Tree can be tested with the below change which is also available in
the above referenced review patches:
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -931,6 +931,7 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
if (error < 0)
goto error_cleanup_mc_io;
+ mc_bus_dev->dev.fwnode = pdev->dev.fwnode;
mc->root_mc_bus_dev = mc_bus_dev;
return 0;
Changes in v3:
- cleanup based on v2 comments
- Added description for more properties
- Added MDIO node DSDT entry
- introduce fwnode_mdio_find_bus()
- renamed and improved phy_find_by_fwnode()
- cleanup based on v2 comments
- move code into phylink_fwnode_phy_connect()
Changes in v2:
- clean up dpaa2_mac_get_node()
- introduce find_phy_device()
- use acpi_find_child_device()
Calvin Johnson (5):
Documentation: ACPI: DSD: Document MDIO PHY
net/fsl: store mdiobus fwnode
net: phy: introduce phy_find_by_fwnode()
phylink: introduce phylink_fwnode_phy_connect()
net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
Documentation/firmware-guide/acpi/dsd/phy.rst | 90 +++++++++++++++++++
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 70 ++++++++-------
drivers/net/ethernet/freescale/xgmac_mdio.c | 2 +
drivers/net/phy/mdio_bus.c | 25 ++++++
drivers/net/phy/phy_device.c | 21 +++++
drivers/net/phy/phylink.c | 33 +++++++
include/linux/phy.h | 2 +
include/linux/phylink.h | 3 +
8 files changed, 216 insertions(+), 30 deletions(-)
create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [net-next PATCH v3 1/5] Documentation: ACPI: DSD: Document MDIO PHY
2020-07-08 17:34 [net-next PATCH v3 0/5] ACPI support for dpaa2 MAC driver Calvin Johnson
@ 2020-07-08 17:34 ` Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode Calvin Johnson
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Calvin Johnson @ 2020-07-08 17:34 UTC (permalink / raw)
To: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andrew Lunn, Andy Shevchenko,
Florian Fainelli, Madalin Bucur
Cc: linux.cj, linux-acpi, netdev, Calvin Johnson
Introduce ACPI mechanism to get PHYs registered on a MDIO bus and
provide them to be connected to MAC.
An ACPI node property "mdio-handle" is introduced to reference the
MDIO bus on which PHYs are registered with autoprobing method used
by mdiobus_register().
Describe properties "phy-channel" and "phy-mode"
Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---
Changes in v3:
- cleanup based on v2 comments
- Added description for more properties
- Added MDIO node DSDT entry
Changes in v2: None
Documentation/firmware-guide/acpi/dsd/phy.rst | 90 +++++++++++++++++++
1 file changed, 90 insertions(+)
create mode 100644 Documentation/firmware-guide/acpi/dsd/phy.rst
diff --git a/Documentation/firmware-guide/acpi/dsd/phy.rst b/Documentation/firmware-guide/acpi/dsd/phy.rst
new file mode 100644
index 000000000000..0132fee10b45
--- /dev/null
+++ b/Documentation/firmware-guide/acpi/dsd/phy.rst
@@ -0,0 +1,90 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=========================
+MDIO bus and PHYs in ACPI
+=========================
+
+The PHYs on an mdiobus are probed and registered using mdiobus_register().
+Later, for connecting these PHYs to MAC, the PHYs registered on the
+mdiobus have to be referenced.
+
+mdio-handle
+-----------
+For each MAC node, a property "mdio-handle" is used to reference the
+MDIO bus on which the PHYs are registered. On getting hold of the MDIO
+bus, use find_phy_device() to get the PHY connected to the MAC.
+
+phy-channel
+-----------
+Property "phy-channel" defines the address of the PHY on the mdiobus.
+
+phy-mode
+--------
+Property "phy-mode" defines the type of PHY interface.
+
+An example of this is shown below::
+
+DSDT entry for MAC where MDIO node is referenced
+------------------------------------------------
+ Scope(\_SB.MCE0.PR17) // 1G
+ {
+ Name (_DSD, Package () {
+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package () {
+ Package () {"phy-channel", 1},
+ Package () {"phy-mode", "rgmii-id"},
+ Package () {"mdio-handle", Package (){\_SB.MDI0}}
+ }
+ })
+ }
+
+ Scope(\_SB.MCE0.PR18) // 1G
+ {
+ Name (_DSD, Package () {
+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package () {
+ Package () {"phy-channel", 2},
+ Package () {"phy-mode", "rgmii-id"},
+ Package () {"mdio-handle", Package (){\_SB.MDI0}}
+ }
+ })
+ }
+
+DSDT entry for MDIO node
+------------------------
+a) Silicon Component
+--------------------
+ Scope(_SB)
+ {
+ Device(MDI0) {
+ Name(_HID, "NXP0006")
+ Name(_CCA, 1)
+ Name(_UID, 0)
+ Name(_CRS, ResourceTemplate() {
+ Memory32Fixed(ReadWrite, MDI0_BASE, MDI_LEN)
+ Interrupt(ResourceConsumer, Level, ActiveHigh, Shared)
+ {
+ MDI0_IT
+ }
+ }) // end of _CRS for MDI0
+ Name (_DSD, Package () {
+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package () {
+ Package () {"little-endian", 1},
+ }
+ })
+ } // end of MDI0
+ }
+
+b) Platform Component
+---------------------
+ Scope(\_SB.MDI0)
+ {
+ Device(PHY1) {
+ Name (_ADR, 0x1)
+ } // end of PHY1
+
+ Device(PHY2) {
+ Name (_ADR, 0x2)
+ } // end of PHY2
+ }
--
2.17.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode
2020-07-08 17:34 [net-next PATCH v3 0/5] ACPI support for dpaa2 MAC driver Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 1/5] Documentation: ACPI: DSD: Document MDIO PHY Calvin Johnson
@ 2020-07-08 17:34 ` Calvin Johnson
2020-07-08 18:55 ` Andrew Lunn
2020-07-08 19:38 ` Andy Shevchenko
2020-07-08 17:34 ` [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode() Calvin Johnson
` (2 subsequent siblings)
4 siblings, 2 replies; 10+ messages in thread
From: Calvin Johnson @ 2020-07-08 17:34 UTC (permalink / raw)
To: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andrew Lunn, Andy Shevchenko,
Florian Fainelli, Madalin Bucur
Cc: linux.cj, linux-acpi, netdev, Calvin Johnson
Store fwnode for mdiobus in the bus structure so that it can
later be retrieved and used whenever mdiobus fwnode information
is required.
Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---
Changes in v3: None
Changes in v2: None
drivers/net/ethernet/freescale/xgmac_mdio.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c
index 98be51d8b08c..8189c86d5a44 100644
--- a/drivers/net/ethernet/freescale/xgmac_mdio.c
+++ b/drivers/net/ethernet/freescale/xgmac_mdio.c
@@ -269,6 +269,8 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
bus->write = xgmac_mdio_write;
bus->parent = &pdev->dev;
bus->probe_capabilities = MDIOBUS_C22_C45;
+ if (pdev->dev.fwnode)
+ bus->dev.fwnode = pdev->dev.fwnode;
snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start);
/* Set the PHY base address */
--
2.17.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode()
2020-07-08 17:34 [net-next PATCH v3 0/5] ACPI support for dpaa2 MAC driver Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 1/5] Documentation: ACPI: DSD: Document MDIO PHY Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode Calvin Johnson
@ 2020-07-08 17:34 ` Calvin Johnson
2020-07-08 18:58 ` Andrew Lunn
2020-07-08 19:42 ` Andy Shevchenko
2020-07-08 17:34 ` [net-next PATCH v3 4/5] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 5/5] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Calvin Johnson
4 siblings, 2 replies; 10+ messages in thread
From: Calvin Johnson @ 2020-07-08 17:34 UTC (permalink / raw)
To: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andrew Lunn, Andy Shevchenko,
Florian Fainelli, Madalin Bucur
Cc: linux.cj, linux-acpi, netdev, Calvin Johnson
The PHYs on an mdiobus are probed and registered using mdiobus_register().
Later, for connecting these PHYs to MAC, the PHYs registered on the
mdiobus have to be referenced.
For each MAC node, a property "mdio-handle" is used to reference the
MDIO bus on which the PHYs are registered. On getting hold of the MDIO
bus, use phy_find_by_fwnode() to get the PHY connected to the MAC.
Introduce fwnode_mdio_find_bus() to find the mii_bus that corresponds
to given mii_bus fwnode.
Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---
Changes in v3:
- introduce fwnode_mdio_find_bus()
- renamed and improved phy_find_by_fwnode()
Changes in v2: None
drivers/net/phy/mdio_bus.c | 25 +++++++++++++++++++++++++
drivers/net/phy/phy_device.c | 21 +++++++++++++++++++++
include/linux/phy.h | 2 ++
3 files changed, 48 insertions(+)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 46b33701ad4b..626da1070392 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -435,6 +435,31 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np)
}
EXPORT_SYMBOL(of_mdio_find_bus);
+/**
+ * fwnode_mdio_find_bus - Given an mii_bus fwnode, find the mii_bus.
+ * @mdio_bus_fwnode: fwnode of the mii_bus.
+ *
+ * Returns a reference to the mii_bus, or NULL if none found. The
+ * embedded struct device will have its reference count incremented,
+ * and this must be put once the bus is finished with.
+ *
+ * Because the association of a fwnode and mii_bus is made via
+ * mdiobus_register(), the mii_bus cannot be found before it is
+ * registered with mdiobus_register().
+ *
+ */
+struct mii_bus *fwnode_mdio_find_bus(struct fwnode_handle *mdio_bus_fwnode)
+{
+ struct device *d;
+
+ if (!mdio_bus_fwnode)
+ return NULL;
+
+ d = class_find_device_by_fwnode(&mdio_bus_class, mdio_bus_fwnode);
+ return d ? to_mii_bus(d) : NULL;
+}
+EXPORT_SYMBOL(fwnode_mdio_find_bus);
+
/* 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
* found, set the of_node pointer for the mdio device. This allows
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index cf3505e2f587..6d113ae9eaa0 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -25,6 +25,7 @@
#include <linux/netdevice.h>
#include <linux/phy.h>
#include <linux/phy_led_triggers.h>
+#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/sfp.h>
#include <linux/skbuff.h>
@@ -964,6 +965,26 @@ struct phy_device *phy_find_first(struct mii_bus *bus)
}
EXPORT_SYMBOL(phy_find_first);
+struct phy_device *phy_find_by_fwnode(struct fwnode_handle *fwnode)
+{
+ struct fwnode_handle *fwnode_mdio;
+ struct mii_bus *mdio;
+ int addr;
+ int err;
+
+ fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0);
+ mdio = fwnode_mdio_find_bus(fwnode_mdio);
+ if (!mdio)
+ return NULL;
+
+ err = fwnode_property_read_u32(fwnode, "phy-channel", &addr);
+ if (err < 0 || addr < 0 || addr >= PHY_MAX_ADDR)
+ return NULL;
+
+ return mdiobus_get_phy(mdio, addr);
+}
+EXPORT_SYMBOL(phy_find_by_fwnode);
+
static void phy_link_change(struct phy_device *phydev, bool up)
{
struct net_device *netdev = phydev->attached_dev;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 1592c3d0e12f..6f283789d6d3 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -334,6 +334,7 @@ static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev)
}
struct mii_bus *mdio_find_bus(const char *mdio_name);
+struct mii_bus *fwnode_mdio_find_bus(struct fwnode_handle *mdio_bus_fwnode);
struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
#define PHY_INTERRUPT_DISABLED false
@@ -1245,6 +1246,7 @@ int phy_sfp_probe(struct phy_device *phydev,
struct phy_device *phy_attach(struct net_device *dev, const char *bus_id,
phy_interface_t interface);
struct phy_device *phy_find_first(struct mii_bus *bus);
+struct phy_device *phy_find_by_fwnode(struct fwnode_handle *fwnode);
int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
u32 flags, phy_interface_t interface);
int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
--
2.17.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [net-next PATCH v3 4/5] phylink: introduce phylink_fwnode_phy_connect()
2020-07-08 17:34 [net-next PATCH v3 0/5] ACPI support for dpaa2 MAC driver Calvin Johnson
` (2 preceding siblings ...)
2020-07-08 17:34 ` [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode() Calvin Johnson
@ 2020-07-08 17:34 ` Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 5/5] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Calvin Johnson
4 siblings, 0 replies; 10+ messages in thread
From: Calvin Johnson @ 2020-07-08 17:34 UTC (permalink / raw)
To: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andrew Lunn, Andy Shevchenko,
Florian Fainelli, Madalin Bucur
Cc: linux.cj, linux-acpi, netdev, Calvin Johnson
Define phylink_fwnode_phy_connect() to connect phy specified by
a fwnode to a phylink instance.
Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---
Changes in v3: None
Changes in v2: None
drivers/net/phy/phylink.c | 33 +++++++++++++++++++++++++++++++++
include/linux/phylink.h | 3 +++
2 files changed, 36 insertions(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index dae6c8b51d7f..35d4dfbf5567 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -5,6 +5,7 @@
*
* Copyright (C) 2015 Russell King
*/
+#include <linux/acpi.h>
#include <linux/ethtool.h>
#include <linux/export.h>
#include <linux/gpio/consumer.h>
@@ -1017,6 +1018,38 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn,
}
EXPORT_SYMBOL_GPL(phylink_of_phy_connect);
+/**
+ * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode.
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
+ * @fwnode: a pointer to a &struct fwnode_handle.
+ * @flags: PHY-specific flags to communicate to the PHY device driver
+ *
+ * Connect the phy specified @fwnode to the phylink instance specified
+ * by @pl. Actions specified in phylink_connect_phy() will be
+ * performed.
+ *
+ * Returns 0 on success or a negative errno.
+ */
+int phylink_fwnode_phy_connect(struct phylink *pl,
+ struct fwnode_handle *fwnode,
+ u32 flags)
+{
+ struct phy_device *phy_dev;
+ int ret = 0;
+
+ if (is_of_node(fwnode)) {
+ ret = phylink_of_phy_connect(pl, to_of_node(fwnode), flags);
+ } else if (is_acpi_device_node(fwnode)) {
+ phy_dev = phy_find_by_fwnode(fwnode);
+ if (!phy_dev)
+ return -ENODEV;
+ ret = phylink_connect_phy(pl, phy_dev);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect);
+
/**
* phylink_disconnect_phy() - disconnect any PHY attached to the phylink
* instance.
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index b32b8b45421b..b27eed5e49a9 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -368,6 +368,9 @@ void phylink_destroy(struct phylink *);
int phylink_connect_phy(struct phylink *, struct phy_device *);
int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags);
+int phylink_fwnode_phy_connect(struct phylink *pl,
+ struct fwnode_handle *fwnode,
+ u32 flags);
void phylink_disconnect_phy(struct phylink *);
void phylink_mac_change(struct phylink *, bool up);
--
2.17.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [net-next PATCH v3 5/5] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
2020-07-08 17:34 [net-next PATCH v3 0/5] ACPI support for dpaa2 MAC driver Calvin Johnson
` (3 preceding siblings ...)
2020-07-08 17:34 ` [net-next PATCH v3 4/5] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson
@ 2020-07-08 17:34 ` Calvin Johnson
4 siblings, 0 replies; 10+ messages in thread
From: Calvin Johnson @ 2020-07-08 17:34 UTC (permalink / raw)
To: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andrew Lunn, Andy Shevchenko,
Florian Fainelli, Madalin Bucur
Cc: linux.cj, linux-acpi, netdev, Calvin Johnson
Modify dpaa2_mac_connect() to support ACPI along with DT.
Modify dpaa2_mac_get_node() to get the dpmac fwnode from either
DT or ACPI.
Replace of_get_phy_mode with fwnode_get_phy_mode to get
phy-mode for a dpmac_node.
Define and use helper function find_phy_device() to find phy_dev
that is later connected to mac->phylink.
Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---
Changes in v3:
- cleanup based on v2 comments
- move code into phylink_fwnode_phy_connect()
Changes in v2:
- clean up dpaa2_mac_get_node()
- introduce find_phy_device()
- use acpi_find_child_device()
.../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 70 +++++++++++--------
1 file changed, 40 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 3ee236c5fc37..297d2dab9e97 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
/* Copyright 2019 NXP */
+#include <linux/acpi.h>
+#include <linux/platform_device.h>
+
#include "dpaa2-eth.h"
#include "dpaa2-mac.h"
@@ -23,38 +26,46 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
}
/* Caller must call of_node_put on the returned value */
-static struct device_node *dpaa2_mac_get_node(u16 dpmac_id)
+static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
+ u16 dpmac_id)
{
- struct device_node *dpmacs, *dpmac = NULL;
- u32 id;
+ struct fwnode_handle *fsl_mc_fwnode = dev_fwnode(dev->parent->parent);
+ struct fwnode_handle *dpmacs, *dpmac = NULL;
+ struct acpi_device *adev;
int err;
+ u32 id;
- dpmacs = of_find_node_by_name(NULL, "dpmacs");
- if (!dpmacs)
- return NULL;
-
- while ((dpmac = of_get_next_child(dpmacs, dpmac)) != NULL) {
- err = of_property_read_u32(dpmac, "reg", &id);
- if (err)
- continue;
- if (id == dpmac_id)
- break;
+ if (is_of_node(fsl_mc_fwnode)) {
+ dpmacs = fwnode_get_named_child_node(fsl_mc_fwnode, "dpmacs");
+ if (!dpmacs)
+ return NULL;
+
+ while ((dpmac = fwnode_get_next_child_node(dpmacs, dpmac))) {
+ err = fwnode_property_read_u32(dpmac, "reg", &id);
+ if (err)
+ continue;
+ if (id == dpmac_id)
+ return dpmac;
+ }
+ fwnode_handle_put(dpmacs);
+ } else if (is_acpi_device_node(fsl_mc_fwnode)) {
+ adev = acpi_find_child_device(ACPI_COMPANION(dev->parent),
+ dpmac_id, false);
+ if (adev)
+ return acpi_fwnode_handle(adev);
}
-
- of_node_put(dpmacs);
-
- return dpmac;
+ return NULL;
}
-static int dpaa2_mac_get_if_mode(struct device_node *node,
+static int dpaa2_mac_get_if_mode(struct fwnode_handle *dpmac_node,
struct dpmac_attr attr)
{
phy_interface_t if_mode;
int err;
- err = of_get_phy_mode(node, &if_mode);
- if (!err)
- return if_mode;
+ err = fwnode_get_phy_mode(dpmac_node);
+ if (err > 0)
+ return err;
err = phy_mode(attr.eth_if, &if_mode);
if (!err)
@@ -231,7 +242,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
{
struct fsl_mc_device *dpmac_dev = mac->mc_dev;
struct net_device *net_dev = mac->net_dev;
- struct device_node *dpmac_node;
+ struct fwnode_handle *dpmac_node = NULL;
struct phylink *phylink;
struct dpmac_attr attr;
int err;
@@ -251,7 +262,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
mac->if_link_type = attr.link_type;
- dpmac_node = dpaa2_mac_get_node(attr.id);
+ dpmac_node = dpaa2_mac_get_node(&dpmac_dev->dev, attr.id);
if (!dpmac_node) {
netdev_err(net_dev, "No dpmac@%d node found.\n", attr.id);
err = -ENODEV;
@@ -269,7 +280,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
* error out if the interface mode requests them and there is no PHY
* to act upon them
*/
- if (of_phy_is_fixed_link(dpmac_node) &&
+ if (of_phy_is_fixed_link(to_of_node(dpmac_node)) &&
(mac->if_mode == PHY_INTERFACE_MODE_RGMII_ID ||
mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID ||
mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) {
@@ -282,7 +293,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
mac->phylink_config.type = PHYLINK_NETDEV;
phylink = phylink_create(&mac->phylink_config,
- of_fwnode_handle(dpmac_node), mac->if_mode,
+ dpmac_node, mac->if_mode,
&dpaa2_mac_phylink_ops);
if (IS_ERR(phylink)) {
err = PTR_ERR(phylink);
@@ -290,20 +301,19 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
}
mac->phylink = phylink;
- err = phylink_of_phy_connect(mac->phylink, dpmac_node, 0);
+ err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0);
if (err) {
- netdev_err(net_dev, "phylink_of_phy_connect() = %d\n", err);
+ netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err);
goto err_phylink_destroy;
}
- of_node_put(dpmac_node);
-
+ fwnode_handle_put(dpmac_node);
return 0;
err_phylink_destroy:
phylink_destroy(mac->phylink);
err_put_node:
- of_node_put(dpmac_node);
+ fwnode_handle_put(dpmac_node);
err_close_dpmac:
dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle);
return err;
--
2.17.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode
2020-07-08 17:34 ` [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode Calvin Johnson
@ 2020-07-08 18:55 ` Andrew Lunn
2020-07-08 19:38 ` Andy Shevchenko
1 sibling, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2020-07-08 18:55 UTC (permalink / raw)
To: Calvin Johnson
Cc: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andy Shevchenko,
Florian Fainelli, Madalin Bucur, linux.cj, linux-acpi, netdev
On Wed, Jul 08, 2020 at 11:04:32PM +0530, Calvin Johnson wrote:
> Store fwnode for mdiobus in the bus structure so that it can
> later be retrieved and used whenever mdiobus fwnode information
> is required.
>
> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
> drivers/net/ethernet/freescale/xgmac_mdio.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c
> index 98be51d8b08c..8189c86d5a44 100644
> --- a/drivers/net/ethernet/freescale/xgmac_mdio.c
> +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c
> @@ -269,6 +269,8 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
> bus->write = xgmac_mdio_write;
> bus->parent = &pdev->dev;
> bus->probe_capabilities = MDIOBUS_C22_C45;
> + if (pdev->dev.fwnode)
> + bus->dev.fwnode = pdev->dev.fwnode;
This is pretty fundamental to making this work. In the device tree
world, this is setup by of_mdiobus_register(). Maybe we need an
fwnode_mdiobus_register(), just to ensure the next device wanting to
do ACPI does not forget this?
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode()
2020-07-08 17:34 ` [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode() Calvin Johnson
@ 2020-07-08 18:58 ` Andrew Lunn
2020-07-08 19:42 ` Andy Shevchenko
1 sibling, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2020-07-08 18:58 UTC (permalink / raw)
To: Calvin Johnson
Cc: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andy Shevchenko,
Florian Fainelli, Madalin Bucur, linux.cj, linux-acpi, netdev
> +/**
> + * fwnode_mdio_find_bus - Given an mii_bus fwnode, find the mii_bus.
> + * @mdio_bus_fwnode: fwnode of the mii_bus.
> + *
> + * Returns a reference to the mii_bus, or NULL if none found. The
> + * embedded struct device will have its reference count incremented,
> + * and this must be put once the bus is finished with.
> +struct phy_device *phy_find_by_fwnode(struct fwnode_handle *fwnode)
> +{
> + struct fwnode_handle *fwnode_mdio;
> + struct mii_bus *mdio;
> + int addr;
> + int err;
> +
> + fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0);
> + mdio = fwnode_mdio_find_bus(fwnode_mdio);
You don't seem to release the reference on the device anywhere. Is
that a problem?
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode
2020-07-08 17:34 ` [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode Calvin Johnson
2020-07-08 18:55 ` Andrew Lunn
@ 2020-07-08 19:38 ` Andy Shevchenko
1 sibling, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2020-07-08 19:38 UTC (permalink / raw)
To: Calvin Johnson
Cc: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andrew Lunn, Florian Fainelli,
Madalin Bucur, linux.cj, ACPI Devel Maling List, netdev
On Wed, Jul 8, 2020 at 8:35 PM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> Store fwnode for mdiobus in the bus structure so that it can
> later be retrieved and used whenever mdiobus fwnode information
> is required.
...
> + if (pdev->dev.fwnode)
But do you need this check?
> + bus->dev.fwnode = pdev->dev.fwnode;
Shouldn't be rather something like dev_fwnode().
And maybe set_primary_fwnode()? I'm not sure about the latter, though.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode()
2020-07-08 17:34 ` [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode() Calvin Johnson
2020-07-08 18:58 ` Andrew Lunn
@ 2020-07-08 19:42 ` Andy Shevchenko
1 sibling, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2020-07-08 19:42 UTC (permalink / raw)
To: Calvin Johnson
Cc: Jeremy Linton, Russell King - ARM Linux admin, Jon,
Cristi Sovaiala, Ioana Ciornei, Andrew Lunn, Florian Fainelli,
Madalin Bucur, linux.cj, ACPI Devel Maling List, netdev
On Wed, Jul 8, 2020 at 8:35 PM Calvin Johnson
<calvin.johnson@oss.nxp.com> wrote:
>
> The PHYs on an mdiobus are probed and registered using mdiobus_register().
> Later, for connecting these PHYs to MAC, the PHYs registered on the
> mdiobus have to be referenced.
>
> For each MAC node, a property "mdio-handle" is used to reference the
> MDIO bus on which the PHYs are registered. On getting hold of the MDIO
> bus, use phy_find_by_fwnode() to get the PHY connected to the MAC.
>
> Introduce fwnode_mdio_find_bus() to find the mii_bus that corresponds
> to given mii_bus fwnode.
...
> + err = fwnode_property_read_u32(fwnode, "phy-channel", &addr);
> + if (err < 0 || addr < 0 || addr >= PHY_MAX_ADDR)
> + return NULL;
Just wondering if we can return an error pointer here (sorry if it has
been discussed already).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-07-08 19:42 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 17:34 [net-next PATCH v3 0/5] ACPI support for dpaa2 MAC driver Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 1/5] Documentation: ACPI: DSD: Document MDIO PHY Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 2/5] net/fsl: store mdiobus fwnode Calvin Johnson
2020-07-08 18:55 ` Andrew Lunn
2020-07-08 19:38 ` Andy Shevchenko
2020-07-08 17:34 ` [net-next PATCH v3 3/5] net: phy: introduce phy_find_by_fwnode() Calvin Johnson
2020-07-08 18:58 ` Andrew Lunn
2020-07-08 19:42 ` Andy Shevchenko
2020-07-08 17:34 ` [net-next PATCH v3 4/5] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson
2020-07-08 17:34 ` [net-next PATCH v3 5/5] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Calvin Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).