All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RFC PATCH 0/1] net: phy: Force master mode for RTL8211C
@ 2016-03-22  7:51 Michael Haas
  2016-03-22  7:51 ` [U-Boot] [RFC PATCH] " Michael Haas
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Haas @ 2016-03-22  7:51 UTC (permalink / raw)
  To: u-boot


This patch is an RFC based on recent discussions. It's only lightly
tested. I have yet to verify that the registers are being set correctly.
I'm sending it out now because I have to leave for today.

Note that this patch requires Karsten Merkers '[PATCH] net: phy: Realtek
RTL8211B/C PHY ID fix'.

Series-Version: 2
Series-changes: 2
 - Removed accidental inclusion of Karsten's patch in my first submission of this series.
 - Fix a typo in the code: 6 -> &

Michael



Michael Haas (1):
  net: phy: Force master mode for RTL8211C

 drivers/net/phy/realtek.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

-- 
2.7.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [RFC PATCH] net: phy: Force master mode for RTL8211C
  2016-03-22  7:51 [U-Boot] [RFC PATCH 0/1] net: phy: Force master mode for RTL8211C Michael Haas
@ 2016-03-22  7:51 ` Michael Haas
  2016-03-22  8:09   ` Hans de Goede
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Haas @ 2016-03-22  7:51 UTC (permalink / raw)
  To: u-boot

The RTL8211C found on the A20-OlinuXino-Lime2 does not word in slave
mode. This patch disables master/slave mode autonegotiation and forces
master mode.

The RTL8211C identifies itself as RTL8211B via its UID. This patch uses
the revision number taken from the PHYID2 register to distinguish the
two. The NetBSD driver uses the same approach.

CC: fradav at gmail.com
CC: merker at debian.org
CC: hdegoede at redhat.com
CC: ijc at hellion.org.uk
CC: joe.hershberger at ni.com
Signed-off-by: Michael Haas <haas@computerlinguist.org>
---

 drivers/net/phy/realtek.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 259a87f..97d5712 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -54,6 +54,19 @@ static int rtl8211x_config(struct phy_device *phydev)
 	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
 		  MIIM_RTL8211x_PHY_INTR_DIS);
 
+	int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);
+	int rev = reg & 0xf;
+	if (rev == 3 && phydev->phy_id == 0x1cc912) {
+		/* RTL8211C and RTL8211C are distinguished only by
+		   their revision number */
+		reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
+		/* force manual master/slave configuration */
+		reg |= (1 << 12);
+		/* force master mode */
+		reg | = (1 << 11);
+		phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
+	}
+
 	/* read interrupt status just to clear it */
 	phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
 
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [RFC PATCH] net: phy: Force master mode for RTL8211C
  2016-03-22  7:51 ` [U-Boot] [RFC PATCH] " Michael Haas
@ 2016-03-22  8:09   ` Hans de Goede
  0 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2016-03-22  8:09 UTC (permalink / raw)
  To: u-boot

Hi,

On 22-03-16 08:51, Michael Haas wrote:
> The RTL8211C found on the A20-OlinuXino-Lime2 does not word in slave
> mode. This patch disables master/slave mode autonegotiation and forces
> master mode.
>
> The RTL8211C identifies itself as RTL8211B via its UID. This patch uses
> the revision number taken from the PHYID2 register to distinguish the
> two. The NetBSD driver uses the same approach.
>
> CC: fradav at gmail.com
> CC: merker at debian.org
> CC: hdegoede at redhat.com
> CC: ijc at hellion.org.uk
> CC: joe.hershberger at ni.com
> Signed-off-by: Michael Haas <haas@computerlinguist.org>
> ---
>
>   drivers/net/phy/realtek.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index 259a87f..97d5712 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -54,6 +54,19 @@ static int rtl8211x_config(struct phy_device *phydev)
>   	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
>   		  MIIM_RTL8211x_PHY_INTR_DIS);
>
> +	int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);
> +	int rev = reg & 0xf;
> +	if (rev == 3 && phydev->phy_id == 0x1cc912) {
> +		/* RTL8211C and RTL8211C are distinguished only by
> +		   their revision number */

RTL8211C and RTL8211C -> RTL8211B and RTL8211C ?

Also I would put this comment above the:

	int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);

Line, and put a comment like this above the if :

	/* The RTL8211C is unreliable in slave mode, force master mode */

Code wise everything looks good :)

> +		reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
> +		/* force manual master/slave configuration */
> +		reg |= (1 << 12);
> +		/* force master mode */
> +		reg | = (1 << 11);
> +		phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
> +	}
> +
>   	/* read interrupt status just to clear it */
>   	phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
>
>

Regards,

Hans

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [RFC PATCH] net: phy: Force master mode for RTL8211C
  2016-03-22  7:19 ` [U-Boot] [RFC PATCH] " Michael Haas
@ 2016-03-22  7:40   ` Michael Haas
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Haas @ 2016-03-22  7:40 UTC (permalink / raw)
  To: u-boot

On 03/22/2016 08:19 AM, Michael Haas wrote:
> The RTL8211C found on the A20-OlinuXino-Lime2 does not word in slave
> mode. This patch disables master/slave mode autonegotiation and forces
> master mode.
>
> The RTL8211C identifies itself as RTL8211B via its UID. This patch uses
> the revision number taken from the PHYID2 register to distinguish the
> two. The NetBSD driver uses the same approach.
>
> CC: fradav at gmail.com
> CC: merker at debian.org
> CC: hdegoede at redhat.com
> CC: ijc at hellion.org.uk
> CC: joe.hershberger at ni.com
> Signed-off-by: Michael Haas <haas@computerlinguist.org>
> ---
>
>  drivers/net/phy/realtek.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index 259a87f..cdb3376 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -5,6 +5,7 @@
>   *
>   * Copyright 2010-2011, 2015 Freescale Semiconductor, Inc.
>   * author Andy Fleming
> + * Copyright 2016 Karsten Merker <merker@debian.org>
>   */
>  #include <config.h>
>  #include <common.h>
> @@ -54,6 +55,19 @@ static int rtl8211x_config(struct phy_device *phydev)
>  	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
>  		  MIIM_RTL8211x_PHY_INTR_DIS);
>  
> +	int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);
> +	int rev = reg & 0xf;
> +	if (rev == 3 & 6 phydev->phy_id == 0x1cc912) {
> +		/* RTL8211C and RTL8211C are distinguished only by
> +		   their revision number */
> +		reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
> +		/* force manual master/slave configuration */
> +		reg |= (1 << 12);
> +		/* force master mode */
> +		reg | = (1 << 11);
> +		phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
> +	}
> +
>  	/* read interrupt status just to clear it */
>  	phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
>  
> @@ -223,7 +237,7 @@ static int rtl8211f_startup(struct phy_device *phydev)
>  /* Support for RTL8211B PHY */
>  static struct phy_driver RTL8211B_driver = {
>  	.name = "RealTek RTL8211B",
> -	.uid = 0x1cc910,
> +	.uid = 0x1cc912,
>  	.mask = 0xffffff,
>  	.features = PHY_GBIT_FEATURES,
>  	.config = &rtl8211x_config,

I have accidentally included Karsten Merkers '[PATCH] net: phy: Realtek
RTL8211B/C PHY ID fix' due to a botched call to git am earlier. I'll be
re-sending a clean version, but note that Karsten's patch is required.

Michael

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [RFC PATCH] net: phy: Force master mode for RTL8211C
  2016-03-22  7:19 [U-Boot] [RFC PATCH 0/1] " Michael Haas
@ 2016-03-22  7:19 ` Michael Haas
  2016-03-22  7:40   ` Michael Haas
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Haas @ 2016-03-22  7:19 UTC (permalink / raw)
  To: u-boot

The RTL8211C found on the A20-OlinuXino-Lime2 does not word in slave
mode. This patch disables master/slave mode autonegotiation and forces
master mode.

The RTL8211C identifies itself as RTL8211B via its UID. This patch uses
the revision number taken from the PHYID2 register to distinguish the
two. The NetBSD driver uses the same approach.

CC: fradav at gmail.com
CC: merker at debian.org
CC: hdegoede at redhat.com
CC: ijc at hellion.org.uk
CC: joe.hershberger at ni.com
Signed-off-by: Michael Haas <haas@computerlinguist.org>
---

 drivers/net/phy/realtek.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 259a87f..cdb3376 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -5,6 +5,7 @@
  *
  * Copyright 2010-2011, 2015 Freescale Semiconductor, Inc.
  * author Andy Fleming
+ * Copyright 2016 Karsten Merker <merker@debian.org>
  */
 #include <config.h>
 #include <common.h>
@@ -54,6 +55,19 @@ static int rtl8211x_config(struct phy_device *phydev)
 	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
 		  MIIM_RTL8211x_PHY_INTR_DIS);
 
+	int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);
+	int rev = reg & 0xf;
+	if (rev == 3 & 6 phydev->phy_id == 0x1cc912) {
+		/* RTL8211C and RTL8211C are distinguished only by
+		   their revision number */
+		reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
+		/* force manual master/slave configuration */
+		reg |= (1 << 12);
+		/* force master mode */
+		reg | = (1 << 11);
+		phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
+	}
+
 	/* read interrupt status just to clear it */
 	phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
 
@@ -223,7 +237,7 @@ static int rtl8211f_startup(struct phy_device *phydev)
 /* Support for RTL8211B PHY */
 static struct phy_driver RTL8211B_driver = {
 	.name = "RealTek RTL8211B",
-	.uid = 0x1cc910,
+	.uid = 0x1cc912,
 	.mask = 0xffffff,
 	.features = PHY_GBIT_FEATURES,
 	.config = &rtl8211x_config,
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-22  8:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-22  7:51 [U-Boot] [RFC PATCH 0/1] net: phy: Force master mode for RTL8211C Michael Haas
2016-03-22  7:51 ` [U-Boot] [RFC PATCH] " Michael Haas
2016-03-22  8:09   ` Hans de Goede
  -- strict thread matches above, loose matches on Subject: below --
2016-03-22  7:19 [U-Boot] [RFC PATCH 0/1] " Michael Haas
2016-03-22  7:19 ` [U-Boot] [RFC PATCH] " Michael Haas
2016-03-22  7:40   ` Michael Haas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.