From: Vladimir Oltean <olteanv@gmail.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, andrew@lunn.ch, f.fainelli@gmail.com,
hkallweit1@gmail.com, antoine.tenart@bootlin.com
Subject: [PATCH net-next 3/4] net: phy: mscc: configure both RX and TX internal delays for RGMII
Date: Thu, 19 Mar 2020 23:16:48 +0200 [thread overview]
Message-ID: <20200319211649.10136-4-olteanv@gmail.com> (raw)
In-Reply-To: <20200319211649.10136-1-olteanv@gmail.com>
From: Vladimir Oltean <vladimir.oltean@nxp.com>
The driver appears to be secretly enabling the RX clock skew
irrespective of PHY interface type, which is generally considered a big
no-no.
Make them configurable instead, and add TX internal delays when
necessary too.
While at it, configure a more canonical clock skew of 2.0 nanoseconds
than the current default of 1.1 ns.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/phy/mscc/mscc.h | 2 ++
drivers/net/phy/mscc/mscc_main.c | 16 +++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h
index 56feb14838f3..d4349a327329 100644
--- a/drivers/net/phy/mscc/mscc.h
+++ b/drivers/net/phy/mscc/mscc.h
@@ -164,6 +164,8 @@ enum rgmii_clock_delay {
#define MSCC_PHY_RGMII_CNTL 20
#define RGMII_RX_CLK_DELAY_MASK 0x0070
#define RGMII_RX_CLK_DELAY_POS 4
+#define RGMII_TX_CLK_DELAY_MASK 0x0007
+#define RGMII_TX_CLK_DELAY_POS 0
#define MSCC_PHY_WOL_LOWER_MAC_ADDR 21
#define MSCC_PHY_WOL_MID_MAC_ADDR 22
diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
index 67d96a3e0fad..dd99e0cb9588 100644
--- a/drivers/net/phy/mscc/mscc_main.c
+++ b/drivers/net/phy/mscc/mscc_main.c
@@ -522,16 +522,26 @@ static int vsc85xx_mac_if_set(struct phy_device *phydev,
static int vsc85xx_default_config(struct phy_device *phydev)
{
+ u16 reg_val = 0;
int rc;
- u16 reg_val;
phydev->mdix_ctrl = ETH_TP_MDI_AUTO;
+
+ if (!phy_interface_mode_is_rgmii(phydev->interface))
+ return 0;
+
mutex_lock(&phydev->lock);
- reg_val = RGMII_CLK_DELAY_1_1_NS << RGMII_RX_CLK_DELAY_POS;
+ if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
+ phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
+ reg_val |= RGMII_CLK_DELAY_2_0_NS << RGMII_RX_CLK_DELAY_POS;
+ if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
+ phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
+ reg_val |= RGMII_CLK_DELAY_2_0_NS << RGMII_TX_CLK_DELAY_POS;
rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2,
- MSCC_PHY_RGMII_CNTL, RGMII_RX_CLK_DELAY_MASK,
+ MSCC_PHY_RGMII_CNTL,
+ RGMII_RX_CLK_DELAY_MASK | RGMII_TX_CLK_DELAY_MASK,
reg_val);
mutex_unlock(&phydev->lock);
--
2.17.1
next prev parent reply other threads:[~2020-03-19 21:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-19 21:16 [PATCH net-next 0/4] MSCC PHY: RGMII delays and VSC8502 support Vladimir Oltean
2020-03-19 21:16 ` [PATCH net-next 1/4] net: phy: mscc: rename enum rgmii_rx_clock_delay to rgmii_clock_delay Vladimir Oltean
2020-03-20 10:09 ` Andrew Lunn
2020-03-20 10:38 ` Vladimir Oltean
2020-03-20 11:04 ` Antoine Tenart
2020-03-20 11:32 ` Vladimir Oltean
2020-03-21 17:01 ` Andrew Lunn
2020-03-21 17:28 ` Vladimir Oltean
2020-03-20 20:59 ` Florian Fainelli
2020-03-19 21:16 ` [PATCH net-next 2/4] net: phy: mscc: accept all RGMII species in vsc85xx_mac_if_set Vladimir Oltean
2020-03-20 20:58 ` Florian Fainelli
2020-03-19 21:16 ` Vladimir Oltean [this message]
2020-03-19 21:16 ` [PATCH net-next 4/4] net: phy: mscc: add support for VSC8502 Vladimir Oltean
2020-03-24 3:52 ` [PATCH net-next 0/4] MSCC PHY: RGMII delays and VSC8502 support David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200319211649.10136-4-olteanv@gmail.com \
--to=olteanv@gmail.com \
--cc=andrew@lunn.ch \
--cc=antoine.tenart@bootlin.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).