* [PATCH] make of_set_phy_supported work with genphy driver
@ 2014-05-21 13:29 Sascha Hauer
2014-05-21 13:29 ` [PATCH 1/2] net: phy: genphy: Allow overwriting features Sascha Hauer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-21 13:29 UTC (permalink / raw)
To: netdev; +Cc: Florian Fainelli
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.
Sascha
----------------------------------------------------------------
Sascha Hauer (2):
net: phy: genphy: Allow overwriting features
net: phy: make of_set_phy_supported work with genphy driver
drivers/net/phy/phy_device.c | 47 +++++++++++++++++++++++++++++++++++++-------
drivers/of/of_mdio.c | 26 ------------------------
2 files changed, 40 insertions(+), 33 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] net: phy: genphy: Allow overwriting features
2014-05-21 13:29 [PATCH] make of_set_phy_supported work with genphy driver Sascha Hauer
@ 2014-05-21 13:29 ` Sascha Hauer
2014-05-21 13:29 ` [PATCH 2/2] net: phy: make of_set_phy_supported work with genphy driver Sascha Hauer
2014-05-22 19:44 ` [PATCH] " David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-21 13:29 UTC (permalink / raw)
To: netdev; +Cc: Florian Fainelli, Sascha Hauer
of_set_phy_supported allows overwiting hardware capabilities of
a phy with values from the devicetree. This does not work with
the genphy driver though because the genphys config_init function
will overwrite all values adjusted by of_set_phy_supported. Fix
this by initialising the genphy features in the phy_driver struct
and in config_init just limit the features to the ones the hardware
can actually support. The resulting features are a subset of the
devicetree specified features and the hardware features.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/phy/phy_device.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 0ce6066..9db3fba 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1072,9 +1072,6 @@ static 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 +1104,8 @@ static 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;
}
@@ -1295,7 +1292,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,
--
2.0.0.rc0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] net: phy: make of_set_phy_supported work with genphy driver
2014-05-21 13:29 [PATCH] make of_set_phy_supported work with genphy driver Sascha Hauer
2014-05-21 13:29 ` [PATCH 1/2] net: phy: genphy: Allow overwriting features Sascha Hauer
@ 2014-05-21 13:29 ` Sascha Hauer
2014-05-22 19:44 ` [PATCH] " David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-21 13:29 UTC (permalink / raw)
To: netdev; +Cc: Florian Fainelli, Sascha Hauer
of_set_phy_supported allows overwiting hardware capabilities of
a phy with values from the devicetree. of_set_phy_supported is
called right after phy_device_register in the assumption that
phy_probe is called from phy_device_register and the features
of the phy are already initialized. For the genphy driver this
is not true, here phy_probe is called later during phy_connect
time. phy_probe will then overwrite all settings done from
of_set_phy_supported
Fix this by moving of_set_phy_supported to the core phy code
and calling it from phy_probe.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/phy/phy_device.c | 36 +++++++++++++++++++++++++++++++++++-
drivers/of/of_mdio.c | 26 --------------------------
2 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 9db3fba..2dcab24 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -33,6 +33,7 @@
#include <linux/mdio.h>
#include <linux/io.h>
#include <linux/uaccess.h>
+#include <linux/of.h>
#include <asm/irq.h>
@@ -1165,6 +1166,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
@@ -1199,7 +1232,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;
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 9a95831..007fb7a 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -22,27 +22,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)
@@ -103,11 +82,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);
--
2.0.0.rc0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] make of_set_phy_supported work with genphy driver
2014-05-21 13:29 [PATCH] make of_set_phy_supported work with genphy driver Sascha Hauer
2014-05-21 13:29 ` [PATCH 1/2] net: phy: genphy: Allow overwriting features Sascha Hauer
2014-05-21 13:29 ` [PATCH 2/2] net: phy: make of_set_phy_supported work with genphy driver Sascha Hauer
@ 2014-05-22 19:44 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-05-22 19:44 UTC (permalink / raw)
To: s.hauer; +Cc: netdev, f.fainelli
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Wed, 21 May 2014 15:29:43 +0200
> 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.
Series applied to net-next, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-22 19:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-21 13:29 [PATCH] make of_set_phy_supported work with genphy driver Sascha Hauer
2014-05-21 13:29 ` [PATCH 1/2] net: phy: genphy: Allow overwriting features Sascha Hauer
2014-05-21 13:29 ` [PATCH 2/2] net: phy: make of_set_phy_supported work with genphy driver Sascha Hauer
2014-05-22 19:44 ` [PATCH] " David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).