diff mbox series

[3/3] net: dsa: microchip: lan937x: disable VPHY output

Message ID 20240403180226.1641383-3-l.stach@pengutronix.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [1/3] net: dsa: microchip: lan9372: fix TX PHY access | expand

Checks

Context Check Description
netdev/series_format warning Series does not have a cover letter; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 943 this patch: 943
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 3 maintainers not CCed: pabeni@redhat.com kuba@kernel.org edumazet@google.com
netdev/build_clang success Errors and warnings before: 954 this patch: 954
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 954 this patch: 954
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-04-04--00-00 (tests: 950)

Commit Message

Lucas Stach April 3, 2024, 6:02 p.m. UTC
While the documented VPHY out-of-reset configuration should autonegotiate
the maximum supported link speed on the CPU interface, that doesn't work
on RGMII links, where the VPHY negotiates 100MBit speed. This causes the
RGMII TX interface to run with a wrong clock rate.

Disable the VPHY output altogether, so it doesn't interfere with the
CPU interface configuration set via fixed-link. The VPHY is a compatibility
functionality to be able to attach network drivers without fixed-link
support to the switch, which generally should not be needed with linux
network drivers.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/dsa/microchip/lan937x_main.c | 3 +++
 drivers/net/dsa/microchip/lan937x_reg.h  | 4 ++++
 2 files changed, 7 insertions(+)

Comments

Andrew Lunn April 4, 2024, 12:42 p.m. UTC | #1
On Wed, Apr 03, 2024 at 08:02:26PM +0200, Lucas Stach wrote:
> While the documented VPHY out-of-reset configuration should autonegotiate
> the maximum supported link speed on the CPU interface, that doesn't work
> on RGMII links, where the VPHY negotiates 100MBit speed. This causes the
> RGMII TX interface to run with a wrong clock rate.
> 
> Disable the VPHY output altogether, so it doesn't interfere with the
> CPU interface configuration set via fixed-link. The VPHY is a compatibility
> functionality to be able to attach network drivers without fixed-link
> support to the switch, which generally should not be needed with linux
> network drivers.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Arun Ramadoss April 4, 2024, 2:29 p.m. UTC | #2
Hi Lucas,

On Wed, 2024-04-03 at 20:02 +0200, Lucas Stach wrote:
> [Some people who received this message don't often get email from
> l.stach@pengutronix.de. Learn why this is important at 
> https://aka.ms/LearnAboutSenderIdentification ]
> 
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> While the documented VPHY out-of-reset configuration should
> autonegotiate
> the maximum supported link speed on the CPU interface, that doesn't
> work
> on RGMII links, where the VPHY negotiates 100MBit speed. This causes
> the
> RGMII TX interface to run with a wrong clock rate.
> 
> Disable the VPHY output altogether, so it doesn't interfere with the
> CPU interface configuration set via fixed-link. The VPHY is a
> compatibility
> functionality to be able to attach network drivers without fixed-link
> support to the switch, which generally should not be needed with
> linux
> network drivers.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

I believe, if targeted to net, fixes tag is required. 

> ---
>  drivers/net/dsa/microchip/lan937x_main.c | 3 +++
>  drivers/net/dsa/microchip/lan937x_reg.h  | 4 ++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/net/dsa/microchip/lan937x_main.c
> b/drivers/net/dsa/microchip/lan937x_main.c
> index 04fa74c7dcbe..9db1d278ee9b 100644
> --- a/drivers/net/dsa/microchip/lan937x_main.c
> +++ b/drivers/net/dsa/microchip/lan937x_main.c
> @@ -400,6 +400,9 @@ int lan937x_setup(struct dsa_switch *ds)
>         lan937x_cfg(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1,
>                     (SW_CLK125_ENB | SW_CLK25_ENB), true);
> 
> +       /* disable VPHY output*/
> +       ksz_rmw32(dev, REG_SW_CFG_STRAP_OVR, SW_VPHY_DISABLE,
> SW_VPHY_DISABLE);

ksz_rmw32 returns value, it needs to be handled. 

> +
>         return 0;
>  }
>
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index 04fa74c7dcbe..9db1d278ee9b 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -400,6 +400,9 @@  int lan937x_setup(struct dsa_switch *ds)
 	lan937x_cfg(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1,
 		    (SW_CLK125_ENB | SW_CLK25_ENB), true);
 
+	/* disable VPHY output*/
+	ksz_rmw32(dev, REG_SW_CFG_STRAP_OVR, SW_VPHY_DISABLE, SW_VPHY_DISABLE);
+
 	return 0;
 }
 
diff --git a/drivers/net/dsa/microchip/lan937x_reg.h b/drivers/net/dsa/microchip/lan937x_reg.h
index e36bcb155f54..be553e23a964 100644
--- a/drivers/net/dsa/microchip/lan937x_reg.h
+++ b/drivers/net/dsa/microchip/lan937x_reg.h
@@ -37,6 +37,10 @@ 
 #define SW_CLK125_ENB			BIT(1)
 #define SW_CLK25_ENB			BIT(0)
 
+/* 2 - PHY Control */
+#define REG_SW_CFG_STRAP_OVR		0x214
+#define SW_VPHY_DISABLE			BIT(31)
+
 /* 3 - Operation Control */
 #define REG_SW_OPERATION		0x0300