From: Hubert Feurstein <h.feurstein@gmail.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Hubert Feurstein <h.feurstein@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Richard Cochran <richardcochran@gmail.com>,
Fugang Duan <fugang.duan@nxp.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH net-next 3/3] net: fec: add support for PTP system timestamping for MDIO devices
Date: Fri, 16 Aug 2019 18:31:57 +0200 [thread overview]
Message-ID: <20190816163157.25314-4-h.feurstein@gmail.com> (raw)
In-Reply-To: <20190816163157.25314-1-h.feurstein@gmail.com>
In order to improve the synchronisation precision of phc2sys (from
the linuxptp project) for devices like switches which are attached
to the MDIO bus, it is necessary the get the system timestamps as
close as possible to the access which causes the PTP timestamp
register to be snapshotted in the switch hardware. Usually this is
triggered by an MDIO write access, the snapshotted timestamp is then
transferred by several MDIO reads.
The ptp_read_system_*ts functions already check the ptp_sts pointer.
Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
---
drivers/net/ethernet/freescale/fec_main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 2f6057e7335d..60e866631b61 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1815,10 +1815,12 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
reinit_completion(&fep->mdio_done);
/* start a write op */
+ ptp_read_system_prets(bus->ptp_sts);
writel(FEC_MMFR_ST | FEC_MMFR_OP_WRITE |
FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) |
FEC_MMFR_TA | FEC_MMFR_DATA(value),
fep->hwp + FEC_MII_DATA);
+ ptp_read_system_postts(bus->ptp_sts);
/* wait for end of transfer */
time_left = wait_for_completion_timeout(&fep->mdio_done,
@@ -2034,6 +2036,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
pdev->name, fep->dev_id + 1);
fep->mii_bus->priv = fep;
fep->mii_bus->parent = &pdev->dev;
+ fep->mii_bus->ptp_sts_supported = true;
node = of_get_child_by_name(pdev->dev.of_node, "mdio");
err = of_mdiobus_register(fep->mii_bus, node);
--
2.22.1
prev parent reply other threads:[~2019-08-16 16:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 16:31 [PATCH net-next 0/3] Improve phc2sys precision for mv88e6xxx switch in combination with imx6-fec Hubert Feurstein
2019-08-16 16:31 ` [PATCH net-next 1/3] net: mdio: add support for passing a PTP system timestamp to the mii_bus driver Hubert Feurstein
2019-08-17 3:30 ` Richard Cochran
2019-08-19 13:17 ` Andrew Lunn
2019-08-19 13:34 ` Vladimir Oltean
2019-08-19 13:37 ` Vladimir Oltean
2019-08-19 15:14 ` Andrew Lunn
2019-08-16 16:31 ` [PATCH net-next 2/3] net: dsa: mv88e6xxx: extend PTP gettime function to read system clock Hubert Feurstein
2019-08-19 13:27 ` Andrew Lunn
2019-08-19 15:16 ` Vivien Didelot
2019-08-19 15:20 ` Andrew Lunn
2019-08-19 17:14 ` Hubert Feurstein
2019-08-19 17:34 ` Andrew Lunn
2019-08-16 16:31 ` Hubert Feurstein [this message]
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=20190816163157.25314-4-h.feurstein@gmail.com \
--to=h.feurstein@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=fugang.duan@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=richardcochran@gmail.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).