diff mbox series

[net,v4,3/3] net: stmmac: fix unbalanced ptp clock issue in suspend/resume flow

Message ID 20220713101002.10970-4-biao.huang@mediatek.com (mailing list archive)
State New, archived
Headers show
Series stmmac: dwmac-mediatek: fix clock issue | expand

Commit Message

Biao Huang (黄彪) July 13, 2022, 10:10 a.m. UTC
Current stmmac driver will prepare/enable ptp_ref clock in
stmmac_init_tstamp_counter().

The stmmac_pltfr_noirq_suspend will disable it once in suspend flow.

But in resume flow,
	stmmac_pltfr_noirq_resume --> stmmac_init_tstamp_counter
	stmmac_resume --> stmmac_hw_setup --> stmmac_init_ptp --> stmmac_init_tstamp_counter
ptp_ref clock reference counter increases twice, which leads to unbalance
ptp clock when resume back.

Move ptp_ref clock prepare/enable out of stmmac_init_tstamp_counter to fix it.

Fixes: 0735e639f129d ("net: stmmac: skip only stmmac_ptp_register when resume from suspend")
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c    | 16 ++++++++--------
 .../ethernet/stmicro/stmmac/stmmac_platform.c    |  8 +++++++-
 2 files changed, 15 insertions(+), 9 deletions(-)

Comments

Jakub Kicinski July 14, 2022, 3:39 a.m. UTC | #1
On Wed, 13 Jul 2022 18:10:02 +0800 Biao Huang wrote:
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 197fac587ad5..c230b8b9aab1 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -839,14 +839,6 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags)
>  	if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))
>  		return -EOPNOTSUPP;
>  
> -	ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
> -	if (ret < 0) {
> -		netdev_warn(priv->dev,
> -			    "failed to enable PTP reference clock: %pe\n",
> -			    ERR_PTR(ret));
> -		return ret;
> -	}
> -
>  	stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags);
>  	priv->systime_flags = systime_flags;
>  


drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:837:6: warning: unused variable 'ret' [-Wunused-variable]
        int ret;
            ^
Biao Huang (黄彪) July 14, 2022, 5:37 a.m. UTC | #2
Dear Jakub,
	Thanks for your comments~

On Wed, 2022-07-13 at 20:39 -0700, Jakub Kicinski wrote:
> On Wed, 13 Jul 2022 18:10:02 +0800 Biao Huang wrote:
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index 197fac587ad5..c230b8b9aab1 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -839,14 +839,6 @@ int stmmac_init_tstamp_counter(struct
> > stmmac_priv *priv, u32 systime_flags)
> >  	if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))
> >  		return -EOPNOTSUPP;
> >  
> > -	ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
> > -	if (ret < 0) {
> > -		netdev_warn(priv->dev,
> > -			    "failed to enable PTP reference clock:
> > %pe\n",
> > -			    ERR_PTR(ret));
> > -		return ret;
> > -	}
> > -
> >  	stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags);
> >  	priv->systime_flags = systime_flags;
> >  
> 
> 
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:837:6: warning:
> unused variable 'ret' [-Wunused-variable]
>         int ret;
>             ^
OK, I'll fix it in next send.

Best Regards!
Biao
kernel test robot July 14, 2022, 10:40 p.m. UTC | #3
Hi Biao,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Biao-Huang/stmmac-dwmac-mediatek-fix-clock-issue/20220713-181044
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 22b9c41a3fb8ef4624bcda312665937d2ba98aa7
config: x86_64-randconfig-a016 (https://download.01.org/0day-ci/archive/20220715/202207150612.B3phHNEY-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5e61b9c556267086ef9b743a0b57df302eef831b)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/f145c999bcff52c22cc849bf17f2b30c5e991c0a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Biao-Huang/stmmac-dwmac-mediatek-fix-clock-issue/20220713-181044
        git checkout f145c999bcff52c22cc849bf17f2b30c5e991c0a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/ethernet/stmicro/stmmac/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:837:6: warning: unused variable 'ret' [-Wunused-variable]
           int ret;
               ^
   1 warning generated.


vim +/ret +837 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

891434b18ec0a2 Rayagond Kokatanur 2013-03-26  820  
a6da2bbb0005e6 Holger Assmann     2021-11-21  821  /**
a6da2bbb0005e6 Holger Assmann     2021-11-21  822   * stmmac_init_tstamp_counter - init hardware timestamping counter
a6da2bbb0005e6 Holger Assmann     2021-11-21  823   * @priv: driver private structure
a6da2bbb0005e6 Holger Assmann     2021-11-21  824   * @systime_flags: timestamping flags
a6da2bbb0005e6 Holger Assmann     2021-11-21  825   * Description:
a6da2bbb0005e6 Holger Assmann     2021-11-21  826   * Initialize hardware counter for packet timestamping.
a6da2bbb0005e6 Holger Assmann     2021-11-21  827   * This is valid as long as the interface is open and not suspended.
a6da2bbb0005e6 Holger Assmann     2021-11-21  828   * Will be rerun after resuming from suspend, case in which the timestamping
a6da2bbb0005e6 Holger Assmann     2021-11-21  829   * flags updated by stmmac_hwtstamp_set() also need to be restored.
a6da2bbb0005e6 Holger Assmann     2021-11-21  830   */
a6da2bbb0005e6 Holger Assmann     2021-11-21  831  int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags)
a6da2bbb0005e6 Holger Assmann     2021-11-21  832  {
a6da2bbb0005e6 Holger Assmann     2021-11-21  833  	bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;
a6da2bbb0005e6 Holger Assmann     2021-11-21  834  	struct timespec64 now;
a6da2bbb0005e6 Holger Assmann     2021-11-21  835  	u32 sec_inc = 0;
a6da2bbb0005e6 Holger Assmann     2021-11-21  836  	u64 temp = 0;
a6da2bbb0005e6 Holger Assmann     2021-11-21 @837  	int ret;
a6da2bbb0005e6 Holger Assmann     2021-11-21  838  
a6da2bbb0005e6 Holger Assmann     2021-11-21  839  	if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))
a6da2bbb0005e6 Holger Assmann     2021-11-21  840  		return -EOPNOTSUPP;
a6da2bbb0005e6 Holger Assmann     2021-11-21  841  
a6da2bbb0005e6 Holger Assmann     2021-11-21  842  	stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags);
a6da2bbb0005e6 Holger Assmann     2021-11-21  843  	priv->systime_flags = systime_flags;
a6da2bbb0005e6 Holger Assmann     2021-11-21  844  
a6da2bbb0005e6 Holger Assmann     2021-11-21  845  	/* program Sub Second Increment reg */
a6da2bbb0005e6 Holger Assmann     2021-11-21  846  	stmmac_config_sub_second_increment(priv, priv->ptpaddr,
a6da2bbb0005e6 Holger Assmann     2021-11-21  847  					   priv->plat->clk_ptp_rate,
a6da2bbb0005e6 Holger Assmann     2021-11-21  848  					   xmac, &sec_inc);
a6da2bbb0005e6 Holger Assmann     2021-11-21  849  	temp = div_u64(1000000000ULL, sec_inc);
a6da2bbb0005e6 Holger Assmann     2021-11-21  850  
a6da2bbb0005e6 Holger Assmann     2021-11-21  851  	/* Store sub second increment for later use */
a6da2bbb0005e6 Holger Assmann     2021-11-21  852  	priv->sub_second_inc = sec_inc;
a6da2bbb0005e6 Holger Assmann     2021-11-21  853  
a6da2bbb0005e6 Holger Assmann     2021-11-21  854  	/* calculate default added value:
a6da2bbb0005e6 Holger Assmann     2021-11-21  855  	 * formula is :
a6da2bbb0005e6 Holger Assmann     2021-11-21  856  	 * addend = (2^32)/freq_div_ratio;
a6da2bbb0005e6 Holger Assmann     2021-11-21  857  	 * where, freq_div_ratio = 1e9ns/sec_inc
a6da2bbb0005e6 Holger Assmann     2021-11-21  858  	 */
a6da2bbb0005e6 Holger Assmann     2021-11-21  859  	temp = (u64)(temp << 32);
a6da2bbb0005e6 Holger Assmann     2021-11-21  860  	priv->default_addend = div_u64(temp, priv->plat->clk_ptp_rate);
a6da2bbb0005e6 Holger Assmann     2021-11-21  861  	stmmac_config_addend(priv, priv->ptpaddr, priv->default_addend);
a6da2bbb0005e6 Holger Assmann     2021-11-21  862  
a6da2bbb0005e6 Holger Assmann     2021-11-21  863  	/* initialize system time */
a6da2bbb0005e6 Holger Assmann     2021-11-21  864  	ktime_get_real_ts64(&now);
a6da2bbb0005e6 Holger Assmann     2021-11-21  865  
a6da2bbb0005e6 Holger Assmann     2021-11-21  866  	/* lower 32 bits of tv_sec are safe until y2106 */
a6da2bbb0005e6 Holger Assmann     2021-11-21  867  	stmmac_init_systime(priv, priv->ptpaddr, (u32)now.tv_sec, now.tv_nsec);
a6da2bbb0005e6 Holger Assmann     2021-11-21  868  
a6da2bbb0005e6 Holger Assmann     2021-11-21  869  	return 0;
a6da2bbb0005e6 Holger Assmann     2021-11-21  870  }
a6da2bbb0005e6 Holger Assmann     2021-11-21  871  EXPORT_SYMBOL_GPL(stmmac_init_tstamp_counter);
a6da2bbb0005e6 Holger Assmann     2021-11-21  872
Biao Huang (黄彪) July 15, 2022, 7:52 a.m. UTC | #4
Hi,
	This warning is fixed in v5 send, please test with v5.

Best Regards!
Biao

On Fri, 2022-07-15 at 06:40 +0800, kernel test robot wrote:
> Hi Biao,
> 
> Thank you for the patch! Perhaps something to improve:
> 
> [auto build test WARNING on net/master]
> 
> url:    
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux/commits/Biao-Huang/stmmac-dwmac-mediatek-fix-clock-issue/20220713-181044__;!!CTRNKA9wMg0ARbw!zSIorkBYIMJM_lsS_i-iPXUHkJnImzF7_legwMzhyi3I_4dNo9-GDn7_MBAjUJw2wA$
>  
> base:   
> https://urldefense.com/v3/__https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git__;!!CTRNKA9wMg0ARbw!zSIorkBYIMJM_lsS_i-iPXUHkJnImzF7_legwMzhyi3I_4dNo9-GDn7_MBA1ViIHxA$
>   22b9c41a3fb8ef4624bcda312665937d2ba98aa7
> config: x86_64-randconfig-a016 (
> https://urldefense.com/v3/__https://download.01.org/0day-ci/archive/20220715/202207150612.B3phHNEY-lkp@intel.com/config__;!!CTRNKA9wMg0ARbw!zSIorkBYIMJM_lsS_i-iPXUHkJnImzF7_legwMzhyi3I_4dNo9-GDn7_MBDrBZ7cUQ$
>  )
> compiler: clang version 15.0.0 (
> https://urldefense.com/v3/__https://github.com/llvm/llvm-project__;!!CTRNKA9wMg0ARbw!zSIorkBYIMJM_lsS_i-iPXUHkJnImzF7_legwMzhyi3I_4dNo9-GDn7_MBB4_f7rKw$
> $  5e61b9c556267086ef9b743a0b57df302eef831b)
> reproduce (this is a W=1 build):
>         wget 
> https://urldefense.com/v3/__https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross__;!!CTRNKA9wMg0ARbw!zSIorkBYIMJM_lsS_i-iPXUHkJnImzF7_legwMzhyi3I_4dNo9-GDn7_MBBCyTTgjA$
>   -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # 
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux/commit/f145c999bcff52c22cc849bf17f2b30c5e991c0a__;!!CTRNKA9wMg0ARbw!zSIorkBYIMJM_lsS_i-iPXUHkJnImzF7_legwMzhyi3I_4dNo9-GDn7_MBCdfrCTBg$
>  
>         git remote add linux-review 
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux__;!!CTRNKA9wMg0ARbw!zSIorkBYIMJM_lsS_i-iPXUHkJnImzF7_legwMzhyi3I_4dNo9-GDn7_MBAnpXqSbQ$
>  
>         git fetch --no-tags linux-review Biao-Huang/stmmac-dwmac-
> mediatek-fix-clock-issue/20220713-181044
>         git checkout f145c999bcff52c22cc849bf17f2b30c5e991c0a
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross
> W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
> drivers/net/ethernet/stmicro/stmmac/
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
> > > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:837:6: warning:
> > > unused variable 'ret' [-Wunused-variable]
> 
>            int ret;
>                ^
>    1 warning generated.
> 
> 
> vim +/ret +837 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> 
> 891434b18ec0a2 Rayagond Kokatanur 2013-03-26  820  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  821  /**
> a6da2bbb0005e6 Holger Assmann     2021-11-21  822   *
> stmmac_init_tstamp_counter - init hardware timestamping counter
> a6da2bbb0005e6 Holger Assmann     2021-11-21  823   * @priv: driver
> private structure
> a6da2bbb0005e6 Holger Assmann     2021-11-21  824   * @systime_flags:
> timestamping flags
> a6da2bbb0005e6 Holger Assmann     2021-11-21  825   * Description:
> a6da2bbb0005e6 Holger Assmann     2021-11-21  826   * Initialize
> hardware counter for packet timestamping.
> a6da2bbb0005e6 Holger Assmann     2021-11-21  827   * This is valid
> as long as the interface is open and not suspended.
> a6da2bbb0005e6 Holger Assmann     2021-11-21  828   * Will be rerun
> after resuming from suspend, case in which the timestamping
> a6da2bbb0005e6 Holger Assmann     2021-11-21  829   * flags updated
> by stmmac_hwtstamp_set() also need to be restored.
> a6da2bbb0005e6 Holger Assmann     2021-11-21  830   */
> a6da2bbb0005e6 Holger Assmann     2021-11-21  831  int
> stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32
> systime_flags)
> a6da2bbb0005e6 Holger Assmann     2021-11-21  832  {
> a6da2bbb0005e6 Holger Assmann     2021-11-21  833  	bool xmac =
> priv->plat->has_gmac4 || priv->plat->has_xgmac;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  834  	struct
> timespec64 now;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  835  	u32 sec_inc =
> 0;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  836  	u64 temp = 0;
> a6da2bbb0005e6 Holger Assmann     2021-11-21 @837  	int ret;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  838  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  839  	if (!(priv-
> >dma_cap.time_stamp || priv->dma_cap.atime_stamp))
> a6da2bbb0005e6 Holger Assmann     2021-11-21  840  		return
> -EOPNOTSUPP;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  841  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  842  	stmmac_config_h
> w_tstamping(priv, priv->ptpaddr, systime_flags);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  843  	priv-
> >systime_flags = systime_flags;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  844  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  845  	/* program Sub
> Second Increment reg */
> a6da2bbb0005e6 Holger Assmann     2021-11-21  846  	stmmac_config_s
> ub_second_increment(priv, priv->ptpaddr,
> a6da2bbb0005e6 Holger Assmann     2021-11-21  847  			
> 		   priv->plat->clk_ptp_rate,
> a6da2bbb0005e6 Holger Assmann     2021-11-21  848  			
> 		   xmac, &sec_inc);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  849  	temp =
> div_u64(1000000000ULL, sec_inc);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  850  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  851  	/* Store sub
> second increment for later use */
> a6da2bbb0005e6 Holger Assmann     2021-11-21  852  	priv-
> >sub_second_inc = sec_inc;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  853  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  854  	/* calculate
> default added value:
> a6da2bbb0005e6 Holger Assmann     2021-11-21  855  	 * formula is :
> a6da2bbb0005e6 Holger Assmann     2021-11-21  856  	 * addend =
> (2^32)/freq_div_ratio;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  857  	 * where,
> freq_div_ratio = 1e9ns/sec_inc
> a6da2bbb0005e6 Holger Assmann     2021-11-21  858  	 */
> a6da2bbb0005e6 Holger Assmann     2021-11-21  859  	temp =
> (u64)(temp << 32);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  860  	priv-
> >default_addend = div_u64(temp, priv->plat->clk_ptp_rate);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  861  	stmmac_config_a
> ddend(priv, priv->ptpaddr, priv->default_addend);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  862  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  863  	/* initialize
> system time */
> a6da2bbb0005e6 Holger Assmann     2021-11-21  864  	ktime_get_real_
> ts64(&now);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  865  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  866  	/* lower 32
> bits of tv_sec are safe until y2106 */
> a6da2bbb0005e6 Holger Assmann     2021-11-21  867  	stmmac_init_sys
> time(priv, priv->ptpaddr, (u32)now.tv_sec, now.tv_nsec);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  868  
> a6da2bbb0005e6 Holger Assmann     2021-11-21  869  	return 0;
> a6da2bbb0005e6 Holger Assmann     2021-11-21  870  }
> a6da2bbb0005e6 Holger Assmann     2021-11-
> 21  871  EXPORT_SYMBOL_GPL(stmmac_init_tstamp_counter);
> a6da2bbb0005e6 Holger Assmann     2021-11-21  872  
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 197fac587ad5..c230b8b9aab1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -839,14 +839,6 @@  int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags)
 	if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))
 		return -EOPNOTSUPP;
 
-	ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
-	if (ret < 0) {
-		netdev_warn(priv->dev,
-			    "failed to enable PTP reference clock: %pe\n",
-			    ERR_PTR(ret));
-		return ret;
-	}
-
 	stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags);
 	priv->systime_flags = systime_flags;
 
@@ -3270,6 +3262,14 @@  static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
 
 	stmmac_mmc_setup(priv);
 
+	if (ptp_register) {
+		ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
+		if (ret < 0)
+			netdev_warn(priv->dev,
+				    "failed to enable PTP reference clock: %pe\n",
+				    ERR_PTR(ret));
+	}
+
 	ret = stmmac_init_ptp(priv);
 	if (ret == -EOPNOTSUPP)
 		netdev_info(priv->dev, "PTP not supported by HW\n");
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 11e1055e8260..9f5cac4000da 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -815,7 +815,13 @@  static int __maybe_unused stmmac_pltfr_noirq_resume(struct device *dev)
 		if (ret)
 			return ret;
 
-		stmmac_init_tstamp_counter(priv, priv->systime_flags);
+		ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
+		if (ret < 0) {
+			netdev_warn(priv->dev,
+				    "failed to enable PTP reference clock: %pe\n",
+				    ERR_PTR(ret));
+			return ret;
+		}
 	}
 
 	return 0;