diff mbox

[U-Boot,v3,1/4] net: phy: Optionally force master mode for RTL PHY

Message ID 1458801986-21625-2-git-send-email-haas@computerlinguist.org
State Superseded
Delegated to: Hans de Goede
Headers show

Commit Message

Michael Haas March 24, 2016, 6:46 a.m. UTC
This patch introduces CONFIG_RTL8211X_PHY_FORCE_MASTER. If this
define is set, RTL8211x PHYs will have their 1000BASE-T
master/slave autonegotiation disabled and forced to master mode.

This is helpful for PHYs like the RTL8211C which produce unstable links
in slave mode. Such problems have been found on the A20-Olimex-SOM-EVB
and A20-OLinuXino-Lime2.

There is no proper way to identify affected PHYs as the RTL8211C shares
its UID with the RTL8211B. Thus, this fixes requires the introduction of
an #ifdef.

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

Changes in v3:
 - Remove incorrect detection of RTL8211CL and use #ifdef instead
   (thanks to Karsten Merker)
 - Introduced constants for register bits

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

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

Comments

Karsten Merker March 24, 2016, 7:40 p.m. UTC | #1
On Thu, Mar 24, 2016 at 07:46:23AM +0100, Michael Haas wrote:
> This patch introduces CONFIG_RTL8211X_PHY_FORCE_MASTER. If this
> define is set, RTL8211x PHYs will have their 1000BASE-T

s/RTL8211x PHYs/RTL8211x PHYs (except for the RTL8211F)/ ?

> master/slave autonegotiation disabled and forced to master mode.
> 
> This is helpful for PHYs like the RTL8211C which produce unstable links
> in slave mode. Such problems have been found on the A20-Olimex-SOM-EVB
> and A20-OLinuXino-Lime2.
> 
> There is no proper way to identify affected PHYs as the RTL8211C shares

s/to identify affected PHYs/to identify affected PHYs in software/ ?

> its UID with the RTL8211B. Thus, this fixes requires the introduction of

s/fixes/fix/

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

I also agree with the review comments from Hans de Goede and Chen-Yu Tsai.

Tested-by: Karsten Merker <merker@debian.org> [on an A20-Olimex-SOM-EVB]

Regards,
Karsten

> ---
> 
> Changes in v3:
>  - Remove incorrect detection of RTL8211CL and use #ifdef instead
>    (thanks to Karsten Merker)
>  - Introduced constants for register bits
> 
> Changes in v2:
>  - Removed accidental inclusion of Karsten's patch in my first submission of this series.
>  - Fix a typo in the code: 6 -> &
> 
>  drivers/net/phy/realtek.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index 259a87f..359ec50 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -12,6 +12,10 @@
>  
>  #define PHY_AUTONEGOTIATE_TIMEOUT 5000
>  
> +/* RTL8211x 1000BASE-T Control Register */
> +#define MIIM_RTL8211x_CTRL1000T_MSCE (1 << 12);
> +#define MIIM_RTL8211X_CTRL1000T_MASTER (1 << 11);
> +
>  /* RTL8211x PHY Status Register */
>  #define MIIM_RTL8211x_PHY_STATUS       0x11
>  #define MIIM_RTL8211x_PHYSTAT_SPEED    0xc000
> @@ -53,7 +57,14 @@ static int rtl8211x_config(struct phy_device *phydev)
>  	 */
>  	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
>  		  MIIM_RTL8211x_PHY_INTR_DIS);
> -
> +#ifdef CONFIG_RTL8211X_PHY_FORCE_MASTER
> +	unsigned int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
> +	/* force manual master/slave configuration */
> +	reg |= MIIM_RTL8211x_CTRL1000T_MSCE;
> +	/* force master mode */
> +	reg |= MIIM_RTL8211X_CTRL1000T_MASTER;
> +	phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
> +#endif
>  	/* read interrupt status just to clear it */
>  	phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
>  
> -- 
> 2.7.2
>
diff mbox

Patch

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 259a87f..359ec50 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -12,6 +12,10 @@ 
 
 #define PHY_AUTONEGOTIATE_TIMEOUT 5000
 
+/* RTL8211x 1000BASE-T Control Register */
+#define MIIM_RTL8211x_CTRL1000T_MSCE (1 << 12);
+#define MIIM_RTL8211X_CTRL1000T_MASTER (1 << 11);
+
 /* RTL8211x PHY Status Register */
 #define MIIM_RTL8211x_PHY_STATUS       0x11
 #define MIIM_RTL8211x_PHYSTAT_SPEED    0xc000
@@ -53,7 +57,14 @@  static int rtl8211x_config(struct phy_device *phydev)
 	 */
 	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
 		  MIIM_RTL8211x_PHY_INTR_DIS);
-
+#ifdef CONFIG_RTL8211X_PHY_FORCE_MASTER
+	unsigned int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
+	/* force manual master/slave configuration */
+	reg |= MIIM_RTL8211x_CTRL1000T_MSCE;
+	/* force master mode */
+	reg |= MIIM_RTL8211X_CTRL1000T_MASTER;
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
+#endif
 	/* read interrupt status just to clear it */
 	phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);