diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2013-12-05 17:52:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-06 14:57:21 -0500 |
commit | 8fdade4be755af17a3d205d07f594f939f173504 (patch) | |
tree | 84c4ae38f56f58c1c9dbc9af385845f9f1d6cc87 /drivers/of | |
parent | e9fbdf176d2a7993b9d4c487b50c68d1c6019b2c (diff) |
net: of_mdio: parse "max-speed" property to set PHY supported features
The "max-speed" property is defined per the ePAPR specification to
express the maximum speed a PHY supports. Use that property, if present
to set the phydev->supported features which properly restricts the PHY
within the range of defined speeds.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/of_mdio.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 14feffc36964..a43b8523c61e 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
@@ -22,12 +22,30 @@ | |||
22 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); | 22 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); |
23 | MODULE_LICENSE("GPL"); | 23 | MODULE_LICENSE("GPL"); |
24 | 24 | ||
25 | static void of_set_phy_supported(struct phy_device *phydev, u32 max_speed) | ||
26 | { | ||
27 | phydev->supported |= PHY_DEFAULT_FEATURES; | ||
28 | |||
29 | switch (max_speed) { | ||
30 | default: | ||
31 | return; | ||
32 | |||
33 | case SPEED_1000: | ||
34 | phydev->supported |= PHY_1000BT_FEATURES; | ||
35 | case SPEED_100: | ||
36 | phydev->supported |= PHY_100BT_FEATURES; | ||
37 | case SPEED_10: | ||
38 | phydev->supported |= PHY_10BT_FEATURES; | ||
39 | } | ||
40 | } | ||
41 | |||
25 | static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *child, | 42 | static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *child, |
26 | u32 addr) | 43 | u32 addr) |
27 | { | 44 | { |
28 | struct phy_device *phy; | 45 | struct phy_device *phy; |
29 | bool is_c45; | 46 | bool is_c45; |
30 | int rc, prev_irq; | 47 | int rc, prev_irq; |
48 | u32 max_speed = 0; | ||
31 | 49 | ||
32 | is_c45 = of_device_is_compatible(child, | 50 | is_c45 = of_device_is_compatible(child, |
33 | "ethernet-phy-ieee802.3-c45"); | 51 | "ethernet-phy-ieee802.3-c45"); |
@@ -58,8 +76,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi | |||
58 | return 1; | 76 | return 1; |
59 | } | 77 | } |
60 | 78 | ||
79 | /* Set phydev->supported based on the "max-speed" property | ||
80 | * if present */ | ||
81 | if (!of_property_read_u32(child, "max-speed", &max_speed)) | ||
82 | of_set_phy_supported(phy, max_speed); | ||
83 | |||
61 | dev_dbg(&mdio->dev, "registered phy %s at address %i\n", | 84 | dev_dbg(&mdio->dev, "registered phy %s at address %i\n", |
62 | child->name, addr); | 85 | child->name, addr); |
63 | 86 | ||
64 | return 0; | 87 | return 0; |
65 | } | 88 | } |