diff options
Diffstat (limited to 'drivers/of/of_mdio.c')
-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 | } |