[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230616135323.98215-15-radu-nicolae.pirea@oss.nxp.com>
Date: Fri, 16 Jun 2023 16:53:23 +0300
From: "Radu Pirea (NXP OSS)" <radu-nicolae.pirea@....nxp.com>
To: andrew@...n.ch,
hkallweit1@...il.com,
linux@...linux.org.uk,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
richardcochran@...il.com
Cc: netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
sebastian.tobuschat@....com,
"Radu Pirea (NXP OSS)" <radu-nicolae.pirea@....nxp.com>
Subject: [PATCH net-next v1 14/14] net: phy: nxp-c45-tja11xx: timestamp reading workaround for TJA1120
On TJA1120 engineering samples, the new timestamp is stuck in the FIFO.
If the MORE_TS bit is set and the VALID bit is not set, we know that we
have a timestamp in the FIFO but not in the buffer.
To move the new timestamp in the buffer registers, the current
timestamp(which is invalid) is unlocked by writing any of the buffer
registers.
Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@....nxp.com>
---
drivers/net/phy/nxp-c45-tja11xx.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
index 0d22eb7534dc..3543c8fe099c 100644
--- a/drivers/net/phy/nxp-c45-tja11xx.c
+++ b/drivers/net/phy/nxp-c45-tja11xx.c
@@ -532,15 +532,30 @@ static bool nxp_c45_get_extts(struct nxp_c45_phy *priv,
static bool tja1120_get_extts(struct nxp_c45_phy *priv,
struct timespec64 *extts)
{
+ const struct nxp_c45_regmap *regmap = nxp_c45_get_regmap(priv->phydev);
+ bool more_ts;
bool valid;
u16 reg;
+ reg = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1,
+ regmap->vend1_ext_trg_ctrl);
+ more_ts = !!(reg & TJA1120_MORE_TS);
+
reg = phy_read_mmd(priv->phydev, MDIO_MMD_VEND1,
TJA1120_VEND1_PTP_TRIG_DATA_S);
valid = !!(reg & TJA1120_TS_VALID);
if (valid)
return nxp_c45_get_extts(priv, extts);
+ /* Bug workaround for TJA1120 enegineering samples: move the new
+ * timestamp from the FIFO to the buffer.
+ */
+ if (more_ts) {
+ phy_write_mmd(priv->phydev, MDIO_MMD_VEND1,
+ regmap->vend1_ext_trg_ctrl, RING_DONE);
+ return nxp_c45_get_extts(priv, extts);
+ }
+
return valid;
}
@@ -588,15 +603,25 @@ static bool tja1120_get_hwtxts(struct nxp_c45_phy *priv,
struct nxp_c45_hwts *hwts)
{
struct phy_device *phydev = priv->phydev;
+ bool more_ts;
bool valid;
u16 reg;
mutex_lock(&priv->ptp_lock);
+ reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, TJA1120_EGRESS_TS_END);
+ more_ts = !!(reg & TJA1120_MORE_TS);
reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, TJA1120_EGRESS_TS_DATA_S);
valid = !!(reg & TJA1120_TS_VALID);
- if (!valid)
- goto tja1120_get_hwtxts_out;
-
+ if (!valid) {
+ if (!more_ts)
+ goto tja1120_get_hwtxts_out;
+ /* Bug workaround for TJA1120 enegineering samples: move the
+ * new timestamp from the FIFO to the buffer.
+ */
+ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
+ TJA1120_EGRESS_TS_END, TJA1120_TS_VALID);
+ valid = true;
+ }
nxp_c45_read_egress_ts(priv, hwts);
phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, TJA1120_EGRESS_TS_DATA_S,
TJA1120_TS_VALID);
--
2.34.1
Powered by blists - more mailing lists