amd-xgbe: Add PPS periodic output support
Subsystems (3)
Raju Rangoju
maintainerPATCH v3 1/1 amd-xgbe: Add PPS periodic output support
Add support for hardware PPS (Pulse Per Second) output to the AMD XGBE driver. The implementation enables flexible periodic output mode, exposing it via the PTP per_out interface.
The driver supports configuring PPS output using the standard PTP subsystem, allowing precise periodic signal generation for time synchronization applications.
The feature has been verified using the testptp tool and oscilloscope.
---
Changes since v2:
- avoid redundant checks in xgbe_enable()
- simplify the mask calculation
Changes since v1:
- add sanity check to prevent pps_out_num and aux_snap_num exceeding the limit
drivers/net/ethernet/amd/xgbe/Makefile | 2 +- drivers/net/ethernet/amd/xgbe/xgbe-common.h | 46 ++++++++++++- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 15 +++++ drivers/net/ethernet/amd/xgbe/xgbe-pps.c | 73 +++++++++++++++++++++ drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 26 +++++++- drivers/net/ethernet/amd/xgbe/xgbe.h | 16 +++++ 6 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 drivers/net/ethernet/amd/xgbe/xgbe-pps.c
drivers/net/ethernet/amd/xgbe/Makefile +1 -1
@@ -3,7 +3,7 @@ obj-$(CONFIG_AMD_XGBE) += amd-xgbe.o amd-xgbe-objs := xgbe-main.o xgbe-drv.o xgbe-dev.o \ xgbe-desc.o xgbe-ethtool.o xgbe-mdio.o \ - xgbe-hwtstamp.o xgbe-ptp.o \ + xgbe-hwtstamp.o xgbe-ptp.o xgbe-pps.o\ xgbe-i2c.o xgbe-phy-v1.o xgbe-phy-v2.o \ xgbe-platform.o
drivers/net/ethernet/amd/xgbe/xgbe-common.h +43 -3
76 lines not on this page · raw message
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +15 -0
@@ -691,6 +691,21 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) hw_feat->pps_out_num =XGMAC_GET_BITS (mac_hfr2,MAC_HWF2R ,PPSOUTNUM ); hw_feat->aux_snap_num =XGMAC_GET_BITS (mac_hfr2,MAC_HWF2R ,AUXSNAPNUM ); +/* Sanity check and warn if hardware reports more than supported */ +if (hw_feat->pps_out_num >XGBE_MAX_PPS_OUT ) { +dev_warn (pdata->dev, +"Hardware reports %u PPS outputs, limiting to %u\n" , + hw_feat->pps_out_num,XGBE_MAX_PPS_OUT ); + hw_feat->pps_out_num =XGBE_MAX_PPS_OUT ; + } + +if (hw_feat->aux_snap_num >XGBE_MAX_AUX_SNAP ) { +dev_warn (pdata->dev, +"Hardware reports %u aux snapshot inputs, limiting to %u\n" , + hw_feat->aux_snap_num,XGBE_MAX_AUX_SNAP ); + hw_feat->aux_snap_num =XGBE_MAX_AUX_SNAP ; + } +/* Translate the Hash Table size into actual number */ switch (hw_feat->hash_table_size) {case 0 :
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +73 -0
73 lines not on this page · raw message
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +25 -1
@@ -106,7 +106,29 @@ static int xgbe_settime(struct ptp_clock_info *info,static int xgbe_enable (struct ptp_clock_info *info,struct ptp_clock_request *request,int on) { -return -EOPNOTSUPP ; + struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data, + ptp_clock_info); +struct xgbe_pps_config *pps_cfg; +unsigned long flags; +int ret; + +dev_dbg (pdata->dev,"rq->type %d on %d\n" , request->type, on); + +if (request->type !=PTP_CLK_REQ_PEROUT ) +return -EOPNOTSUPP ; + + pps_cfg = &pdata->pps[request->perout.index]; + + pps_cfg->start.tv_sec = request->perout.start.sec; + pps_cfg->start.tv_nsec = request->perout.start.nsec; + pps_cfg->period.tv_sec = request->perout.period.sec; + pps_cfg->period.tv_nsec = request->perout.period.nsec; + +spin_lock_irqsave (&pdata->tstamp_lock, flags); + ret =xgbe_pps_config (pdata, pps_cfg, request->perout.index, on); +spin_unlock_irqrestore (&pdata->tstamp_lock, flags); + +return ret; }void xgbe_ptp_register (struct xgbe_prv_data *pdata)
@@ -122,6 +144,8 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata) info->adjtime = xgbe_adjtime; info->gettimex64 = xgbe_gettimex; info->settime64 = xgbe_settime; + info->n_per_out = pdata->hw_feat.pps_out_num; + info->n_ext_ts = pdata->hw_feat.aux_snap_num; info->enable = xgbe_enable; clock =ptp_clock_register (info, pdata->dev);
drivers/net/ethernet/amd/xgbe/xgbe.h +16 -0
@@ -142,6 +142,10 @@#define XGBE_V2_TSTAMP_SNSINC 0#define XGBE_V2_PTP_ACT_CLK_FREQ 1000000000 +/* Define maximum supported values */ +#define XGBE_MAX_PPS_OUT 4 +#define XGBE_MAX_AUX_SNAP 4 +/* Driver PMT macros */ #define XGMAC_DRIVER_CONTEXT 1#define XGMAC_IOCTL_CONTEXT 2
@@ -673,6 +677,11 @@ struct xgbe_ext_stats {u64 rx_vxlan_csum_errors; }; +struct xgbe_pps_config { +struct timespec64 start; +struct timespec64 period; +}; +struct xgbe_hw_if {int (*tx_complete)(struct xgbe_ring_desc *);
@@ -1143,6 +1152,9 @@ struct xgbe_prv_data {struct sk_buff *tx_tstamp_skb;u64 tx_tstamp; +/* Pulse Per Second output */ +struct xgbe_pps_config pps[XGBE_MAX_PPS_OUT ]; +/* DCB support */ struct ieee_ets *ets;struct ieee_pfc *pfc;
@@ -1305,6 +1317,10 @@ void xgbe_prep_tx_tstamp(struct xgbe_prv_data *pdata,int xgbe_init_ptp (struct xgbe_prv_data *pdata);void xgbe_update_tstamp_time (struct xgbe_prv_data *pdata,unsigned int sec,unsigned int nsec); + +int xgbe_pps_config (struct xgbe_prv_data *pdata,struct xgbe_pps_config *cfg, +int index,int on); +#ifdef CONFIG_DEBUG_FS void xgbe_debugfs_init (struct xgbe_prv_data *);void xgbe_debugfs_exit (struct xgbe_prv_data *);
Signature · 1 line
2.34.1
From: Raju Rangoju <[email protected]>
Date: Thu, 28 Aug 2025 14:59:00 +0530
Quoted 28 lines
Add support for hardware PPS (Pulse Per Second) output to the AMD XGBE driver. The implementation enables flexible periodic output mode, exposing it via the PTP
per_outinterface.The driver supports configuring PPS output using the standard PTP subsystem, allowing precise periodic signal generation for time synchronization applications.
The feature has been verified using the testptp tool and oscilloscope.
Signed-off-by Raju Rangoju <[email protected]>---
Changes since v2:
- avoid redundant checks inxgbe_enable()
- simplify the mask calculationChanges since v1:
- add sanity check to preventpps_out_numandaux_snap_numexceeding the limitdrivers/net/ethernet/amd/xgbe/Makefile | 2 +- drivers/net/ethernet/amd/xgbe/xgbe-common.h | 46 ++++++++++++- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 15 +++++ drivers/net/ethernet/amd/xgbe/xgbe-pps.c | 73 +++++++++++++++++++++ drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 26 +++++++- drivers/net/ethernet/amd/xgbe/xgbe.h | 16 +++++ 6 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 drivers/net/ethernet/amd/xgbe/xgbe-pps.c
[...]
drivers/net/ethernet/amd/xgbe/xgbe-drv.c void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) · line 696
Quoted 11 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +3
-0@@ -691,6 +691,21 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) hw_feat->pps_out_num =XGMAC_GET_BITS (mac_hfr2,MAC_HWF2R ,PPSOUTNUM ); hw_feat->aux_snap_num =XGMAC_GET_BITS (mac_hfr2,MAC_HWF2R ,AUXSNAPNUM ); +/* Sanity check and warn if hardware reports more than supported */ +if (hw_feat->pps_out_num >XGBE_MAX_PPS_OUT ) { + dev_warn(pdata->dev,
1. How often can this function be called? Don't you need the _ratelimit version here?
2. netdev_ variant instead of dev_?
drivers/net/ethernet/amd/xgbe/xgbe-drv.c void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) · line 703
Quoted 7 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +7
-0+"Hardware reports %u PPS outputs, limiting to %u\n" , + hw_feat->pps_out_num, XGBE_MAX_PPS_OUT); + hw_feat->pps_out_num =XGBE_MAX_PPS_OUT ; + } + +if (hw_feat->aux_snap_num >XGBE_MAX_AUX_SNAP ) { + dev_warn(pdata->dev,
(same)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) · line 705
Quoted 2 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +2
-0+"Hardware reports %u aux snapshot inputs, limiting to %u\n" , + hw_feat->aux_snap_num, XGBE_MAX_AUX_SNAP);
BTW, these messages are not very meaningful, maybe you should print both min and max and say that the actual HW output is out of range?
Quoted 22 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +3
-0+ hw_feat->aux_snap_num =XGBE_MAX_AUX_SNAP ; + } +/* Translate the Hash Table size into actual number */ switch (hw_feat->hash_table_size) {case 0 :drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +10
-0@@ -0,0 +1,73 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause) +/* +* Copyright (c) 2014-2025, Advanced Micro Devices, Inc. +* Copyright (c) 2014, Synopsys, Inc. +* All rights reserved +* +* Author: Raju Rangoju <[email protected]> +*/ + +#include "xgbe.h"
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 20
Quoted 10 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +10
-0+#include "xgbe-common.h" + +static inline u32 PPSx_MASK (unsigned int x) +{ +return GENMASK (PPS_MAXIDX (x),PPS_MINIDX (x)); +} + +static inline u32 PPSCMDx (unsigned int x,u32 val) +{ +return ((val &GENMASK (3 ,0 )) <<PPS_MINIDX (x));
Redundant outer ()s.
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 25
Quoted 5 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +5
-0+} + +static inline u32 TRGTMODSELx (unsigned int x,u32 val) +{ +return ((val &GENMASK (1 ,0 )) << (PPS_MAXIDX (x) -2 ));
Same here.
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 26
Quoted 1 line
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +1
-0+}
I believe you shouldn't name these functions that way, also pls no inlines in .c files.
Either give them proper names and remove inline or make macros from them.
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 29
Quoted 3 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +3
-0+ +int xgbe_pps_config (struct xgbe_prv_data *pdata, +struct xgbe_pps_config *cfg,int index,int on)
@on can be bool?
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 41
Quoted 12 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +12
-0+{ +unsigned int value =0 ; +unsigned int tnsec; +u64 period; + + tnsec =XGMAC_IOREAD (pdata,MAC_PPSx_TTNSR (index)); +if (XGMAC_GET_BITS (tnsec, MAC_PPSx_TTNSR,TRGTBUSY0 )) +return -EBUSY ; + + value =XGMAC_IOREAD (pdata,MAC_PPSCR ); + + value &= ~PPSx_MASK (index);
I'd remove that NL between these two or even squash them into 1 line if it fits into 80 chars.
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 47
Quoted 6 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +6
-0+ +if (!on) { + value |=PPSCMDx (index,0x5 ); + value |=PPSEN0 ; +XGMAC_IOWRITE (pdata,MAC_PPSCR , value); +return 0 ;
Newline before the return.
Quoted 15 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +15
-0+ } + +XGMAC_IOWRITE (pdata,MAC_PPSx_TTSR (index), cfg->start.tv_sec); +XGMAC_IOWRITE (pdata,MAC_PPSx_TTNSR (index), cfg->start.tv_nsec); + + period = cfg->period.tv_sec *NSEC_PER_SEC ; + period += cfg->period.tv_nsec; +do_div (period,XGBE_V2_TSTAMP_SSINC ); + +if (period <=1 ) +return -EINVAL ; + +XGMAC_IOWRITE (pdata,MAC_PPSx_INTERVAL (index), period -1 ); + period >>=1 ; +if (period <=1 )
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 72
Quoted 10 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +10
-0+return -EINVAL ; + +XGMAC_IOWRITE (pdata,MAC_PPSx_WIDTH (index), period -1 ); + + value |=PPSCMDx (index,0x2 ); + value |=TRGTMODSELx (index,0x2 ); + value |=PPSEN0 ; + +XGMAC_IOWRITE (pdata,MAC_PPSCR , value); +return 0 ;
Same here.
Quoted 21 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +1
-0+}drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +11
-1@@ -106,7 +106,29 @@ static int xgbe_settime(struct ptp_clock_info *info,static int xgbe_enable (struct ptp_clock_info *info,struct ptp_clock_request *request,int on) { -return -EOPNOTSUPP ; + struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data, + ptp_clock_info); +struct xgbe_pps_config *pps_cfg; +unsigned long flags; +int ret; + +dev_dbg (pdata->dev,"rq->type %d on %d\n" , request->type, on); + +if (request->type !=PTP_CLK_REQ_PEROUT ) +return -EOPNOTSUPP ; +
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c static int xgbe_settime(struct ptp_clock_info *info, · line 129
Quoted 10 lines
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +10
-0+ pps_cfg = &pdata->pps[request->perout.index]; + + pps_cfg->start.tv_sec = request->perout.start.sec; + pps_cfg->start.tv_nsec = request->perout.start.nsec; + pps_cfg->period.tv_sec = request->perout.period.sec; + pps_cfg->period.tv_nsec = request->perout.period.nsec; + +spin_lock_irqsave (&pdata->tstamp_lock, flags); + ret =xgbe_pps_config (pdata, pps_cfg, request->perout.index, on); +spin_unlock_irqrestore (&pdata->tstamp_lock, flags);
Are you sure you need to protect the whole xgbe_pps_config() from interrupts? It's quite large and I don't think you need that lock (and IRQ protection) for its entire runtime.
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c static int xgbe_settime(struct ptp_clock_info *info, · line 134
Quoted 5 lines
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +2
-0+ +return ret; }void xgbe_ptp_register (struct xgbe_prv_data *pdata)
Thanks,
Olek
Rangoju, Raju
maintainerQuoted 42 lines · Alexander Lobakin
From: Raju Rangoju <[email protected]>
Date: Thu, 28 Aug 2025 14:59:00 +0530Quoted 28 lines
Add support for hardware PPS (Pulse Per Second) output to the AMD XGBE driver. The implementation enables flexible periodic output mode, exposing it via the PTP
per_outinterface.The driver supports configuring PPS output using the standard PTP subsystem, allowing precise periodic signal generation for time synchronization applications.
The feature has been verified using the testptp tool and oscilloscope.
Signed-off-by Raju Rangoju <[email protected]>---
Changes since v2:
- avoid redundant checks inxgbe_enable()
- simplify the mask calculationChanges since v1:
- add sanity check to preventpps_out_numandaux_snap_numexceeding the limitdrivers/net/ethernet/amd/xgbe/Makefile | 2 +- drivers/net/ethernet/amd/xgbe/xgbe-common.h | 46 ++++++++++++- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 15 +++++ drivers/net/ethernet/amd/xgbe/xgbe-pps.c | 73 +++++++++++++++++++++ drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 26 +++++++- drivers/net/ethernet/amd/xgbe/xgbe.h | 16 +++++ 6 files changed, 173 insertions(+), 5 deletions(-)create mode 100644
drivers/net/ethernet/amd/xgbe/xgbe-pps.c[...]
Quoted 8 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +0
-0@@ -691,6 +691,21 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) hw_feat->pps_out_num =XGMAC_GET_BITS (mac_hfr2,MAC_HWF2R ,PPSOUTNUM ); hw_feat->aux_snap_num =XGMAC_GET_BITS (mac_hfr2,MAC_HWF2R ,AUXSNAPNUM );
Quoted 6 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) · line 696
Quoted 3 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +3
-0+/* Sanity check and warn if hardware reports more than supported */ +if (hw_feat->pps_out_num >XGBE_MAX_PPS_OUT ) { + dev_warn(pdata->dev,1. How often can this function be called? Don't you need the
_ratelimitversion here?
This is only called once after driver load, so _ratelimit may not be needed.
Quoted 1 line
2.
netdev_variant instead ofdev_?
This is in the early stages of probe, even before netdev is configured.
Quoted 11 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) · line 703
Quoted 8 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +7
-0+"Hardware reports %u PPS outputs, limiting to %u\n" , + hw_feat->pps_out_num, XGBE_MAX_PPS_OUT); + hw_feat->pps_out_num =XGBE_MAX_PPS_OUT ; + } + +if (hw_feat->aux_snap_num >XGBE_MAX_AUX_SNAP ) { + dev_warn(pdata->dev,(same)
Quoted 5 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) · line 705
Quoted 2 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +2
-0+"Hardware reports %u aux snapshot inputs, limiting to %u\n" , + hw_feat->aux_snap_num, XGBE_MAX_AUX_SNAP);BTW, these messages are not very meaningful, maybe you should print both min and max and say that the actual HW output is out of range?
XGBE_MAX_AUX_SNAP is max supported value, so limiting it only in case hardware reports more than max value. Any lower value should be fine.
Quoted 44 lines
Quoted 23 lines
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +3
-0+ hw_feat->aux_snap_num =XGBE_MAX_AUX_SNAP ; + } +/* Translate the Hash Table size into actual number */ switch (hw_feat->hash_table_size) {case 0 :drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +10
-0@@ -0,0 +1,73 @@ +// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause) +/* +* Copyright (c) 2014-2025, Advanced Micro Devices, Inc. +* Copyright (c) 2014, Synopsys, Inc. +* All rights reserved +* +* Author: Raju Rangoju <[email protected]> +*/ + +#include "xgbe.h" drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 20
Quoted 10 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +10
-0+#include "xgbe-common.h" + +static inline u32 PPSx_MASK (unsigned int x) +{ +return GENMASK (PPS_MAXIDX (x),PPS_MINIDX (x)); +} + +static inline u32 PPSCMDx (unsigned int x,u32 val) +{ +return ((val &GENMASK (3 ,0 )) <<PPS_MINIDX (x));Redundant outer ()s.
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 25
Quoted 5 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +5
-0+} + +static inline u32 TRGTMODSELx (unsigned int x,u32 val) +{ +return ((val &GENMASK (1 ,0 )) << (PPS_MAXIDX (x) -2 ));Same here.
Quoted 5 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 26
Quoted 1 line
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +1
-0+}I believe you shouldn't name these functions that way, also pls no inlines in .c files.
Either give them proper names and removeinlineor make macros from them.
Sure, will address these and above comments in next version.
Quoted 6 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 29
Quoted 4 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +3
-0+ +int xgbe_pps_config (struct xgbe_prv_data *pdata, +struct xgbe_pps_config *cfg,int index,int on)@on can be bool?
Yes, will address this.
Quoted 17 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 41
Quoted 13 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +12
-0+{ +unsigned int value =0 ; +unsigned int tnsec; +u64 period; + + tnsec =XGMAC_IOREAD (pdata,MAC_PPSx_TTNSR (index)); +if (XGMAC_GET_BITS (tnsec, MAC_PPSx_TTNSR,TRGTBUSY0 )) +return -EBUSY ; + + value =XGMAC_IOREAD (pdata,MAC_PPSCR ); + + value &= ~PPSx_MASK (index);I'd remove that NL between these two or even squash them into 1 line if it fits into 80 chars.
Quoted 8 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 47
Quoted 6 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +6
-0+ +if (!on) { + value |=PPSCMDx (index,0x5 ); + value |=PPSEN0 ; +XGMAC_IOWRITE (pdata,MAC_PPSCR , value); +return 0 ;Newline before the return.
sure, will drop this in next version of patch
Quoted 56 lines
Quoted 16 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +15
-0+ } + +XGMAC_IOWRITE (pdata,MAC_PPSx_TTSR (index), cfg->start.tv_sec); +XGMAC_IOWRITE (pdata,MAC_PPSx_TTNSR (index), cfg->start.tv_nsec); + + period = cfg->period.tv_sec *NSEC_PER_SEC ; + period += cfg->period.tv_nsec; +do_div (period,XGBE_V2_TSTAMP_SSINC ); + +if (period <=1 ) +return -EINVAL ; + +XGMAC_IOWRITE (pdata,MAC_PPSx_INTERVAL (index), period -1 ); + period >>=1 ; +if (period <=1 )drivers/net/ethernet/amd/xgbe/xgbe-pps.c line 72
Quoted 10 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +10
-0+return -EINVAL ; + +XGMAC_IOWRITE (pdata,MAC_PPSx_WIDTH (index), period -1 ); + + value |=PPSCMDx (index,0x2 ); + value |=TRGTMODSELx (index,0x2 ); + value |=PPSEN0 ; + +XGMAC_IOWRITE (pdata,MAC_PPSCR , value); +return 0 ;Same here.
Quoted 27 lines
drivers/net/ethernet/amd/xgbe/xgbe-pps.c new file +1
-0+}drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +17
-1@@ -106,7 +106,29 @@ static int xgbe_settime(struct ptp_clock_info *info,static int xgbe_enable (struct ptp_clock_info *info,struct ptp_clock_request *request,int on) { -return -EOPNOTSUPP ; + struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data, + ptp_clock_info); +struct xgbe_pps_config *pps_cfg; +unsigned long flags; +int ret; + +dev_dbg (pdata->dev,"rq->type %d on %d\n" , request->type, on); + +if (request->type !=PTP_CLK_REQ_PEROUT ) +return -EOPNOTSUPP ; + + pps_cfg = &pdata->pps[request->perout.index]; + + pps_cfg->start.tv_sec = request->perout.start.sec; + pps_cfg->start.tv_nsec = request->perout.start.nsec; + pps_cfg->period.tv_sec = request->perout.period.sec; + pps_cfg->period.tv_nsec = request->perout.period.nsec;
Quoted 8 lines
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c static int xgbe_settime(struct ptp_clock_info *info, · line 129
Quoted 4 lines
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +4
-0+ +spin_lock_irqsave (&pdata->tstamp_lock, flags); + ret =xgbe_pps_config (pdata, pps_cfg, request->perout.index, on); +spin_unlock_irqrestore (&pdata->tstamp_lock, flags);Are you sure you need to protect the whole
xgbe_pps_config()from interrupts? It's quite large and I don't think you need that lock (and IRQ protection) for its entire runtime.
xgbe_pps_config() touches the hardware registers throughout the function, so this protection is needed.
Quoted 9 lines
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c static int xgbe_settime(struct ptp_clock_info *info, · line 134
Quoted 6 lines
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +2
-0+ +return ret; }void xgbe_ptp_register (struct xgbe_prv_data *pdata)Thanks,
Olek