Skip to content

Commit

Permalink
Merge branch 'genphy'
Browse files Browse the repository at this point in the history
Sascha Hauer says:

====================
make of_set_phy_supported work with genphy driver

The mdio phys recently gained support for specifying the phy speed
via devicetree. This currently only works with the hardware specific
phy drivers but not with the genphy driver. This series fixes this.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed May 22, 2014
2 parents a6cea53 + de906af commit 11ee46f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 33 deletions.
47 changes: 40 additions & 7 deletions drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/mdio.h>
#include <linux/io.h>
#include <linux/uaccess.h>
#include <linux/of.h>

#include <asm/irq.h>

Expand Down Expand Up @@ -1072,9 +1073,6 @@ int genphy_config_init(struct phy_device *phydev)
int val;
u32 features;

/* For now, I'll claim that the generic driver supports
* all possible port types
*/
features = (SUPPORTED_TP | SUPPORTED_MII
| SUPPORTED_AUI | SUPPORTED_FIBRE |
SUPPORTED_BNC);
Expand Down Expand Up @@ -1107,8 +1105,8 @@ int genphy_config_init(struct phy_device *phydev)
features |= SUPPORTED_1000baseT_Half;
}

phydev->supported = features;
phydev->advertising = features;
phydev->supported &= features;
phydev->advertising &= features;

return 0;
}
Expand Down Expand Up @@ -1169,6 +1167,38 @@ static int gen10g_resume(struct phy_device *phydev)
return 0;
}

static void of_set_phy_supported(struct phy_device *phydev)
{
struct device_node *node = phydev->dev.of_node;
u32 max_speed;

if (!IS_ENABLED(CONFIG_OF_MDIO))
return;

if (!node)
return;

if (!of_property_read_u32(node, "max-speed", &max_speed)) {
/* The default values for phydev->supported are provided by the PHY
* driver "features" member, we want to reset to sane defaults fist
* before supporting higher speeds.
*/
phydev->supported &= PHY_DEFAULT_FEATURES;

switch (max_speed) {
default:
return;

case SPEED_1000:
phydev->supported |= PHY_1000BT_FEATURES;
case SPEED_100:
phydev->supported |= PHY_100BT_FEATURES;
case SPEED_10:
phydev->supported |= PHY_10BT_FEATURES;
}
}
}

/**
* phy_probe - probe and init a PHY device
* @dev: device to probe and init
Expand Down Expand Up @@ -1203,7 +1233,8 @@ static int phy_probe(struct device *dev)
* or both of these values
*/
phydev->supported = phydrv->features;
phydev->advertising = phydrv->features;
of_set_phy_supported(phydev);
phydev->advertising = phydev->supported;

/* Set the state to READY by default */
phydev->state = PHY_READY;
Expand Down Expand Up @@ -1296,7 +1327,9 @@ static struct phy_driver genphy_driver[] = {
.name = "Generic PHY",
.soft_reset = genphy_soft_reset,
.config_init = genphy_config_init,
.features = 0,
.features = PHY_GBIT_FEATURES | SUPPORTED_MII |
SUPPORTED_AUI | SUPPORTED_FIBRE |
SUPPORTED_BNC,
.config_aneg = genphy_config_aneg,
.aneg_done = genphy_aneg_done,
.read_status = genphy_read_status,
Expand Down
26 changes: 0 additions & 26 deletions drivers/of/of_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,6 @@
MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>");
MODULE_LICENSE("GPL");

static void of_set_phy_supported(struct phy_device *phydev, u32 max_speed)
{
/* The default values for phydev->supported are provided by the PHY
* driver "features" member, we want to reset to sane defaults fist
* before supporting higher speeds.
*/
phydev->supported &= PHY_DEFAULT_FEATURES;

switch (max_speed) {
default:
return;

case SPEED_1000:
phydev->supported |= PHY_1000BT_FEATURES;
case SPEED_100:
phydev->supported |= PHY_100BT_FEATURES;
case SPEED_10:
phydev->supported |= PHY_10BT_FEATURES;
}
}

/* Extract the clause 22 phy ID from the compatible string of the form
* ethernet-phy-idAAAA.BBBB */
static int of_get_phy_id(struct device_node *device, u32 *phy_id)
Expand Down Expand Up @@ -104,11 +83,6 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi
return 1;
}

/* Set phydev->supported based on the "max-speed" property
* if present */
if (!of_property_read_u32(child, "max-speed", &max_speed))
of_set_phy_supported(phy, max_speed);

dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
child->name, addr);

Expand Down

0 comments on commit 11ee46f

Please sign in to comment.