When an SDP (Software Definable Pin) is configured as a periodic output,
the driver already sets PIN_DIR (output) and PIN_FUNC (routing the pin
to the timer's AUX output) in GPIO_CTL, but leaves TRI_CTL cleared. Per
the hardware definition, TRI_CTL (bit 5) is meaningful only for single
ended GPIOs configured as output and driven high: 0b tristates the pin,
1b drives it high.
With TRI_CTL cleared, the pin is driven low but tristated instead of
driven high, so the high level comes only from the pull-up and the
rising edge is slow. A device that timestamps this signal sees the
rising edge late. The measured delay was ~6 us, and it depends on the
board and the load on the line. This adds an offset and jitter between
the PHC and the device that consumes the signal. Examples are a second
NIC using EXTTS, a DPLL input or a measurement instrument.
The problem was found during development, while validating periodic
output signal quality with an oscilloscope. It was not found by static
analysis.
To reproduce, enable a 1 PPS periodic output on one of the SDPs, e.g.:
testptp -d /dev/ptpX -L <pin>,2
testptp -d /dev/ptpX -p 1000000000
and probe the pin with an oscilloscope. The rising edge is delayed by
~6 us.
Set TRI_CTL, the only missing bit, when enabling periodic outputs, so
the pin is actively driven high. With this change the rising edge delay
drops from ~6 us to ~50 ns. This has no effect on pins that are not
single ended SDPs, such as the differential 1PPS output.
Fixes: 172db5f91d5f ("ice: add support for auxiliary input/output pins")
Reviewed-by: Przemek Kitszel <prze…@intel.com>
Signed-off-by: Maciek Machnikowski <maci…@intel.com>
---
drivers/net/ethernet/intel/ice/ice_hw_autogen.h | 1 +
drivers/net/ethernet/intel/ice/ice_ptp.c | 7 +++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
index 082ad33c53dc..1d538a04196c 100644
--- a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
+++ b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
@@ -154,6 +154,7 @@
#define GLGEN_CLKSTAT_SRC 0x000B826C
#define GLGEN_GPIO_CTL(_i) (0x000880C8 + ((_i) * 4))
#define GLGEN_GPIO_CTL_PIN_DIR_M BIT(4)
+#define GLGEN_GPIO_CTL_TRI_CTL_M BIT(5)
#define GLGEN_GPIO_CTL_PIN_FUNC_S 8
#define GLGEN_GPIO_CTL_PIN_FUNC_M ICE_M(0xF, 8)
#define GLGEN_RSTAT 0x000B8188
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index 30bc2d8aed9e..803744ff1a89 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -1762,9 +1762,12 @@ static int ice_ptp_write_perout(struct ice_hw *hw, unsigned int chan,
/* 4. write GPIO CTL reg */
val = GLGEN_GPIO_CTL_PIN_DIR_M;
- if (!!period)
- val |= FIELD_PREP(GLGEN_GPIO_CTL_PIN_FUNC_M,
+ if (!!period) {
+ /* TRI_CTL=1 drives SDPs high instead of tristating them */
+ val |= GLGEN_GPIO_CTL_TRI_CTL_M |
+ FIELD_PREP(GLGEN_GPIO_CTL_PIN_FUNC_M,
8 + chan + (tmr_idx * 4));
+ }
wr32(hw, GLGEN_GPIO_CTL(gpio_pin), val);
ice_flush(hw);
--
2.56.1