From d9519789d0989ab47355b30fe1bc35f2c327e6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Mon, 21 Sep 2026 19:50:29 +0200 Subject: [PATCH] net: ethernet: ravb: Move programming of gPTP timer interval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit f384ab481cab ("net: ravb: Split GTI computation and set operations") broke apart the operations of computing the timer interval and programming of it. However it kept the programming of the interval in the RAVB main logic. Having split the two apart this can be improved further by moving the programming to the gPTP initialization function, as the first action of the gPTP init function is to wait for the timer interval programming to be acknowledge by the hardware. As an added bonus the interaction with the gPTP registers for the programming can then also be done while holding the gPTP registers lock. Signed-off-by: Niklas Söderlund Reviewed-by: Sergey Shtylyov Link: https://patch.msgid.link/20260921175037.4084310-3-niklas.soderlund+renesas@ragnatech.se Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/renesas/ravb_main.c | 16 ---------------- drivers/net/ethernet/renesas/ravb_ptp.c | 11 ++++++++++- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 36173a09e2fd..a89f6fe7866f 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1846,20 +1846,6 @@ static int ravb_set_config_mode(struct net_device *ndev) return error; } -static void ravb_set_gti(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; - - if (!(info->gptp || info->ccc_gac)) - return; - - ravb_write(ndev, priv->gti_tiv, GTI); - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); -} - static int ravb_compute_gti(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -1974,8 +1960,6 @@ static int ravb_open(struct net_device *ndev) ravb_emac_init(ndev); - ravb_set_gti(ndev); - /* Initialise PTP Clock driver */ if (info->gptp || info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c index 43218bc15b15..ac91a6813368 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c @@ -321,11 +321,20 @@ void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev) priv->ptp.info = ravb_ptp_info; - priv->ptp.default_addend = ravb_read(ndev, GTI); + priv->ptp.default_addend = priv->gti_tiv; priv->ptp.current_addend = priv->ptp.default_addend; spin_lock_irqsave(&priv->lock, flags); + + /* Set gPTP Timer Increment Value. */ + ravb_write(ndev, priv->ptp.default_addend, GTI); + + /* Request GTI loading. */ + ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); + + /* Wait for GIT loading to complete by checking there are no requests. */ ravb_wait(ndev, GCCR, GCCR_TCR, GCCR_TCR_NOREQ); + ravb_modify(ndev, GCCR, GCCR_TCSS, GCCR_TCSS_ADJGPTP); spin_unlock_irqrestore(&priv->lock, flags);