* [net-next PATCH v7 1/6] Documentation: ACPI: DSD: Document MDIO PHY
2020-07-25 14:23 [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver Calvin Johnson
@ 2020-07-25 14:23 ` Calvin Johnson
2020-07-25 14:24 ` [net-next PATCH v7 2/6] net: phy: introduce device_mdiobus_register() Calvin Johnson
` (5 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Calvin Johnson @ 2020-07-25 14:23 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Lorenzo Pieralisi, Hanjun Guo,
Sudeep Holla, Al Stone, Jeremy Linton,
Russell King - ARM Linux admin, Jon, Cristi Sovaiala,
Ioana Ciornei, Andrew Lunn, Andy Shevchenko, Florian Fainelli,
Madalin Bucur
Cc: linux-acpi, netdev, linux.cj, Paul Yang, 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 v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
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] 11+ messages in thread
* [net-next PATCH v7 2/6] net: phy: introduce device_mdiobus_register()
2020-07-25 14:23 [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver Calvin Johnson
2020-07-25 14:23 ` [net-next PATCH v7 1/6] Documentation: ACPI: DSD: Document MDIO PHY Calvin Johnson
@ 2020-07-25 14:24 ` Calvin Johnson
2020-07-25 14:24 ` [net-next PATCH v7 3/6] net/fsl: use device_mdiobus_register() Calvin Johnson
` (4 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Calvin Johnson @ 2020-07-25 14:24 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Lorenzo Pieralisi, Hanjun Guo,
Sudeep Holla, Al Stone, Jeremy Linton,
Russell King - ARM Linux admin, Jon, Cristi Sovaiala,
Ioana Ciornei, Andrew Lunn, Andy Shevchenko, Florian Fainelli,
Madalin Bucur
Cc: linux-acpi, netdev, linux.cj, Paul Yang, Calvin Johnson
Introduce device_mdiobus_register() to register mdiobus
in cases of either DT or ACPI.
Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---
Changes in v7: None
Changes in v6:
- change device_mdiobus_register() parameter position
- improve documentation
Changes in v5:
- add description
- clean up if else
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/phy/mdio_bus.c | 26 ++++++++++++++++++++++++++
include/linux/mdio.h | 1 +
2 files changed, 27 insertions(+)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 46b33701ad4b..8610f938f81f 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -501,6 +501,32 @@ static int mdiobus_create_device(struct mii_bus *bus,
return ret;
}
+/**
+ * device_mdiobus_register - register mdiobus for either DT or ACPI
+ * @bus: target mii_bus
+ * @dev: given MDIO device
+ *
+ * Description: Given an MDIO device and target mii bus, this function
+ * calls of_mdiobus_register() for DT node and mdiobus_register() in
+ * case of ACPI.
+ *
+ * Returns 0 on success or negative error code on failure.
+ */
+int device_mdiobus_register(struct device *dev,
+ struct mii_bus *bus)
+{
+ struct fwnode_handle *fwnode = dev_fwnode(dev);
+
+ if (is_of_node(fwnode))
+ return of_mdiobus_register(bus, to_of_node(fwnode));
+ if (fwnode) {
+ bus->dev.fwnode = fwnode;
+ return mdiobus_register(bus);
+ }
+ return -ENODEV;
+}
+EXPORT_SYMBOL(device_mdiobus_register);
+
/**
* __mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
* @bus: target mii_bus
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 898cbf00332a..f454c5435101 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -358,6 +358,7 @@ static inline int mdiobus_c45_read(struct mii_bus *bus, int prtad, int devad,
return mdiobus_read(bus, prtad, mdiobus_c45_addr(devad, regnum));
}
+int device_mdiobus_register(struct device *dev, struct mii_bus *bus);
int mdiobus_register_device(struct mdio_device *mdiodev);
int mdiobus_unregister_device(struct mdio_device *mdiodev);
bool mdiobus_is_registered_device(struct mii_bus *bus, int addr);
--
2.17.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next PATCH v7 3/6] net/fsl: use device_mdiobus_register()
2020-07-25 14:23 [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver Calvin Johnson
2020-07-25 14:23 ` [net-next PATCH v7 1/6] Documentation: ACPI: DSD: Document MDIO PHY Calvin Johnson
2020-07-25 14:24 ` [net-next PATCH v7 2/6] net: phy: introduce device_mdiobus_register() Calvin Johnson
@ 2020-07-25 14:24 ` Calvin Johnson
2020-07-25 14:24 ` [net-next PATCH v7 4/6] net: phy: introduce phy_find_by_mdio_handle() Calvin Johnson
` (3 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Calvin Johnson @ 2020-07-25 14:24 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Lorenzo Pieralisi, Hanjun Guo,
Sudeep Holla, Al Stone, Jeremy Linton,
Russell King - ARM Linux admin, Jon, Cristi Sovaiala,
Ioana Ciornei, Andrew Lunn, Andy Shevchenko, Florian Fainelli,
Madalin Bucur
Cc: linux-acpi, netdev, linux.cj, Paul Yang, Calvin Johnson
Replace of_mdiobus_register() with device_mdiobus_register()
to take care of both DT and ACPI mdiobus_register.
Remove unused device_node pointer.
Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---
Changes in v7: None
Changes in v6:
- change device_mdiobus_register() parameter position
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/ethernet/freescale/xgmac_mdio.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c
index 98be51d8b08c..704f2b166d0a 100644
--- a/drivers/net/ethernet/freescale/xgmac_mdio.c
+++ b/drivers/net/ethernet/freescale/xgmac_mdio.c
@@ -243,7 +243,6 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)
static int xgmac_mdio_probe(struct platform_device *pdev)
{
- struct device_node *np = pdev->dev.of_node;
struct mii_bus *bus;
struct resource *res;
struct mdio_fsl_priv *priv;
@@ -285,7 +284,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
priv->has_a011043 = device_property_read_bool(&pdev->dev,
"fsl,erratum-a011043");
- ret = of_mdiobus_register(bus, np);
+ ret = device_mdiobus_register(&pdev->dev, bus);
if (ret) {
dev_err(&pdev->dev, "cannot register MDIO bus\n");
goto err_registration;
--
2.17.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next PATCH v7 4/6] net: phy: introduce phy_find_by_mdio_handle()
2020-07-25 14:23 [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver Calvin Johnson
` (2 preceding siblings ...)
2020-07-25 14:24 ` [net-next PATCH v7 3/6] net/fsl: use device_mdiobus_register() Calvin Johnson
@ 2020-07-25 14:24 ` Calvin Johnson
2020-07-25 14:24 ` [net-next PATCH v7 5/6] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson
` (2 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Calvin Johnson @ 2020-07-25 14:24 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Lorenzo Pieralisi, Hanjun Guo,
Sudeep Holla, Al Stone, Jeremy Linton,
Russell King - ARM Linux admin, Jon, Cristi Sovaiala,
Ioana Ciornei, Andrew Lunn, Andy Shevchenko, Florian Fainelli,
Madalin Bucur
Cc: linux-acpi, netdev, linux.cj, Paul Yang, 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 v7:
- remove unnecessary -ve check for u32 var
Changes in v6: None
Changes in v5:
- rename phy_find_by_fwnode() to phy_find_by_mdio_handle()
- add docment for phy_find_by_mdio_handle()
- error out DT in phy_find_by_mdio_handle()
- clean up err return
Changes in v4:
- release fwnode_mdio after use
- return ERR_PTR instead of NULL
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 | 40 ++++++++++++++++++++++++++++++++++++
include/linux/phy.h | 2 ++
3 files changed, 67 insertions(+)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 8610f938f81f..d9597c5b55ae 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 1b9523595839..746755c086bf 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -23,8 +23,10 @@
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/netdevice.h>
+#include <linux/of.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>
@@ -965,6 +967,44 @@ struct phy_device *phy_find_first(struct mii_bus *bus)
}
EXPORT_SYMBOL(phy_find_first);
+/**
+ * phy_find_by_mdio_handle - get phy device from mdio-handle and phy-channel
+ * @fwnode: a pointer to a &struct fwnode_handle to get mdio-handle and
+ * phy-channel
+ *
+ * Find fwnode_mdio using mdio-handle reference. Using fwnode_mdio get the
+ * mdio bus. Property phy-channel provides the phy address on the mdio bus.
+ * Pass mdio bus and phy address to mdiobus_get_phy() and get corresponding
+ * phy_device. This method is used for ACPI and not for DT.
+ *
+ * Returns pointer to the phy device on success, else ERR_PTR.
+ */
+struct phy_device *phy_find_by_mdio_handle(struct fwnode_handle *fwnode)
+{
+ struct fwnode_handle *fwnode_mdio;
+ struct mii_bus *mdio;
+ int addr;
+ int err;
+
+ if (is_of_node(fwnode))
+ return ERR_PTR(-EINVAL);
+
+ fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0);
+ mdio = fwnode_mdio_find_bus(fwnode_mdio);
+ fwnode_handle_put(fwnode_mdio);
+ if (!mdio)
+ return ERR_PTR(-ENODEV);
+
+ err = fwnode_property_read_u32(fwnode, "phy-channel", &addr);
+ if (err)
+ return ERR_PTR(err);
+ if (addr >= PHY_MAX_ADDR)
+ return ERR_PTR(-EINVAL);
+
+ return mdiobus_get_phy(mdio, addr);
+}
+EXPORT_SYMBOL(phy_find_by_mdio_handle);
+
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 0403eb799913..fd383a22eb61 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_mdio_handle(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] 11+ messages in thread
* [net-next PATCH v7 5/6] phylink: introduce phylink_fwnode_phy_connect()
2020-07-25 14:23 [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver Calvin Johnson
` (3 preceding siblings ...)
2020-07-25 14:24 ` [net-next PATCH v7 4/6] net: phy: introduce phy_find_by_mdio_handle() Calvin Johnson
@ 2020-07-25 14:24 ` Calvin Johnson
2020-07-25 14:24 ` [net-next PATCH v7 6/6] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Calvin Johnson
2020-07-29 0:39 ` [net-next PATCH v7 0/6] ACPI support for dpaa2 " David Miller
6 siblings, 0 replies; 11+ messages in thread
From: Calvin Johnson @ 2020-07-25 14:24 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Lorenzo Pieralisi, Hanjun Guo,
Sudeep Holla, Al Stone, Jeremy Linton,
Russell King - ARM Linux admin, Jon, Cristi Sovaiala,
Ioana Ciornei, Andrew Lunn, Andy Shevchenko, Florian Fainelli,
Madalin Bucur
Cc: linux-acpi, netdev, linux.cj, Paul Yang, 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>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v7:
- assign flags to phy_dev
Changes in v6:
- clean up phylink_fwnode_phy_connect()
Changes in v5:
- return -EINVAL for invalid fwnode
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/net/phy/phylink.c | 32 ++++++++++++++++++++++++++++++++
include/linux/phylink.h | 3 +++
2 files changed, 35 insertions(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 32b4bd6a5b55..c35ae42d9318 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>
@@ -1118,6 +1119,37 @@ 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;
+
+ if (is_of_node(fwnode))
+ return phylink_of_phy_connect(pl, to_of_node(fwnode), flags);
+ if (is_acpi_device_node(fwnode)) {
+ phy_dev = phy_find_by_mdio_handle(fwnode);
+ if (!phy_dev)
+ return -ENODEV;
+ phy_dev->dev_flags |= flags;
+ return phylink_connect_phy(pl, phy_dev);
+ }
+ return -EINVAL;
+}
+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 1aad2aea4610..ba23b5a1548f 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -434,6 +434,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] 11+ messages in thread
* [net-next PATCH v7 6/6] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver
2020-07-25 14:23 [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver Calvin Johnson
` (4 preceding siblings ...)
2020-07-25 14:24 ` [net-next PATCH v7 5/6] phylink: introduce phylink_fwnode_phy_connect() Calvin Johnson
@ 2020-07-25 14:24 ` Calvin Johnson
2020-07-29 0:39 ` [net-next PATCH v7 0/6] ACPI support for dpaa2 " David Miller
6 siblings, 0 replies; 11+ messages in thread
From: Calvin Johnson @ 2020-07-25 14:24 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Lorenzo Pieralisi, Hanjun Guo,
Sudeep Holla, Al Stone, Jeremy Linton,
Russell King - ARM Linux admin, Jon, Cristi Sovaiala,
Ioana Ciornei, Andrew Lunn, Andy Shevchenko, Florian Fainelli,
Madalin Bucur
Cc: linux-acpi, netdev, linux.cj, Paul Yang, 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 v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- introduce device_mdiobus_register()
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] 11+ messages in thread
* Re: [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver.
2020-07-25 14:23 [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver Calvin Johnson
` (5 preceding siblings ...)
2020-07-25 14:24 ` [net-next PATCH v7 6/6] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Calvin Johnson
@ 2020-07-29 0:39 ` David Miller
2020-07-29 0:42 ` Florian Fainelli
6 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2020-07-29 0:39 UTC (permalink / raw)
To: calvin.johnson
Cc: rafael, lenb, Lorenzo.Pieralisi, guohanjun, sudeep.holla, ahs3,
jeremy.linton, linux, jon, cristian.sovaiala, ioana.ciornei,
andrew, andy.shevchenko, f.fainelli, madalin.bucur, linux-acpi,
netdev, linux.cj, Paul.Yang
From: Calvin Johnson <calvin.johnson@oss.nxp.com>
Date: Sat, 25 Jul 2020 19:53:58 +0530
> 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.
>
> Previous discussions on this patchset is available at:
> https://lore.kernel.org/linux-acpi/20200715090400.4733-1-calvin.johnson@oss.nxp.com/T/#t
>
> Patch "net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver" depends on
> https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/linux.git/commit/?h=acpi/for-next&id=c279c4cf5bcd3c55b4fb9709d9036cd1bfe3beb8
> Remaining patches are independent of the above patch and can be applied without
> any issues.
This really needs to be reviewed by phy/phylink people.
> Device Tree can be tested on LX2160A-RDB with the below change which is also
> available in the above referenced 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;
I don't know how you expect me to handle this dependency in the networking
tree.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [net-next PATCH v7 0/6] ACPI support for dpaa2 MAC driver.
2020-07-29 0:39 ` [net-next PATCH v7 0/6] ACPI support for dpaa2 " David Miller
@ 2020-07-29 0:42 ` Florian Fainelli
0 siblings, 0 replies; 11+ messages in thread
From: Florian Fainelli @ 2020-07-29 0:42 UTC (permalink / raw)
To: David Miller, calvin.johnson
Cc: rafael, lenb, Lorenzo.Pieralisi, guohanjun, sudeep.holla, ahs3,
jeremy.linton, linux, jon, cristian.sovaiala, ioana.ciornei,
andrew, andy.shevchenko, madalin.bucur, linux-acpi, netdev,
linux.cj, Paul.Yang
On 7/28/2020 5:39 PM, David Miller wrote:
> From: Calvin Johnson <calvin.johnson@oss.nxp.com>
> Date: Sat, 25 Jul 2020 19:53:58 +0530
>
>> 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.
>>
>> Previous discussions on this patchset is available at:
>> https://lore.kernel.org/linux-acpi/20200715090400.4733-1-calvin.johnson@oss.nxp.com/T/#t
>>
>> Patch "net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver" depends on
>> https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/linux.git/commit/?h=acpi/for-next&id=c279c4cf5bcd3c55b4fb9709d9036cd1bfe3beb8
>> Remaining patches are independent of the above patch and can be applied without
>> any issues.
>
> This really needs to be reviewed by phy/phylink people.
Oh it has been reviewed! We just have stalled for various reasons. There
is another email thread with the same subject which is still being
discussed:
https://lore.kernel.org/netdev/20200715090400.4733-1-calvin.johnson@oss.nxp.com/T/#t
--
Florian
^ permalink raw reply [flat|nested] 11+ messages in thread