2020-02-01 07:49:37

by Jeremy Linton

[permalink] [raw]
Subject: [PATCH 0/6] Add ACPI bindings to the genet

This patch series allows the BCM GENET, as used on the RPi4,
to attach when booted in an ACPI environment. The DSDT entry to
trigger this is seen below. Of note, the first patch adds a
small extension to the mdio layer which allows drivers to find
the mii_bus without firmware assistance. The fifth patch in
the set retrieves the MAC address from the umac registers
rather than carrying it directly in the DSDT. This of course
requires the firmware to pre-program it, so we continue to fall
back on a random one if it appears to be garbage.

v1 -> v2:
add a core routine mdio_find_bus(), then use it to attach
to the phy rather than hard-coding the id.
Broke initial ACPI support patch into 3 parts, two for bcmmii.c
Address some review comments from Florian
Lower the severity of a few dev_warns that happen all the time.

+ Device (ETH0)
+ {
+ Name (_HID, "BCM6E4E")
+ Name (_UID, 0)
+ Name (_CCA, 0x0)
+ Method (_STA)
+ {
+ Return (0xf)
+ }
+ Method (_CRS, 0x0, Serialized)
+ {
+ Name (RBUF, ResourceTemplate ()
+ {
+ Memory32Fixed (ReadWrite, 0xFd580000, 0x10000, )
+ Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBD }
+ Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 0xBE }
+ })
+ Return (RBUF)
+ }
+ Name (_DSD, Package () {
+ ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package () {
+ Package () { "phy-mode", "rgmii" },
+ }
+ })
+ }
+

Jeremy Linton (6):
mdio_bus: Add generic mdio_find_bus()
net: bcmgenet: refactor phy mode configuration
net: bcmgenet: enable automatic phy discovery
net: bcmgenet: Initial bcmgenet ACPI support
net: bcmgenet: Fetch MAC address from the adapter
net: bcmgenet: reduce severity of missing clock warnings

.../net/ethernet/broadcom/genet/bcmgenet.c | 66 +++++++++++-----
drivers/net/ethernet/broadcom/genet/bcmmii.c | 79 +++++++++++++------
drivers/net/phy/mdio_bus.c | 17 ++++
include/linux/phy.h | 1 +
4 files changed, 122 insertions(+), 41 deletions(-)

--
2.24.1


2020-02-01 07:50:04

by Jeremy Linton

[permalink] [raw]
Subject: [PATCH 1/6] 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 <[email protected]>
---
drivers/net/phy/mdio_bus.c | 17 +++++++++++++++++
include/linux/phy.h | 1 +
2 files changed, 18 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 229e480179ff..46dfb112fd04 100644
--- 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.
diff --git a/include/linux/phy.h b/include/linux/phy.h
index dd4a91f1feaa..5700dd4dbb6f 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -273,6 +273,7 @@ static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev)
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);

--
2.24.1