[U-Boot] [PATCH] Do not force master mode on unaffected PHY's

The current implementation to force the PHY into master mode is to have a define which affects all realtek PHY's. This is not needed as the problem only exists in the RTL8211C chips. Let us thus turn this into a quirk flag instead.

The BIT macro is the preferred method to set bits. This patch adds the bit macro and converts bit invocations.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/phy/realtek.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 7a99cb0..35b934b 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -9,13 +9,14 @@ */ #include <config.h> #include <common.h> +#include <linux/bitops.h> #include <phy.h>
#define PHY_AUTONEGOTIATE_TIMEOUT 5000
/* RTL8211x 1000BASE-T Control Register */ -#define MIIM_RTL8211x_CTRL1000T_MSCE (1 << 12); -#define MIIM_RTL8211X_CTRL1000T_MASTER (1 << 11); +#define MIIM_RTL8211x_CTRL1000T_MSCE BIT(12); +#define MIIM_RTL8211X_CTRL1000T_MASTER BIT(11);
/* RTL8211x PHY Status Register */ #define MIIM_RTL8211x_PHY_STATUS 0x11

On Tue, 2016-11-08 at 17:38 +0100, Olliver Schinagl wrote:
The BIT macro is the preferred method to set bits. This patch adds the bit macro and converts bit invocations.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
drivers/net/phy/realtek.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 7a99cb0..35b934b 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -9,13 +9,14 @@ */ #include <config.h> #include <common.h> +#include <linux/bitops.h> #include <phy.h> #define PHY_AUTONEGOTIATE_TIMEOUT 5000 /* RTL8211x 1000BASE-T Control Register */ -#define MIIM_RTL8211x_CTRL1000T_MSCE (1 << 12); -#define MIIM_RTL8211X_CTRL1000T_MASTER (1 << 11); +#define MIIM_RTL8211x_CTRL1000T_MSCE BIT(12); +#define MIIM_RTL8211X_CTRL1000T_MASTER BIT(11);
You should also get rid of semicolons.
/* RTL8211x PHY Status Register */ #define MIIM_RTL8211x_PHY_STATUS 0x11 -- 2.10.2

Hi,
On 09-11-16 22:42, Priit Laes wrote:
On Tue, 2016-11-08 at 17:38 +0100, Olliver Schinagl wrote:
The BIT macro is the preferred method to set bits. This patch adds the bit macro and converts bit invocations.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
drivers/net/phy/realtek.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 7a99cb0..35b934b 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -9,13 +9,14 @@ */ #include <config.h> #include <common.h> +#include <linux/bitops.h> #include <phy.h>
#define PHY_AUTONEGOTIATE_TIMEOUT 5000
/* RTL8211x 1000BASE-T Control Register */ -#define MIIM_RTL8211x_CTRL1000T_MSCE (1 << 12); -#define MIIM_RTL8211X_CTRL1000T_MASTER (1 << 11); +#define MIIM_RTL8211x_CTRL1000T_MSCE BIT(12); +#define MIIM_RTL8211X_CTRL1000T_MASTER BIT(11);
ah yeah, didn't even notice it, it's actually wrong. Also here, if that's all I don't mind if it gets fixed in the merge, if it needs a v2 I'll gladly do it however.
Olliver
You should also get rid of semicolons.
/* RTL8211x PHY Status Register */
#define MIIM_RTL8211x_PHY_STATUS 0x11
2.10.2

On Tue, Nov 8, 2016 at 10:38 AM, Olliver Schinagl oliver@schinagl.nl wrote:
The BIT macro is the preferred method to set bits. This patch adds the bit macro and converts bit invocations.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
Acked-by: Joe Hershberger joe.hershberger@ni.com
I can clean up the ';' inline.

Hi oliver@schinagl.nl,
https://patchwork.ozlabs.org/patch/692379/ was applied to u-boot-net.git.
Thanks! -Joe

All internal defines in the realtek phy are with a small X, except MIIM_RTL8211X_CTRL1000T_MASTER. Make this more concistent
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/phy/realtek.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 35b934b..62b8c1e 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -16,7 +16,7 @@
/* RTL8211x 1000BASE-T Control Register */ #define MIIM_RTL8211x_CTRL1000T_MSCE BIT(12); -#define MIIM_RTL8211X_CTRL1000T_MASTER BIT(11); +#define MIIM_RTL8211x_CTRL1000T_MASTER BIT(11);
/* RTL8211x PHY Status Register */ #define MIIM_RTL8211x_PHY_STATUS 0x11 @@ -64,7 +64,7 @@ static int rtl8211x_config(struct phy_device *phydev) /* force manual master/slave configuration */ reg |= MIIM_RTL8211x_CTRL1000T_MSCE; /* force master mode */ - reg |= MIIM_RTL8211X_CTRL1000T_MASTER; + reg |= MIIM_RTL8211x_CTRL1000T_MASTER; phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg); #endif /* read interrupt status just to clear it */

Small nitpick:
El 08/11/16 a las 13:38, Olliver Schinagl escribió:
All internal defines in the realtek phy are with a small X, except MIIM_RTL8211X_CTRL1000T_MASTER. Make this more concistent
s/concistent/consistent/ both here and on the subject :)
Cheers! Emilio

Crap! I thought I spotted it but wasn't sure :)
If there needs to be a v2 i'll fix it; if the v1 is accepted, Joe could hopefully fix that in the message *wink* :)
Olliver
On 09-11-16 00:17, Emilio López wrote:
Small nitpick:
El 08/11/16 a las 13:38, Olliver Schinagl escribió:
All internal defines in the realtek phy are with a small X, except MIIM_RTL8211X_CTRL1000T_MASTER. Make this more concistent
s/concistent/consistent/ both here and on the subject :)
Cheers! Emilio

On Tue, Nov 8, 2016 at 10:38 AM, Olliver Schinagl oliver@schinagl.nl wrote:
All internal defines in the realtek phy are with a small X, except MIIM_RTL8211X_CTRL1000T_MASTER. Make this more concistent
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
Acked-by: Joe Hershberger joe.hershberger@ni.com
I'll fix up the typo.

Hi oliver@schinagl.nl,
https://patchwork.ozlabs.org/patch/692377/ was applied to u-boot-net.git.
Thanks! -Joe

Commit 525d187af ("net: phy: Optionally force master mode for RTL PHY") added the define to force the PHY into master mode. Unfortunatly this is an all or nothing switch. So it applies to either all PHY's or no PHY's.
The bug that define tried to solve was a buggy PLL in the RTL8211C only.
The Olimex OLinuXino Lime2 has gotten an upgrade where the PHY was replaced with an RTL8211E. With this define however, both lime2 boards are either forced to master mode or not. We could of course have a binary for each board, but the following patch fixes this by adding a 'quirk' to the flags to the rtl8211b and rtl8211c only. It is now possible to force master mode, but only have it apply to the rtl8211b and rtl8211c.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/phy/realtek.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 62b8c1e..635acf5 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -12,6 +12,8 @@ #include <linux/bitops.h> #include <phy.h>
+#define PHY_RTL8211x_FORCE_MASTER BIT(1) + #define PHY_AUTONEGOTIATE_TIMEOUT 5000
/* RTL8211x 1000BASE-T Control Register */ @@ -49,6 +51,15 @@ #define MIIM_RTL8211F_TX_DELAY 0x100 #define MIIM_RTL8211F_LCR 0x10
+static int rtl8211b_probe(struct phy_device *phydev) +{ +#ifdef CONFIG_RTL8211X_PHY_FORCE_MASTER + phydev->flags |= PHY_RTL8211x_FORCE_MASTER; +#endif + + return 0; +} + /* RealTek RTL8211x */ static int rtl8211x_config(struct phy_device *phydev) { @@ -59,14 +70,17 @@ 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 + + if (phydev->flags & PHY_RTL8211x_FORCE_MASTER) { + unsigned int reg; + + 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); + } /* read interrupt status just to clear it */ phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
@@ -249,6 +263,7 @@ static struct phy_driver RTL8211B_driver = { .uid = 0x1cc912, .mask = 0xffffff, .features = PHY_GBIT_FEATURES, + .probe = &rtl8211b_probe, .config = &rtl8211x_config, .startup = &rtl8211x_startup, .shutdown = &genphy_shutdown,

On Tue, Nov 8, 2016 at 10:38 AM, Olliver Schinagl oliver@schinagl.nl wrote:
Commit 525d187af ("net: phy: Optionally force master mode for RTL PHY") added the define to force the PHY into master mode. Unfortunatly this is an all or nothing switch. So it applies to either all PHY's or no PHY's.
The bug that define tried to solve was a buggy PLL in the RTL8211C only.
The Olimex OLinuXino Lime2 has gotten an upgrade where the PHY was replaced with an RTL8211E. With this define however, both lime2 boards are either forced to master mode or not. We could of course have a binary for each board, but the following patch fixes this by adding a 'quirk' to the flags to the rtl8211b and rtl8211c only. It is now possible to force master mode, but only have it apply to the rtl8211b and rtl8211c.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
Acked-by: Joe Hershberger joe.hershberger@ni.com

Hi oliver@schinagl.nl,
https://patchwork.ozlabs.org/patch/692378/ was applied to u-boot-net.git.
Thanks! -Joe

Hi,
On 08-11-16 17:38, Olliver Schinagl wrote:
The current implementation to force the PHY into master mode is to have a define which affects all realtek PHY's. This is not needed as the problem only exists in the RTL8211C chips. Let us thus turn this into a quirk flag instead.
Series looks good to me:
Reviewed-by: Hans de Goede hdegoede@redhat.com
Regards,
Hans

Hey Hans,
On 14-11-16 12:26, Hans de Goede wrote:
Hi,
On 08-11-16 17:38, Olliver Schinagl wrote:
The current implementation to force the PHY into master mode is to have a define which affects all realtek PHY's. This is not needed as the problem only exists in the RTL8211C chips. Let us thus turn this into a quirk flag instead.
Series looks good to me:
Reviewed-by: Hans de Goede hdegoede@redhat.com
Thanks, but keep your eye on the thread. I'm working on a v3 where i'm pulling the eeprom stuff out of the sunxi stuff, and in the net-uclass layer!
Olliver
Regards,
Hans

Hi,
On 14-11-16 15:11, Olliver Schinagl wrote:
Hey Hans,
On 14-11-16 12:26, Hans de Goede wrote:
Hi,
On 08-11-16 17:38, Olliver Schinagl wrote:
The current implementation to force the PHY into master mode is to have a define which affects all realtek PHY's. This is not needed as the problem only exists in the RTL8211C chips. Let us thus turn this into a quirk flag instead.
Series looks good to me:
Reviewed-by: Hans de Goede hdegoede@redhat.com
Thanks, but keep your eye on the thread. I'm working on a v3 where i'm pulling the eeprom stuff out of the sunxi stuff, and in the net-uclass layer!
Erm, this is another series :)
Regards,
Hans

Hans,
On 14-11-16 15:13, Hans de Goede wrote:
Hi,
On 14-11-16 15:11, Olliver Schinagl wrote:
Hey Hans,
On 14-11-16 12:26, Hans de Goede wrote:
Hi,
On 08-11-16 17:38, Olliver Schinagl wrote:
The current implementation to force the PHY into master mode is to have a define which affects all realtek PHY's. This is not needed as the problem only exists in the RTL8211C chips. Let us thus turn this into a quirk flag instead.
Series looks good to me:
Reviewed-by: Hans de Goede hdegoede@redhat.com
Thanks, but keep your eye on the thread. I'm working on a v3 where i'm pulling the eeprom stuff out of the sunxi stuff, and in the net-uclass layer!
Erm, this is another series :)
Ah poop. You are right! Sorry :)
Regards,
Hans
participants (6)
-
Emilio López
-
Hans de Goede
-
Joe Hershberger
-
Joe Hershberger
-
Olliver Schinagl
-
Priit Laes