Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netdev/phy/of: Handle IEEE802.3 clause 45 Ethernet PHYs in of_mdiobus_register()

Define two new "compatible" values for Ethernet
PHYs. "ethernet-phy-ieee802.3-c22" and "ethernet-phy-ieee802.3-c45"
are used to indicate a PHY uses the corresponding protocol.

If a PHY is "compatible" with "ethernet-phy-ieee802.3-c45", we
indicate this so that get_phy_device() can properly probe the device.

If get_phy_device() fails, it was probably due to failing the probe of
the PHY identifier registers. Since we have the device tree telling
us the PHY exists, go ahead and add it anyhow with a phy_id of zero.
There may be a driver match based on the "compatible" property.

Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

David Daney and committed by
David S. Miller
6bd47ac2 ac28b9f8

+23 -5
+11 -1
Documentation/devicetree/bindings/net/phy.txt
··· 14 14 - linux,phandle : phandle for this node; likely referenced by an 15 15 ethernet controller node. 16 16 17 + Optional Properties: 18 + 19 + - compatible: Compatible list, may contain 20 + "ethernet-phy-ieee802.3-c22" or "ethernet-phy-ieee802.3-c45" for 21 + PHYs that implement IEEE802.3 clause 22 or IEEE802.3 clause 45 22 + specifications. If neither of these are specified, the default is to 23 + assume clause 22. The compatible list may also contain other 24 + elements. 25 + 17 26 Example: 18 27 19 28 ethernet-phy@0 { 20 - linux,phandle = <2452000> 29 + compatible = "ethernet-phy-ieee802.3-c22"; 30 + linux,phandle = <2452000>; 21 31 interrupt-parent = <40000>; 22 32 interrupts = <35 1>; 23 33 reg = <0>;
+12 -4
drivers/of/of_mdio.c
··· 57 57 const __be32 *paddr; 58 58 u32 addr; 59 59 int len; 60 + bool is_c45; 60 61 61 62 /* A PHY must have a reg property in the range [0-31] */ 62 63 paddr = of_get_property(child, "reg", &len); ··· 80 79 mdio->irq[addr] = PHY_POLL; 81 80 } 82 81 83 - phy = get_phy_device(mdio, addr, false); 82 + is_c45 = of_device_is_compatible(child, 83 + "ethernet-phy-ieee802.3-c45"); 84 + phy = get_phy_device(mdio, addr, is_c45); 85 + 84 86 if (!phy || IS_ERR(phy)) { 85 - dev_err(&mdio->dev, "error probing PHY at address %i\n", 86 - addr); 87 - continue; 87 + phy = phy_device_create(mdio, addr, 0, false, NULL); 88 + if (!phy || IS_ERR(phy)) { 89 + dev_err(&mdio->dev, 90 + "error creating PHY at address %i\n", 91 + addr); 92 + continue; 93 + } 88 94 } 89 95 90 96 /* Associate the OF node with the device structure so it