aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/backport-5.4/771-mdio-bus-add-generic-find-bus.patch67
-rw-r--r--target/linux/generic/pending-5.4/703-phy-add-detach-callback-to-struct-phy_driver.patch2
2 files changed, 68 insertions, 1 deletions
diff --git a/target/linux/generic/backport-5.4/771-mdio-bus-add-generic-find-bus.patch b/target/linux/generic/backport-5.4/771-mdio-bus-add-generic-find-bus.patch
new file mode 100644
index 0000000000..b79fa0f18a
--- /dev/null
+++ b/target/linux/generic/backport-5.4/771-mdio-bus-add-generic-find-bus.patch
@@ -0,0 +1,67 @@
+From ce69e2162f158d9d4a0e513971d02dabc7d14cb7 Mon Sep 17 00:00:00 2001
+From: Jeremy Linton <jeremy.linton@arm.com>
+Date: Mon, 24 Feb 2020 16:53:58 -0600
+Subject: [PATCH] mdio_bus: Add generic mdio_find_bus()
+
+It appears most ethernet drivers follow one of two main strategies
+for mdio bus/phy management. A monolithic model where the net driver
+itself creates, probes and uses the phy, and one where an external
+mdio/phy driver instantiates the mdio bus/phy and the net driver
+only attaches to a known phy. Usually in this latter model the phys
+are discovered via DT relationships or simply phy name/address
+hardcoding.
+
+This is a shame because modern well behaved mdio buses are self
+describing and can be probed. The mdio layer itself is fully capable
+of this, yet there isn't a clean way for a standalone net driver
+to attach and enumerate the discovered devices. This is because
+outside of of_mdio_find_bus() there isn't a straightforward way
+to acquire the mii_bus pointer.
+
+So, lets add a mdio_find_bus which can return the mii_bus based
+only on its name.
+
+Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
+Acked-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/phy/mdio_bus.c | 17 +++++++++++++++++
+ include/linux/phy.h | 1 +
+ 2 files changed, 18 insertions(+)
+
+--- a/drivers/net/phy/mdio_bus.c
++++ b/drivers/net/phy/mdio_bus.c
+@@ -260,6 +260,23 @@ static struct class mdio_bus_class = {
+ .dev_release = mdiobus_release,
+ };
+
++/**
++ * mdio_find_bus - Given the name of a mdiobus, find the mii_bus.
++ * @mdio_bus_np: Pointer to 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_deviced'ed once the bus is finished with.
++ */
++struct mii_bus *mdio_find_bus(const char *mdio_name)
++{
++ struct device *d;
++
++ d = class_find_device_by_name(&mdio_bus_class, mdio_name);
++ return d ? to_mii_bus(d) : NULL;
++}
++EXPORT_SYMBOL(mdio_find_bus);
++
+ #if IS_ENABLED(CONFIG_OF_MDIO)
+ /**
+ * of_mdio_find_bus - Given an mii_bus node, find the mii_bus.
+--- a/include/linux/phy.h
++++ b/include/linux/phy.h
+@@ -273,6 +273,7 @@ static inline struct mii_bus *devm_mdiob
+ return devm_mdiobus_alloc_size(dev, 0);
+ }
+
++struct mii_bus *mdio_find_bus(const char *mdio_name);
+ void devm_mdiobus_free(struct device *dev, struct mii_bus *bus);
+ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
+
diff --git a/target/linux/generic/pending-5.4/703-phy-add-detach-callback-to-struct-phy_driver.patch b/target/linux/generic/pending-5.4/703-phy-add-detach-callback-to-struct-phy_driver.patch
index b74b04ca59..e95cb6a4c5 100644
--- a/target/linux/generic/pending-5.4/703-phy-add-detach-callback-to-struct-phy_driver.patch
+++ b/target/linux/generic/pending-5.4/703-phy-add-detach-callback-to-struct-phy_driver.patch
@@ -23,7 +23,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
sysfs_remove_link(&dev->dev.kobj, "phydev");
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
-@@ -540,6 +540,12 @@ struct phy_driver {
+@@ -541,6 +541,12 @@ struct phy_driver {
/* Override default interrupt handling */
int (*handle_interrupt)(struct phy_device *phydev);