diff mbox

[U-Boot,v2,2/7] net: phy: genphy: Allow overwriting features

Message ID 1452693577-25786-3-git-send-email-abrodkin@synopsys.com
State Accepted
Commit 44bc317
Delegated to: Joe Hershberger
Headers show

Commit Message

Alexey Brodkin Jan. 13, 2016, 1:59 p.m. UTC
From: Sascha Hauer <s.hauer@pengutronix.de>

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.

This is a copy of the patch from Linux kernel, see
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c242a47238fa2a6a54af8a16e62b54e6e031d4bc

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---

Changes v1 -> v2:
 No changes, this is just a resent in series with other related patches.

 drivers/net/phy/phy.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Joe Hershberger Jan. 27, 2016, 4:04 p.m. UTC | #1
On Wed, Jan 13, 2016 at 7:59 AM, Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> 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.
>
> This is a copy of the patch from Linux kernel, see
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c242a47238fa2a6a54af8a16e62b54e6e031d4bc
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger Jan. 29, 2016, 9:27 p.m. UTC | #2
Hi Alexey,

https://patchwork.ozlabs.org/patch/566943/ was applied to u-boot-net.git.

Thanks!
-Joe
diff mbox

Patch

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 084276f..ec9be6b 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -380,8 +380,6 @@  int genphy_config(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);
@@ -420,8 +418,8 @@  int genphy_config(struct phy_device *phydev)
 			features |= SUPPORTED_1000baseX_Half;
 	}
 
-	phydev->supported = features;
-	phydev->advertising = features;
+	phydev->supported &= features;
+	phydev->advertising &= features;
 
 	genphy_config_aneg(phydev);
 
@@ -445,7 +443,9 @@  static struct phy_driver genphy_driver = {
 	.uid		= 0xffffffff,
 	.mask		= 0xffffffff,
 	.name		= "Generic PHY",
-	.features	= 0,
+	.features	= PHY_GBIT_FEATURES | SUPPORTED_MII |
+			  SUPPORTED_AUI | SUPPORTED_FIBRE |
+			  SUPPORTED_BNC,
 	.config		= genphy_config,
 	.startup	= genphy_startup,
 	.shutdown	= genphy_shutdown,