Commit 11ee46f2 authored by David S. Miller's avatar David S. Miller

Merge branch 'genphy'

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: default avatarDavid S. Miller <davem@davemloft.net>
parents a6cea535 de906af1
......@@ -33,6 +33,7 @@
#include <linux/mdio.h>
#include <linux/io.h>
#include <linux/uaccess.h>
#include <linux/of.h>
#include <asm/irq.h>
......@@ -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);
......@@ -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;
}
......@@ -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
......@@ -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;
......@@ -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,
......
......@@ -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)
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment