From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
richardcochran@gmail.com, brandon.streiff@ni.com,
Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH net-next 10/10] net: dsa: mv88e6xxx: add workaround for 6341 timestamping
Date: Wed, 14 Feb 2018 01:07:51 +0100 [thread overview]
Message-ID: <1518566871-12213-11-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1518566871-12213-1-git-send-email-andrew@lunn.ch>
From: Brandon Streiff <brandon.streiff@ni.com>
88E6341 devices default to timestamping at the PHY, but due to a
hardware issue, timestamps via this component are unreliable. For
this family, configure the PTP hardware to force the timestamping
to occur at the MAC.
Signed-off-by: Brandon Streiff <brandon.streiff@ni.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/dsa/mv88e6xxx/hwtstamp.c | 13 +++++++++++++
drivers/net/dsa/mv88e6xxx/hwtstamp.h | 9 +++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.c b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
index 1b8f79b2c939..b251d534b70d 100644
--- a/drivers/net/dsa/mv88e6xxx/hwtstamp.c
+++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
@@ -563,6 +563,19 @@ int mv88e6xxx_hwtstamp_setup(struct mv88e6xxx_chip *chip)
if (err)
return err;
+ /* 88E6341 devices default to timestamping at the PHY, but this has
+ * a hardware issue that results in unreliable timestamps. Force
+ * these devices to timestamp at the MAC.
+ */
+ if (chip->info->family == MV88E6XXX_FAMILY_6341) {
+ u16 val = MV88E6341_PTP_CFG_UPDATE |
+ MV88E6341_PTP_CFG_MODE_IDX |
+ MV88E6341_PTP_CFG_MODE_TS_AT_MAC;
+ err = mv88e6xxx_ptp_write(chip, MV88E6341_PTP_CFG, val);
+ if (err)
+ return err;
+ }
+
return 0;
}
diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.h b/drivers/net/dsa/mv88e6xxx/hwtstamp.h
index 18ff39cdab4c..bc71c9212a08 100644
--- a/drivers/net/dsa/mv88e6xxx/hwtstamp.h
+++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.h
@@ -34,6 +34,15 @@
/* Offset 0x02: Timestamp Arrival Capture Pointers */
#define MV88E6XXX_PTP_TS_ARRIVAL_PTR 0x02
+/* Offset 0x07: PTP Global Configuration */
+#define MV88E6341_PTP_CFG 0x07
+#define MV88E6341_PTP_CFG_UPDATE 0x8000
+#define MV88E6341_PTP_CFG_IDX_MASK 0x7f00
+#define MV88E6341_PTP_CFG_DATA_MASK 0x00ff
+#define MV88E6341_PTP_CFG_MODE_IDX 0x0
+#define MV88E6341_PTP_CFG_MODE_TS_AT_PHY 0x00
+#define MV88E6341_PTP_CFG_MODE_TS_AT_MAC 0x80
+
/* Offset 0x08: PTP Interrupt Status */
#define MV88E6XXX_PTP_IRQ_STATUS 0x08
--
2.15.1
next prev parent reply other threads:[~2018-02-14 0:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 0:07 [PATCH net-next 00/10] PTP support for DSA and mv88e6xxx driver Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 01/10] net: ptp: Add stub for ptp_classify_raw() Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 02/10] net: dsa: mv88e6xxx: export g2 register accessors Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 03/10] net: dsa: mv88e6xxx: add accessors for PTP/TAI registers Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 04/10] net: dsa: mv88e6xxx: expose switch time as a PTP hardware clock Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 05/10] net: dsa: mv88e6xxx: add support for GPIO configuration Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 06/10] net: dsa: mv88e6xxx: add support for event capture Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 07/10] net: dsa: forward hardware timestamping ioctls to switch driver Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 08/10] net: dsa: forward timestamping callbacks to switch drivers Andrew Lunn
2018-02-14 0:07 ` [PATCH net-next 09/10] net: dsa: mv88e6xxx: add rx/tx timestamping support Andrew Lunn
2018-02-14 0:07 ` Andrew Lunn [this message]
2018-02-14 3:59 ` [PATCH net-next 00/10] PTP support for DSA and mv88e6xxx driver Richard Cochran
2018-02-14 19:38 ` 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=1518566871-12213-11-git-send-email-andrew@lunn.ch \
--to=andrew@lunn.ch \
--cc=brandon.streiff@ni.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=vivien.didelot@savoirfairelinux.com \
/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).